fix: rename nested const/let __webpack_require__ declarations - #21508
Conversation
🦋 Changeset detectedLatest commit: 287b1b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (7d8d6f7). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@7d8d6f7
yarn add -D webpack@https://pkg.pr.new/webpack@7d8d6f7
pnpm add -D webpack@https://pkg.pr.new/webpack@7d8d6f7 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21508 +/- ##
==========================================
+ Coverage 93.50% 93.60% +0.09%
==========================================
Files 619 619
Lines 72956 73655 +699
Branches 21000 21244 +244
==========================================
+ Hits 68221 68944 +723
+ Misses 4735 4711 -24
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 improve performance by 24.49%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Memory | benchmark "many-modules-esm", scenario '{"name":"mode-production","mode":"production"}' |
10 MB | 7.8 MB | +28.28% |
| ⚡ | Memory | benchmark "asset-modules-resource", scenario '{"name":"mode-development","mode":"development"}' |
2.2 MB | 1.8 MB | +24.15% |
| ⚡ | Memory | benchmark "many-chunks-esm", scenario '{"name":"mode-production","mode":"production"}' |
10.2 MB | 8.4 MB | +21.13% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix-let-runtime (287b1b5) with main (4ae3518)
Summary
When a bundled webpack output declares its runtime scope with
const/let __webpack_require__(as webpack emits for an ES6 output environment) instead ofvar,CompatibilityPluginnever renamed it, because block-pre-walking defines the name beforehooks.patternruns, so the nested runtime collided with the outer one. The kind-specificvarDeclarationConst/varDeclarationLethooks now tag these bindings the same wayvardeclarations are already tagged.What kind of change does this PR introduce?
A fix.
Did you add tests for your changes?
Yes —
test/configCases/module/consume-webpack-runtime/runtime-const-require.jsplus updated expectations in that case'sindex.js.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
AI (Claude Code) was used to help locate the missing parser hooks and to draft the regression test; the fix and test were reviewed and verified by me.