Repository navigation
fix(cjs): disconnect unused side-effect-free reexport requires - #21651
Conversation
Deactivate CommonJsExportRequireDependency when a named reexport is unused and either a getter or an eager require of a side-effect-free module, while keeping whole-module assigns and missing targets alive.
|
| Name | Type |
|---|---|
| webpack | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
|
This PR is packaged and the instant preview is available (da0e809). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@da0e809
yarn add -D webpack@https://pkg.pr.new/webpack@da0e809
pnpm add -D webpack@https://pkg.pr.new/webpack@da0e809 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21651 +/- ##
=======================================
Coverage 94.26% 94.26%
=======================================
Files 628 628
Lines 80106 80178 +72
Branches 23711 23734 +23
=======================================
+ Hits 75512 75580 +68
- Misses 4594 4598 +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:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (27)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Walkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Generated code sizeComparing
8 asset(s) changed size
1 runtime(s) changed which runtime modules they carry
Built |
Merging this PR will degrade performance by 19.35%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
509.3 KB | 944.7 KB | -46.09% |
| ⚡ | Memory | benchmark "many-modules-esm", scenario '{"name":"mode-production","mode":"production"}' |
10.9 MB | 9 MB | +20.66% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix/cjs-unused-reexport-disconnect (c1d4459) with main (c63ac95)
Summary
Unused named CJS reexports (
exports.x = require(...)/ unused getters) kept the target module in the graph even when side-effect-free; deactivate those edges like evaluation-only requires, while keeping whole-module assigns and missing targets (e.g. IgnorePlugin) alive.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes —
test/configCases/cjs-tree-shaking/unused-*, updatedside-effect-free-*-unused-export-require, andtest/configCases/ignore/unused-getter-reexport.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 assisted implementation of
getConditiononCommonJsExportRequireDependency, regression fixtures, and review of edge cases (IgnorePlugin / missing connection).Made with Cursor
Summary by CodeRabbit