feat: inline const for default export#21189
Conversation
🦋 Changeset detectedLatest commit: cdb5dd9 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❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (12.50%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.
Additional details and impacted files@@ Coverage Diff @@
## main #21189 +/- ##
===========================================
- Coverage 92.70% 41.02% -51.68%
===========================================
Files 588 466 -122
Lines 64091 56072 -8019
Branches 17785 15654 -2131
===========================================
- Hits 59416 23004 -36412
- Misses 4675 33068 +28393
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 ×2.6
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Memory | benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,296.8 KB | 323.7 KB | ×4 |
| ⚡ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,048.3 KB | 319.7 KB | ×3.3 |
| ⚡ | Memory | benchmark "css-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,153.4 KB | 409.6 KB | ×2.8 |
| ⚡ | Memory | benchmark "wasm-modules-async", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
488.8 KB | 392.4 KB | +24.54% |
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 feat/inline-const-default-export (cdb5dd9) with main (877f3dc)
|
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. |
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