-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
vitest-dev/vitest
#7846Closed
Copy link
Labels
feat: ssrp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
Example code
- dep.js
export const a = "dep-a"
export const b = "dep-b"
export const c = "dep-c"- main.js
export const a = "main-a"
export * from "./dep.js"
export const c = "main-c"expected
❯ node -e 'import("./src/main.js").then(console.log)'
[Module: null prototype] { a: 'main-a', c: 'main-c', b: 'dep-b' }(Also rollup output on repl)
actual
# get "dep-a" instead of "main-a"
❯ node repro.js
{"a":"dep-a","b":"dep-b","c":"main-c"}Side note: Current Vite SSR works if export const comes after export *. But, probably export hoisting PR #18983 currently breaks this pattern all the time. I think technically this is solvable if we gather local named export names first and then pass and exclude them from exportAll runtime function:
| [ssrExportAllKey]: (obj: any) => exportAll(exports, obj), |
Reproduction
https://stackblitz.com/edit/vitejs-vite-kkt7njfs?file=src%2Fmain.js
Steps to reproduce
- Open stackblitz
- run
node repro.js - run
node -e 'import("./src/main.js").then(console.log)'
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vite: ^6.2.0 => 6.2.0Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
feat: ssrp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)