-
-
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
fix(ssr): named export should overwrite export all #19534
Conversation
// ESM spec doesn't allow conflicting `export *` and such duplicate exports are removed (in this case "d"), | ||
// but this is likely not possible to support due to Vite dev SSR's lazy nature. | ||
// [Node] | ||
// $ node -e 'import("./packages/vite/src/node/ssr/__tests__/fixtures/named-overwrite-all/main.js").then(console.log)' | ||
// [Module: null prototype] { a: 'main-a', b: 'dep1-b', c: 'main-c' } | ||
// [Rollup] | ||
// Conflicting namespaces: "main.js" re-exports "d" from one of the modules "dep1.js" and "dep2.js" (will be ignored). | ||
expect(mod).toMatchInlineSnapshot(` | ||
{ | ||
"a": "main-a", | ||
"b": "dep1-b", | ||
"c": "main-c", | ||
"d": "dep1-d", | ||
} | ||
`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just learned that ESM spec says duplicate names from export * from ...
should be removed entirely 😮 (Didn't actually read the spec but it's on MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#specifications:~:text=If%20there%20are%20two%20wildcard%20exports%20statements%20that%20implicitly%20re%2Dexport%20the%20same%20name%2C%20neither%20one%20is%20re%2Dexported.)
I think this case is hard to handle on Vite SSR model, so the behavior here is that first export *
wins.
/ecosystem-ci run |
commit: |
📝 Ran ecosystem CI on
✅ quasar, histoire, laravel, ladle, analogjs, vite-plugin-react, vite-plugin-pwa, sveltekit, rakkas, vite-environment-examples, react-router, previewjs, marko, unocss, qwik, storybook, vuepress, vitepress, vitest, vite-plugin-cloudflare, waku, vite-setup-catalogue, vite-plugin-react-swc, vite-plugin-vue |
📝 Ran ecosystem CI on
✅ analogjs, laravel, qwik, histoire, unocss, storybook, previewjs, react-router, vike, rakkas, vite-setup-catalogue, vitepress, vite-plugin-vue, vite-environment-examples, sveltekit, vite-plugin-react, quasar, vite-plugin-react-swc, vite-plugin-cloudflare, vuepress, vite-plugin-pwa, waku, vitest, marko, ladle |
📝 Ran ecosystem CI on
✅ ladle, previewjs, marko, analogjs, vike, unocss, laravel, vite-plugin-react, histoire, sveltekit, vite-plugin-react-swc, vite-environment-examples, qwik, vite-setup-catalogue, rakkas, react-router, vite-plugin-pwa, quasar, nuxt, vite-plugin-vue, storybook, vite-plugin-cloudflare, vuepress, vitest, vitepress, waku |
Description
*
re-export by named export #19525 (comment)This change should also help when named export is hoisted in #18983.