-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transitive dependencies of linked dependencies are bundled in SSR build #19403
Comments
I have this issue when importing Sentry with Nuxt as it requires require-in-the-middle |
This is somewhat expected since externalizing transitive dependency won't be necessary visible from the bundled application directory. You have to manually mark This is not the case for SSR dev, so this is technically dev/build inconsistency, but if dev is aligned with build, then it still need to require having externalized transitive dependency explicitly as application dependency. Last time I checked, that's basically what Next.js does and they have a warning for that case. Here is a reference if anyone is interested https://github.com/hi-ogawa/reproductions/tree/main/next-external-import.
|
It looks like OP has addressed the issue on |
Describe the bug
I have a pnpm monorepo containing packages
app
andshared
.app
depends onshared
.My expectation is that
shared
inapp
's SSR build for HMR, because it is a linked dependency and therefore is not externalized.shared
's dependencies inshared/node_modules
remain external.What actually happens is that Vite bundles
shared
's dependencies intoapp
's SSR build as well asshared
itself. This breaks our app becauseshared
pulls in a CJS module (require-in-the-middle
) which explodes if it is loaded in an ESM context (nodejs/require-in-the-middle#110).Reproduction
https://github.com/haines/vite-ssr-externals-repro
Steps to reproduce
Clone the repo and run
pnpm run repro
(which is equivalent to runningpnpm install
followed bypnpm run build
andpnpm run preview
in theapp
).The SSR bundle
packages/app/dist/server/entry-server.js
will includerequire-in-the-middle
rather than importing it frompackages/shared/node_modules
. This will cause the server to blow up withSystem Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: