Skip to content

Commit db2b2c4

Browse files
fix: do not add ESM deps to optimizeDeps without a '.' export (#4855)
1 parent 4e2605a commit db2b2c4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ export default createStartHandler({
104104
if (opts.name === '@tanstack/react-router-devtools') {
105105
return 'exclude'
106106
}
107-
if ('react' in opts.peerDependencies) {
107+
if (
108+
opts.exports &&
109+
'.' in opts.exports &&
110+
'react' in opts.peerDependencies
111+
) {
108112
return 'include'
109113
}
110114
return undefined

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface TanStackStartVitePluginCoreOptions {
4747
crawlPackages?: (opts: {
4848
name: string
4949
peerDependencies: Record<string, any>
50+
exports?: Record<string, any>
5051
}) => 'include' | 'exclude' | undefined
5152
}
5253
// this needs to live outside of the TanStackStartVitePluginCore since it will be invoked multiple times by vite
@@ -110,6 +111,7 @@ export function TanStackStartVitePluginCore(
110111
const internalResult = opts.crawlPackages?.({
111112
name: pkgJson.name,
112113
peerDependencies,
114+
exports: pkgJson.exports,
113115
})
114116
if (internalResult) {
115117
if (internalResult === 'exclude') {

0 commit comments

Comments
 (0)