You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the SSR dep optimizer is only invoked the first time ssrLoadModule is invoked. Subsequent calls will noop the dep optimization process even when additional dependencies have been push to the ssr.optimizeDeps.include array.
The problem appears to be caused by the below check, which removing it causes the optimizer to run and transform the dependency correctly.
8:58:08 AM [vite] Error when evaluating SSR module /cjs-dep-two/index.js:
|- ReferenceError: exports is not defined
at eval (//cjs-dep-two/index.js:3:14)
at instantiateModule (file:////node_modules/vite/dist/node/chunks/dep-bb8a8339.js:56052:15)
8:58:08 AM [vite] Error when evaluating SSR module ./src/entry-server.mjs: failed to import "/cjs-dep-two/index.js"
|- ReferenceError: exports is not defined
at eval (//cjs-dep-two/index.js:3:14)
at instantiateModule (file:////node_modules/vite/dist/node/chunks/dep-bb8a8339.js:56052:15)
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
ReferenceError: exports is not defined
at eval (//cjs-dep-two/index.js:3:14)
at instantiateModule (file:////node_modules/vite/dist/node/chunks/dep-bb8a8339.js:56052:15)
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
This was intentionally set because there was not way to restart the module in SSR (like you can reload the window in browsers).
In Vite v6 beta, we made optimizeDeps.noDiscovery: false to opt-in this behavior (#18358). But this requires the framework author (the user calling runner.import) to handle the restart.
I'd be great if you can try it out and leave a feedback at #16358.
Describe the bug
Currently, the SSR dep optimizer is only invoked the first time
ssrLoadModule
is invoked. Subsequent calls will noop the dep optimization process even when additional dependencies have been push to thessr.optimizeDeps.include
array.The problem appears to be caused by the below check, which removing it causes the optimizer to run and transform the dependency correctly.
vite/packages/vite/src/node/optimizer/optimizer.ts
Lines 68 to 71 in bd4d29f
Reproduction
https://github.com/alan-agius4/vite-dep-optimizer-ssr-once
Steps to reproduce
System Info
Used Package Manager
npm
Logs
Expected
Actual
Validations
The text was updated successfully, but these errors were encountered: