-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
ssr: Nested built-in dependencies of ESM dependencies can't be resolved #4700
Comments
This error occurs because vite/packages/vite/src/node/optimizer/esbuildDepPlugin.ts Lines 113 to 131 in e623b4a
Vite's own resolver will return the built-in module id, the id will be resolved by The resolved content is wrong, we need to externalize the built-in module during SSR, modify the source code: if (isExternalUrl(resolved) || (ssr && isBuiltin(id))) {
return {
path: resolved,
external: true
}
} So the esbuild will resolve the correct content. I will submit a pull request later. |
Thanks, @ygj6. You're a hero! |
Describe the bug
When I attempt to load an entrypoint with
ssrLoadModule
which references an ESM dependency e.g. https://github.com/jplhomer/repro-ssr-pkg, there is anesbuild
error indicating the built-in dependency cannot be loaded.This only happens during the
optimize missing deps
phase of the dev server.Potential similar issues, but slightly different:
ssrLoadModule
does not load nested dependency #3609Reproduction
https://github.com/jplhomer/repro-ssr-modules
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: