Open hi-ogawa opened 2 months ago
When I debug this locally, it looks like createOptimizeDepsIncludeResolver
is returning with __vite_skip_optimization
:
id: '@remix-run/server-runtime > cookie',
entry: '/home/hiroshi/code/personal/vite-plugins/node_modules/.pnpm/cookie@0.6.0/node_modules/cookie/index.js?__vite_skip_optimization'
which in turn is coming from the condition isInNodeModules(importer) = true
where importer is @remix-run/server-runtime
:
Describe the bug
Spinned off from the comment here by @frandiox https://github.com/vitejs/vite/issues/16293#issuecomment-2049573464, it looks like
ssr.optimizeDeps.include: ['dep1 > dep2']
is not working.For example, when adding
@remix-run/server-runtime > cookie
, the deps optimizer seems to reject it by:Reproduction
https://github.com/hi-ogawa/reproductions/tree/main/vite-ssr-optimizedeps-include-deep
https://stackblitz.com/github/hi-ogawa/reproductions/tree/main/vite-ssr-optimizedeps-include-deep
Steps to reproduce
Show error logs
```sh $ node repro.mjs Forced re-optimization of dependencies Forced re-optimization of dependencies Cannot optimize dependency: @remix-run/server-runtime > cookie, present in 'ssr.optimizeDeps.include' 11:57:10 AM [vite] Error when evaluating SSR module /node_modules/cookie/index.js?v=e9d0870e: |- ReferenceError: exports is not defined at eval (/home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/cookie/index.js?v=e9d0870e:17:1) at instantiateModule (file:///home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:55071:15) 11:57:10 AM [vite] Error when evaluating SSR module /node_modules/@remix-run/server-runtime/dist/esm/cookies.js?v=e9d0870e: failed to import "/node_modules/cookie/index.js?v=e9d0870e" |- ReferenceError: exports is not defined at eval (/home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/cookie/index.js?v=e9d0870e:17:1) at instantiateModule (file:///home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:55071:15) 11:57:10 AM [vite] Error when evaluating SSR module /node_modules/@remix-run/server-runtime/dist/esm/index.js?v=e9d0870e: failed to import "/node_modules/@remix-run/server-runtime/dist/esm/cookies.js?v=e9d0870e" |- ReferenceError: exports is not defined at eval (/home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/cookie/index.js?v=e9d0870e:17:1) at instantiateModule (file:///home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:55071:15) 11:57:10 AM [vite] Error when evaluating SSR module /repro-entry.ts: failed to import "/node_modules/@remix-run/server-runtime/dist/esm/index.js?v=e9d0870e" |- ReferenceError: exports is not defined at eval (/home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/cookie/index.js?v=e9d0870e:17:1) at instantiateModule (file:///home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:55071:15) ReferenceError: exports is not defined at eval (/home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/cookie/index.js?v=e9d0870e:17:1) at instantiateModule (file:///home/hiroshi/code/personal/reproductions/vite-ssr-optimizedeps-include-deep/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:55071:15) ```In this reproduction, I have
noExternal: true
to see the clear error. When removingnoExternal: true
,cookie
is externalized, so there's no error, but the same deps optimizer logs come up:System Info
Used Package Manager
npm
Logs
No response
Validations