-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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): inject identity function at the top #18449
fix(ssr): inject identity function at the top #18449
Conversation
"const __vite_ssr_identity__ = v => v; | ||
const __vite_ssr_import_0__ = await __vite_ssr_import__("./foo", {"importedNames":["foo"]}); | ||
|
||
|
||
__vite_ssr_exports__.default = __vite_ssr_identity__(__vite_ssr_import_0__.foo)() | ||
const __vite_ssr_import_1__ = await __vite_ssr_import__("./bar"); | ||
|
||
Object.defineProperty(__vite_ssr_exports__, "bar", { enumerable: true, configurable: true, get(){ return __vite_ssr_import_1__ }}); | ||
console.log(bar) |
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.
The output without the fix is:
const __vite_ssr_import_0__ = await __vite_ssr_import__("./foo", {"importedNames":["foo"]});
__vite_ssr_exports__.default = __vite_ssr_identity__(__vite_ssr_import_0__.foo)()
const __vite_ssr_import_1__ = await __vite_ssr_import__("./bar");
const __vite_ssr_identity__ = v => v;
Object.defineProperty(__vite_ssr_exports__, "bar", { enumerable: true, configurable: true, get(){ return __vite_ssr_import_1__ }});
console.log(bar)
Note that __vite_ssr_identity__
is called before declaration.
/ecosystem-ci run |
📝 Ran ecosystem CI on
✅ analogjs, histoire, ladle, laravel, marko, nuxt, quasar, qwik, rakkas, storybook, unocss, vite-environment-examples, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-vue, vite-setup-catalogue, vitepress, vuepress |
Vike had a similar error (https://github.com/vitejs/vite-ecosystem-ci/actions/runs/11496916712/job/31999518321#step:8:1969) and that is fixed by this PR too. |
Description
This PR should fix marko's fail in #9981 (comment).