Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 24 additions & 23 deletions packages/react-start/src/plugin/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,31 @@ export function tanstackStart(
},
optimizeDeps:
environmentName === VITE_ENVIRONMENT_NAMES.client ||
(environmentName === VITE_ENVIRONMENT_NAMES.server &&
// This indicates that the server environment has opted in to dependency optimization
options.optimizeDeps?.noDiscovery === false)
(environmentName === VITE_ENVIRONMENT_NAMES.server &&
// This indicates that the server environment has opted in to dependency optimization
options.optimizeDeps?.noDiscovery === false)
? {
// As `@tanstack/react-start` depends on `@tanstack/react-router`, we should exclude both.
exclude: [
'@tanstack/react-start',
'@tanstack/react-router',
'@tanstack/react-router-devtools',
'@tanstack/start-static-server-functions',
],
include: [
'react',
'react/jsx-runtime',
'react/jsx-dev-runtime',
'react-dom',
...(environmentName === VITE_ENVIRONMENT_NAMES.client
? ['react-dom/client']
: ['react-dom/server']),
// `@tanstack/react-store` has a dependency on `use-sync-external-store`, which is CJS.
// It therefore needs to be included so that it is converted to ESM.
'@tanstack/react-router > @tanstack/react-store',
],
}
// As `@tanstack/react-start` depends on `@tanstack/react-router`, we should exclude both.
exclude: [
'@tanstack/react-start',
'@tanstack/react-router',
'@tanstack/react-router-devtools',
'@tanstack/start-static-server-functions',
],
include: [
'react',
'react/jsx-runtime',
'react/jsx-dev-runtime',
'react-dom',
...(environmentName === VITE_ENVIRONMENT_NAMES.client
? ['react-dom/client']
: ['react-dom/server']),
// `@tanstack/react-store` has a dependency on `use-sync-external-store`, which is CJS.
// It therefore needs to be included so that it is converted to ESM.
'@tanstack/react-router > @tanstack/react-store',
...(options.optimizeDeps?.exclude?.find(x => x === '@tanstack/react-form') ? ['@tanstack/react-form > @tanstack/react-store'] : []),
],
}
: undefined,
}
},
Expand Down
Loading