You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c593dea
Browse filesBrowse the repository at this point in the historyBrowse files
fix(concatenation): keep wrapped module names and side effects intact (#21593)
* fix(concatenation): keep wrapped module names and side effects intact
A wrapped CommonJS body is emitted verbatim and never scope-analysed, so its
identifiers were unknown when the concatenation allocated its own top-level
names. A local declaration could shadow the wrapper accessor it calls, and a
free global could be captured by another member's top-level binding. Claim the
body's identifiers instead, in place of the scope analysis that is skipped.
An unused export of a wrapped module also collapsed to `undefined`, dropping
the accessor call with it — and with it the module's side effects, which a
hoisted body would still have run at its own slot.
* fix(concatenation): drop the dead identifier cache and untestable branch
Coverage showed the WeakMap around the identifier scan never hit: each
_analyseModule builds a fresh Source, so the key is always new. It cost an
allocation and a lookup per wrapped body for nothing.
The unused-export change at the second getFinalBinding site is reverted: no
build reaches it, because an unused ESM re-export of a wrapped module is
dropped before code generation. The require()-shaped site keeps the fix and
is the one a build actually hits.
* test: make three cases hermetic against a shared global
ConfigTestCases and ConfigCacheTestCases run the same cases, and a worker that
shares one global between test files (Bun's --workerThreads) carries their
leftovers into the second run. The harness only clears globals whose name
contains "webpack", so a plain counter survives: the deferred-evaluation case
then saw a non-zero count and the inline-exports case saw its side effects
twice. Both now clear their own counter.
The amd-runtimeChunk library variants are a timing difference, not a leftover:
the `promise` external is still settling when the harness deletes the chunk
loading globals, which only survives because Node gives each test file a fresh
global. Filtered out under Bun until the harness can await those externals.
0 commit comments