Skip to content

Commit c6574ea

Browse files
schiller-manueltannerlinsley
authored andcommitted
fix optimizeDeps
1 parent 3884b7c commit c6574ea

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

packages/react-start/src/plugin/vite.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
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'
36
import path from 'pathe'
47
import type { TanStackStartInputConfig } from '@tanstack/start-plugin-core'
58
import type { PluginOption } from 'vite'
@@ -43,14 +46,15 @@ export function tanstackStart(
4346
return [
4447
{
4548
name: 'tanstack-react-start:config',
46-
configEnvironment() {
49+
configEnvironment(env, userConfig) {
4750
return {
4851
resolve: {
4952
dedupe: ['react', 'react-dom', '@tanstack/react-router'],
5053

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'],
5458
},
5559

5660
optimizeDeps: {
@@ -62,6 +66,9 @@ export function tanstackStart(
6266
'react-dom',
6367
'react-dom/client',
6468
'@tanstack/react-router',
69+
...(env === VITE_ENVIRONMENT_NAMES.server
70+
? ['react-dom/server']
71+
: []),
6572
],
6673
},
6774
}

packages/start-plugin-core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ export type { TanStackStartInputConfig } from './schema'
22

33
export { TanStackStartVitePluginCore } from './plugin'
44
export { resolveViteId } from './utils'
5+
6+
export { VITE_ENVIRONMENT_NAMES } from './constants'

packages/start-plugin-core/src/plugin.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,18 @@ export function TanStackStartVitePluginCore(
218218
viteConfig.environments?.[VITE_ENVIRONMENT_NAMES.server]
219219
?.build?.copyPublicDir ?? false,
220220
},
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+
},
221233
},
222234
},
223235
resolve: {

0 commit comments

Comments
 (0)