perf(ExportsInfo): resolve nested export paths without per-level slicing#21137
Conversation
Rewrite getUsedName (the "improve this" TODO), getUsed, isExportProvided, getNestedExportsInfo and getReadOnlyExportInfoRecursive as single-pass iterative walks. The recursive versions allocated a `name.slice(1)` plus spread per nesting level (O(depth^2) arrays); the iterative versions build one result array, cutting allocations and time (~4.6x faster on a deep path). Add ExportsInfo.unittest.js covering mangling, passthrough, unused exports, OnlyPropertiesUsed descent, inlined constants and runtime-specific usage.
Replace the ExportsInfo unit test with a configCase that drives the iterative path walks through a real compilation: re-export deep nested JSON, then assert isExportProvided / getUsed / canMangle at depth >= 3 via __webpack_exports_info__, deeply-nested mangled value resolution (getUsedName), and the fully-used-object branch. Runs with and without module concatenation.
🦋 Changeset detectedLatest commit: b6caa5a 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 (f2252b8). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@f2252b8
yarn add -D webpack@https://pkg.pr.new/webpack@f2252b8
pnpm add -D webpack@https://pkg.pr.new/webpack@f2252b8 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21137 +/- ##
==========================================
+ Coverage 92.33% 92.35% +0.01%
==========================================
Files 581 581
Lines 62942 63244 +302
Branches 17420 17489 +69
==========================================
+ Hits 58117 58406 +289
- Misses 4825 4838 +13
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 not alter performance
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
220.5 KB | 1,291.1 KB | -82.92% |
| ❌ | Memory | benchmark "devtool-eval", scenario '{"name":"mode-production","mode":"production"}' |
5.4 MB | 7.7 MB | -30.11% |
| ⚡ | Memory | benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
330 KB | 162.1 KB | ×2 |
| ⚡ | Memory | benchmark "context-esm", scenario '{"name":"mode-development","mode":"development"}' |
1,132.6 KB | 797.5 KB | +42.02% |
| ⚡ | Memory | benchmark "side-effects-reexport", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,187.4 KB | 878.4 KB | +35.18% |
| ⚡ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
323.4 KB | 246.3 KB | +31.3% |
| ⚡ | Memory | benchmark "many-chunks-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
9 MB | 7.4 MB | +21.02% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing claude/todos-list-exclude-webpack-8ni8r1 (b6caa5a) with main (cd45931)
Rewrite getUsedName (the "improve this" TODO), getUsed, isExportProvided,
getNestedExportsInfo and getReadOnlyExportInfoRecursive as single-pass
iterative walks. The recursive versions allocated a
name.slice(1)plusspread per nesting level (O(depth^2) arrays); the iterative versions build
one result array, cutting allocations and time (~4.6x faster on a deep path).
Add ExportsInfo.unittest.js covering mangling, passthrough, unused exports,
OnlyPropertiesUsed descent, inlined constants and runtime-specific usage.