fix: lazy barrel for import with side effects#21291
Conversation
…rt' into fix-lazy-barrel-side-effects
🦋 Changeset detectedLatest commit: 5728ce3 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 (5728ce3). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@5728ce3
yarn add -D webpack@https://pkg.pr.new/webpack@5728ce3
pnpm add -D webpack@https://pkg.pr.new/webpack@5728ce3 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21291 +/- ##
==========================================
+ Coverage 92.86% 92.87% +0.01%
==========================================
Files 594 594
Lines 64980 64996 +16
Branches 18155 18164 +9
==========================================
+ Hits 60345 60368 +23
+ Misses 4635 4628 -7
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}' |
381.2 KB | 1,197.1 KB | -68.15% |
| ❌ | Memory | benchmark "wasm-modules-sync", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
131.8 KB | 360.3 KB | -63.42% |
| ❌ | Memory | benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
247 KB | 319.9 KB | -22.79% |
| ⚡ | Memory | benchmark "many-modules-esm", scenario '{"name":"mode-development","mode":"development"}' |
1.9 MB | 1.1 MB | +68.88% |
| ⚡ | Memory | benchmark "many-chunks-esm", scenario '{"name":"mode-production","mode":"production"}' |
11.4 MB | 7.7 MB | +48.75% |
| ⚡ | Memory | benchmark "wasm-modules-async", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
250.2 KB | 197.4 KB | +26.75% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix-lazy-barrel-side-effects (5728ce3) with main (54fa902)
c805fe8 to
56e9bc5
Compare
56e9bc5 to
5728ce3
Compare
Types CoverageCoverage after merging fix-lazy-barrel-side-effects into main will be
Coverage Report |
Summary
What kind of change does this PR introduce?
Fixes #21288.
The lazy-barrel optimization defers building unused barrel re-export targets. But a barrel re-export (
export { x } from "./mod") and a bare side-effect import (import "./x.css") both produce aHarmonyImportSideEffectDependencywith the samegetLazyUntil() === LAZY_UNTIL_REQUEST.By the time
LazyBarrel.classifyruns after the build, the two are indistinguishable, so the classifier deferred every import dependency — including orphan side-effect imports that no re-export requests, which then never build. This PR moves the deferral decision to parse time, we onlysetLazy(true)for there-exportparser hook and it's gated on the importing module being side-effect-free; theimportparser hook leaves the dependency eager.Did you add tests for your changes?
Existing
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?
No
Use of AI
Parital