-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Labels
feat: ssrp2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)
Description
Describe the bug
- main.js
import * as lib from './lib.js';
lib.default();
setTimeout(() => {
lib.default();
}, 200);
- lib.js
export default function f() {
console.log('a');
}
f = () => {
console.log('b');
};
setTimeout(() => {
f = () => {
console.log('c');
};
}, 100);
On Node:
❯ node src/main.js
b
c
On Vite module runner
❯ node repro.js
b
b
Spec explains live binding as "ExportEntry Record [[LocalName]]", for example, this table https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#table-export-forms-mapping-to-exportentry-records
This is a fairly stretched edge case, but just found that Oxc uses Object.defineProperty(..., { get: ... })
while Vite uses Object.defineProperty(..., { value: ... })
and Oxc's implementation seems to be actually correct one.
Reproduction
https://stackblitz.com/edit/vitejs-vite-b63hinxr?file=src%2Flib.js
Steps to reproduce
open stackblitz
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: 20.19.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vite: ^6.2.2 => 6.2.5
Used 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: ssrp2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)