fix: merge inner modules' top level declarations in concatenated modules#21170
Conversation
The merge loop in ConcatenatedModule._build self-shadowed topLevelDeclarations and added the concatenated module's own (empty) set into itself, so buildInfo.topLevelDeclarations stayed empty and library/name-conflict checks falling back to buildInfo saw no declarations. https://claude.ai/code/session_01FM4kEXcEzgChtBzmuoRA1C
|
This PR is packaged and the instant preview is available (5f01ae5). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@5f01ae5
yarn add -D webpack@https://pkg.pr.new/webpack@5f01ae5
pnpm add -D webpack@https://pkg.pr.new/webpack@5f01ae5 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21170 +/- ##
==========================================
- Coverage 92.58% 92.58% -0.01%
==========================================
Files 587 587
Lines 63666 63666
Branches 17636 17636
==========================================
- Hits 58946 58943 -3
- Misses 4720 4723 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 30.55%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
130 KB | 859.3 KB | -84.87% |
| ❌ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
319.7 KB | 884.8 KB | -63.87% |
| ❌ | Memory | benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
151.9 KB | 330.1 KB | -53.98% |
| ⚡ | Memory | benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,291.9 KB | 318.7 KB | ×4.1 |
| ⚡ | Memory | benchmark "side-effects-reexport", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,201.8 KB | 758.6 KB | +58.43% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix/concat-top-level-declarations (b78b8d7) with main (6e52971)
Summary
A self-shadowed variable in
ConcatenatedModule._buildmade the merge loop addbuildInfo.topLevelDeclarationsinto itself, so concatenated modules always exposed an empty set instead of the merged inner modules' declarations; this fixes the merge so the publicbuildInfocontract is correct for plugins.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes —
test/configCases/concatenate-modules/top-level-declarations/(regression test for the merge) andtest/configCases/concatenate-modules/top-level-declarations-library-conflict/(end-to-end coverage of the library name conflict bailout, previously untested).Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Claude Code (AI) was used to investigate the bug, implement the fix, and write the tests, directed and reviewed by the requester.
Generated by Claude Code