-
Notifications
You must be signed in to change notification settings - Fork 710
Description
Reproduction link or steps
- Open https://stackblitz.com/edit/rolldown-rolldown-starter-stackblitz-kahhkybh?file=rolldown.config.mjs
pnpm iruns automaticallypnpm buildruns automaticallynode src/entry.jsdoes not throw an errornode dist/entry.jsthrows an error
What is expected?
No error happens after build.
What is actually happening?
The following error happens after build:
ReferenceError: globalValue is not defined
System Info
StackBlitz
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.1 - /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:
rolldown: latest => 1.0.0-beta.27Any additional comments?
#__PURE__ only means "the code can be safely removed if not used". It does not mean "the code does not rely on the execution order".
Specifically, this line should be checking whether this module relies on the execution order (e.g. reading a global variable), not whether it has a side effect.
| if !module.meta.contains(EcmaViewMeta::HAS_ANALYZED_SIDE_EFFECT) |
This is because even if a module doesn't have a side effect (e.g. writing a global variable, console logging), it can rely on the side effect that is caused by other modules. So those modules should be wrapped to keep the execution order.
That said, in most cases "the code can be safely removed if not used" and "the code does not rely on the execution order" are equivalent. So this is an edge case. If someone encounters this in real world code, please comment on this issue.
Reactions are currently unavailable