test: emit async CSS chunk for a used lazy re-export (#21306)#21310
Conversation
A side-effect-free barrel that re-exports a component importing CSS dropped the component's stylesheet from its async chunk when only that export was requested by name. The fix landed in #21291; add explicit coverage for the async CSS-chunk emission case the existing test does not exercise.
|
|
This PR is packaged and the instant preview is available (086b229). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@086b229
yarn add -D webpack@https://pkg.pr.new/webpack@086b229
pnpm add -D webpack@https://pkg.pr.new/webpack@086b229 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21310 +/- ##
==========================================
- Coverage 92.87% 92.86% -0.01%
==========================================
Files 594 594
Lines 65210 65210
Branches 18143 18143
==========================================
- Hits 60563 60559 -4
- Misses 4647 4651 +4
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:
|
A cached compile restores modules without firing buildModule, so asserting the requested re-export was built failed under ConfigCacheTestCases. Keep the cache-safe checks: the unused sibling stays deferred and the used component's CSS is emitted while the unused one's is not.
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}' |
383 KB | 1,204.3 KB | -68.2% |
| ❌ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
246.7 KB | 319.5 KB | -22.78% |
| ⚡ | Memory | benchmark "wasm-modules-async", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
361.2 KB | 189.6 KB | +90.52% |
| ⚡ | Memory | benchmark "many-chunks-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
10 MB | 7.3 MB | +36.29% |
| ⚡ | Memory | benchmark "many-modules-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
10.3 MB | 7.6 MB | +35.2% |
| ⚡ | Memory | benchmark "json-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
365.6 KB | 281.7 KB | +29.75% |
| ⚡ | Memory | benchmark "context-esm", scenario '{"name":"mode-production","mode":"production"}' |
8.7 MB | 7.1 MB | +22.73% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing test/lazy-barrel-async-css (22e2bc1) with main (6844305)
Types CoverageCoverage after merging test/lazy-barrel-async-css into main will be
Coverage Report |
Summary
Regression coverage for #21306: a side-effect-free barrel (
sideEffects: ["**/*.css"]) that re-exports a component importing CSS dropped that component's stylesheet from its async chunk when only that export was requested by name. The behaviour was fixed by the lazy-barrel change in #21291; the existinglazy-barrel/side-effect-importtest only covers a sync/initial CSS chunk, so this adds explicit coverage for the async CSS-chunk emission case. The test fails before #21291 (no.cssasset is emitted) and passes on currentmain. Closes #21306.What kind of change does this PR introduce?
test
Did you add tests for your changes?
Yes —
test/configCases/lazy-barrel/side-effect-css-async/(asserts the used re-export's CSS is emitted into the async chunk, the unused sibling's CSS is not, and the unused module stays deferred).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) was used to investigate the regression, build the minimal reproduction, and author the test case; all changes were reviewed before submitting.
Generated by Claude Code