Skip to content

fix(ssr): fix transform error due to export all id scope#19331

Merged
patak-cat merged 1 commit intovitejs:mainfrom
hi-ogawa:fix-ssr-transform-export-all-id-scope
Feb 1, 2025
Merged

fix(ssr): fix transform error due to export all id scope#19331
patak-cat merged 1 commit intovitejs:mainfrom
hi-ogawa:fix-ssr-transform-export-all-id-scope

Conversation

@hi-ogawa
Copy link
Copy Markdown
Contributor

@hi-ogawa hi-ogawa commented Feb 1, 2025

Description

Even on Vite 5, SSR transform wasn't properly handling the identifier from export * as id from ".." as seen by the same repro https://stackblitz.com/edit/github-pnyojxdr-mena4fdt?file=repro-vite.js

const __vite_ssr_import_0__ = await __vite_ssr_import__('x');

const __vite_ssr_import_1__ = await __vite_ssr_import__('x');

Object.defineProperty(__vite_ssr_exports__, 'x', {
  enumerable: true,
  configurable: true,
  get() {
    return __vite_ssr_import_1__;
  },
});
__vite_ssr_import_0__; /// <-- what's this?

I haven't investigated why this now causes magic-string error, but this can be fixed by fixing isRefIdentifier to skip identifiers inside export * ....

@hi-ogawa hi-ogawa marked this pull request as ready for review February 1, 2025 09:16
@patak-cat patak-cat merged commit e28bce2 into vitejs:main Feb 1, 2025
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants