feat: inline const for default export#21189
Conversation
🦋 Changeset detectedLatest commit: b5b947e 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21189 +/- ##
========================================
Coverage 92.80% 92.81%
========================================
Files 590 592 +2
Lines 64647 64801 +154
Branches 17993 18057 +64
========================================
+ Hits 59996 60142 +146
- Misses 4651 4659 +8
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 "side-effects-reexport", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
128.3 KB | 859.3 KB | -85.07% |
| ❌ | Memory | benchmark "css-modules", scenario '{"name":"mode-development","mode":"development"}' |
860.3 KB | 1,676.2 KB | -48.68% |
| ⚡ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,043.2 KB | 320.3 KB | ×3.3 |
| ⚡ | Memory | benchmark "css-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,150.3 KB | 411.1 KB | ×2.8 |
| ⚡ | Memory | benchmark "many-chunks-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
330.4 KB | 164 KB | ×2 |
| ⚡ | Memory | benchmark "many-modules-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
9.1 MB | 7.4 MB | +23.83% |
| ⚡ | Memory | benchmark "context-esm", scenario '{"name":"mode-production","mode":"production"}' |
9.2 MB | 7.7 MB | +20.57% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/inline-const-default-export (b5b947e) with main (efeb5ce)
|
I'm excited for this! :D (Although I suppose that Terser might already inline the default export) |
|
Let's merge #21199 first, and then come back to this. |
cdb5dd9 to
a50ad94
Compare
|
This PR is packaged and the instant preview is available (ef03f5e). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@ef03f5e
yarn add -D webpack@https://pkg.pr.new/webpack@ef03f5e
pnpm add -D webpack@https://pkg.pr.new/webpack@ef03f5e |
Types CoverageCoverage after merging feat/inline-const-default-export into main will be
Coverage Report |
Summary
What kind of change does this PR introduce?
We already inlines named const exports (
optimization.inlineExports) but explicitly skippedexport default <const>(the template carried a "For now we don't set inlined value forexport defaultexpression" note). This makes a default export inlinable when its expression is a primitive constant.Did you add tests for your changes?
Yes
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
Yes