File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { fileURLToPath } from 'node:url'
2
- import { TanStackStartVitePluginCore } from '@tanstack/start-plugin-core'
2
+ import {
3
+ TanStackStartVitePluginCore ,
4
+ VITE_ENVIRONMENT_NAMES ,
5
+ } from '@tanstack/start-plugin-core'
3
6
import path from 'pathe'
4
7
import type { TanStackStartInputConfig } from '@tanstack/start-plugin-core'
5
8
import type { PluginOption } from 'vite'
@@ -43,14 +46,15 @@ export function tanstackStart(
43
46
return [
44
47
{
45
48
name : 'tanstack-react-start:config' ,
46
- configEnvironment ( ) {
49
+ configEnvironment ( env , userConfig ) {
47
50
return {
48
51
resolve : {
49
52
dedupe : [ 'react' , 'react-dom' , '@tanstack/react-router' ] ,
50
53
51
- external : isInsideRouterMonoRepo
52
- ? [ '@tanstack/react-router' , '@tanstack/react-router-devtools' ]
53
- : undefined ,
54
+ external :
55
+ userConfig . resolve ?. noExternal === true || ! isInsideRouterMonoRepo
56
+ ? undefined
57
+ : [ '@tanstack/react-router' , '@tanstack/react-router-devtools' ] ,
54
58
} ,
55
59
56
60
optimizeDeps : {
@@ -62,6 +66,9 @@ export function tanstackStart(
62
66
'react-dom' ,
63
67
'react-dom/client' ,
64
68
'@tanstack/react-router' ,
69
+ ...( env === VITE_ENVIRONMENT_NAMES . server
70
+ ? [ 'react-dom/server' ]
71
+ : [ ] ) ,
65
72
] ,
66
73
} ,
67
74
}
Original file line number Diff line number Diff line change @@ -2,3 +2,5 @@ export type { TanStackStartInputConfig } from './schema'
2
2
3
3
export { TanStackStartVitePluginCore } from './plugin'
4
4
export { resolveViteId } from './utils'
5
+
6
+ export { VITE_ENVIRONMENT_NAMES } from './constants'
Original file line number Diff line number Diff line change @@ -218,6 +218,18 @@ export function TanStackStartVitePluginCore(
218
218
viteConfig . environments ?. [ VITE_ENVIRONMENT_NAMES . server ]
219
219
?. build ?. copyPublicDir ?? false ,
220
220
} ,
221
+ optimizeDeps : {
222
+ exclude : [
223
+ ...Object . values ( VIRTUAL_MODULES ) ,
224
+ ...result . optimizeDeps . exclude . sort ( ) ,
225
+ ...additionalOptimizeDeps . exclude ,
226
+ `@tanstack/${ corePluginOpts . framework } -start/server-functions-server` ,
227
+ ] ,
228
+ include : [
229
+ ...additionalOptimizeDeps . include ,
230
+ ...result . optimizeDeps . include . sort ( ) ,
231
+ ] ,
232
+ } ,
221
233
} ,
222
234
} ,
223
235
resolve : {
You can’t perform that action at this time.
0 commit comments