GeezerVison is showing github.com — fix: inherit sideEffects past type-only nested package.json by xiaoxiaojx · Pull Request #21686 · webpack/webpack
Conversation
xiaoxiaojx
commented
Aug 11, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Nested type-only package.json files (e.g. {"type":"module"}) were shadowing a parent sideEffects flag, so unused modules from packages like entities stayed in the graph. Inherit the ancestor flag within compiler.context, rebase globs to the declaring package root, and stop at named packages / node_modules directory boundaries.
What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes — test/configCases/side-effects/nested-package-json-sideEffects and nested-package-json-sideEffects-outside-context.
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 — AI assisted implementation, tests, and PR drafting; changes were reviewed and verified locally.
Made with Cursor
Summary by CodeRabbit
-
Bug Fixes
- Improved handling of inherited
sideEffects settings in nested packages.
- More accurately removes unused modules while retaining modules that may have side effects.
- Preserved deferred-import re-export modules during optimization.
- Improved behavior across package boundaries and configured build contexts.
- Improved reliability when resolving package metadata from nested directories.
-
Chores
- Added a patch release entry documenting the updated side-effects behavior.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Aug 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Note
.coderabbit.yaml has unrecognized properties
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "tools"
⚙️ Configuration instructions
- Please see the configuration documentation for more information.
- You can also validate your configuration using the online YAML validator.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f02df7db-3228-4733-85fd-69e97ac6b91e
📥 Commits
Reviewing files that changed from the base of the PR and between bf21f16 and 9bc99bc.
⛔ Files ignored due to path filters (35)
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/node_modules/outside-context-sef/esm/heavy.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/node_modules/outside-context-sef/esm/index.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/node_modules/outside-context-sef/esm/light.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/node_modules/outside-context-sef/esm/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/node_modules/outside-context-sef/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/declared-nested-sef/esm/heavy.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/declared-nested-sef/esm/index.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/declared-nested-sef/esm/light.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/declared-nested-sef/esm/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/declared-nested-sef/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/explicit-nested-true/esm/heavy.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/explicit-nested-true/esm/index.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/explicit-nested-true/esm/light.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/explicit-nested-true/esm/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/explicit-nested-true/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-array-sef/esm/heavy.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-array-sef/esm/index.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-array-sef/esm/light.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-array-sef/esm/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-array-sef/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-string-sef/esm/heavy.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-string-sef/esm/index.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-string-sef/esm/light.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-string-sef/esm/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/glob-string-sef/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/shadowed-sef/esm/heavy.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/shadowed-sef/esm/index.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/shadowed-sef/esm/light.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/shadowed-sef/esm/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/shadowed-sef/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/stop-at-node-modules/esm/heavy.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/stop-at-node-modules/esm/index.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/stop-at-node-modules/esm/light.js is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/stop-at-node-modules/esm/package.json is excluded by !**/node_modules/**
test/configCases/side-effects/nested-package-json-sideEffects/node_modules/stop-at-node-modules/package.json is excluded by !**/node_modules/**
📒 Files selected for processing (18)
.changeset/047-inherit-nested-sideEffects.md
lib/dependencies/ImportMetaGlobHelpers.js
lib/optimize/SideEffectsFlagPlugin.js
lib/util/identifier.js
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/package.json
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/heavy.js
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/index.js
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/light.js
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/package.json
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/index.js
test/configCases/side-effects/nested-package-json-sideEffects-outside-context/webpack.config.js
test/configCases/side-effects/nested-package-json-sideEffects/index.js
test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/heavy.js
test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/index.js
test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/light.js
test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/package.json
test/configCases/side-effects/nested-package-json-sideEffects/package.json
test/configCases/side-effects/nested-package-json-sideEffects/webpack.config.js
🚧 Files skipped from review as they are similar to previous changes (18)
- test/configCases/side-effects/nested-package-json-sideEffects/webpack.config.js
- test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/index.js
- test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/package.json
- test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/package.json
- .changeset/047-inherit-nested-sideEffects.md
- test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/light.js
- test/configCases/side-effects/nested-package-json-sideEffects/package.json
- lib/util/identifier.js
- lib/dependencies/ImportMetaGlobHelpers.js
- test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/index.js
- test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/index.js
- test/configCases/side-effects/nested-package-json-sideEffects-outside-context/package.json
- test/configCases/side-effects/nested-package-json-sideEffects/local-app-nested/esm/heavy.js
- test/configCases/side-effects/nested-package-json-sideEffects-outside-context/webpack.config.js
- test/configCases/side-effects/nested-package-json-sideEffects/index.js
- test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/light.js
- test/configCases/side-effects/nested-package-json-sideEffects-outside-context/src/climb-nested/esm/heavy.js
- lib/optimize/SideEffectsFlagPlugin.js
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough
Changes
SideEffectsFlagPlugin now inherits sideEffects metadata from ancestor package.json files within the compiler context. It caches resolved metadata per module creation and applies it during module creation. New configuration cases cover nested packages and context boundaries.
Suggested reviewers: hai-x
Side-effects metadata inheritance
| Layer / File(s) |
Summary |
Package metadata resolution lib/optimize/SideEffectsFlagPlugin.js, lib/util/identifier.js, lib/dependencies/ImportMetaGlobHelpers.js |
The plugin resolves inherited sideEffects values while traversing ancestor package metadata. Shared request normalization is exported and reused. |
Module creation integration lib/optimize/SideEffectsFlagPlugin.js |
afterResolve caches resolved metadata, and module creation applies the cached value. |
Nested package regression coverage test/configCases/side-effects/nested-package-json-sideEffects/*, test/configCases/side-effects/nested-package-json-sideEffects-outside-context/*, .changeset/047-inherit-nested-sideEffects.md |
Configuration cases verify nested declarations, glob rebasing, local package metadata, node_modules boundaries, and paths outside the compiler context. The changeset records the patch release. |
Merge Risk: ⚪ Minimal · up to 9bc99
This change adjusts inheritance of package side-effect metadata and adds focused regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title uses the valid fix: type and accurately describes inherited sideEffects behavior for nested package.json files. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
Warning Your free Security trial is over. An organization admin can activate billing to continue.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR is packaged and the instant preview is available (7b7f6dd).
Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@7b7f6dd
yarn add -D webpack@https://pkg.pr.new/webpack@7b7f6dd
pnpm add -D webpack@https://pkg.pr.new/webpack@7b7f6dd
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Aug 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
❌ Patch coverage is 89.58333% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.85%. Comparing base (bc3e930) to head (9bc99bc).
⚠️ Report is 4 commits behind head on main.
❌ Your patch check has failed because the patch coverage (89.58%) 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 #21686 +/- ##
========================================
Coverage 94.84% 94.85%
========================================
Files 677 683 +6
Lines 87465 87788 +323
Branches 26258 26334 +76
========================================
+ Hits 82956 83270 +314
- Misses 4509 4518 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Generated code size
Comparing 9bc99bc merged into bf21f16 against bf21f16. Merging this pull request adds 2 new asset(s).
|
Changed |
New |
Deleted |
Unchanged |
Gzip change |
Raw change |
Gzip new/gone |
Raw new/gone |
| Cases |
0 |
2 |
0 |
1813 |
— |
— |
+3.36 KiB |
+12.74 KiB |
| Assets |
0 |
2 |
0 |
6829 |
— |
— |
+3.36 KiB |
+12.74 KiB |
| Runtimes |
0 |
2 |
0 |
2131 |
— |
— |
— |
— |
Gzip change decides — it is what a user downloads, and a re-encoding can cut raw bytes while costing wire bytes. Raw change is the tiebreak: it is what the generator wrote, so it is what has to be decompressed and parsed. Both are over assets both runs emit; bytes an added or deleted case brings with it are counted apart, under new/gone. Brotli and zstd are per asset in the table below.
No asset that both runs emit changed size — everything below is new or deleted.
2 asset(s) this pull request adds
|
Asset |
Raw |
Gzip (9) |
Brotli (11) |
Zstd (19) |
| ➕ |
side-effects/nested-package-json-sideEffects bundle0.js |
8.03 KiB |
1.89 KiB |
1.63 KiB |
1.85 KiB |
| ➕ |
side-effects/nested-package-json-sideEffects-outside-context bundle0.js |
4.71 KiB |
1.47 KiB |
1.29 KiB |
1.47 KiB |
No runtime that both runs build changed which runtime modules it carries.
2 runtime(s) this pull request adds or no longer builds
|
Runtime |
Modules |
| ➕ |
side-effects/nested-package-json-sideEffects main |
2 |
| ➕ |
side-effects/nested-package-json-sideEffects-outside-context main |
2 |
Built test/configCases with the defaults a user gets: 1815 case(s), 6831 asset(s), 49 emitted nothing.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codspeed
Bot
commented
Aug 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will regress 2 benchmarks
⚠️ Different runtime environments detected
Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.
Open the report in CodSpeed to investigate
⚡ 4 improved benchmarks
❌ 2 regressed benchmarks
✅ 322 untouched benchmarks
Performance Changes
|
Mode |
Benchmark |
BASE |
HEAD |
Efficiency |
| ❌ |
Memory |
benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
474 KB |
952 KB |
-50.21% |
| ❌ |
Memory |
benchmark "asset-modules-resource", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
658 KB |
844.6 KB |
-22.09% |
| ⚡ |
Memory |
benchmark "many-modules-esm", scenario '{"name":"mode-development","mode":"development"}' |
2,301 KB |
910.8 KB |
×2.5 |
| ⚡ |
Memory |
benchmark "wasm-modules-sync", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
302.6 KB |
212.8 KB |
+42.23% |
| ⚡ |
Memory |
benchmark "devtool-eval", scenario '{"name":"mode-production","mode":"production"}' |
14.8 MB |
11.4 MB |
+29.51% |
| ⚡ |
Memory |
unit benchmark "html-printer-document-unit", walk (fragment, tr context) |
25.2 KB |
19.7 KB |
+27.47% |
Tip Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix/nested-package-json-sideEffects (9bc99bc) with main (13c2f94)1
Footnotes
-
No successful run was found on main (bf21f16) during the generation of this report, so 13c2f94 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
lib/optimize/SideEffectsFlagPlugin.js (2)
278-286: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win
Read compiler.inputFileSystem inside the hook, not at apply time.
compiler.inputFileSystem is reassigned during the compiler lifecycle, for example by NodeEnvironmentPlugin on watch invalidation and on close. The captured reference can become stale, and the !inputFileSystem guard then silently disables the whole resolution path for the rest of the run.
♻️ Proposed change
- const inputFileSystem = compiler.inputFileSystem;
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
const moduleGraph = compilation.moduleGraph;
normalModuleFactory.hooks.afterResolve.tapAsync(
PLUGIN_NAME,
(resolveData, callback) => {
+ const inputFileSystem = compiler.inputFileSystem;
if (!inputFileSystem) return callback();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lib/optimize/SideEffectsFlagPlugin.js` around lines 278 - 286, Update the
compilation hook around `normalModuleFactory.hooks.afterResolve` to read
`compiler.inputFileSystem` when the `afterResolve` callback executes, rather
than capturing it before `compiler.hooks.compilation.tap`. Apply the existing
missing-filesystem guard to this freshly read value so resolution continues
using the current compiler filesystem after lifecycle reassignment.
170-226: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
Memoize the ancestor walk per directory.
afterResolve runs for every resolved module. Every module inside a node_modules package that declares no sideEffects repeats the full ancestor walk, including one readJson per ancestor directory. The result depends only on descriptionFileRoot, not on relativePath, so the walk can be cached per directory and reused.
Store the resolved owning package root plus its sideEffects value in a Map keyed by descriptionFileRoot (scoped to compiler.root, like globToRegexpCache), then compute relativePath per module from that cached root. This also removes repeated work when the input filesystem is not a caching one.
As per coding guidelines: "Evaluate time and memory costs of changes, especially on hot paths."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lib/optimize/SideEffectsFlagPlugin.js` around lines 170 - 226, Memoize the
ancestor walk in the afterResolve path using a Map scoped to compiler.root,
keyed by descriptionFileRoot, alongside globToRegexpCache. Cache both the owning
package root and its sideEffects value, including no-result cases, then compute
each module’s relativePath from the cached root instead of repeating readJson
traversal. Preserve existing boundary and error behavior while avoiding
unbounded per-module cache growth.
Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/optimize/SideEffectsFlagPlugin.js`:
- Around line 197-208: Update the ancestor package.json error handling in the
readJson callback to continue walking via next() for missing or unreadable paths
(ENOENT, ENOTDIR, EISDIR, ENAMETOOLONG) and JSON parse SyntaxError, while
preserving callback(err) for other I/O failures. Keep the existing
parent-directory traversal behavior unchanged.
---
Nitpick comments:
In `@lib/optimize/SideEffectsFlagPlugin.js`:
- Around line 278-286: Update the compilation hook around
`normalModuleFactory.hooks.afterResolve` to read `compiler.inputFileSystem` when
the `afterResolve` callback executes, rather than capturing it before
`compiler.hooks.compilation.tap`. Apply the existing missing-filesystem guard to
this freshly read value so resolution continues using the current compiler
filesystem after lifecycle reassignment.
- Around line 170-226: Memoize the ancestor walk in the afterResolve path using
a Map scoped to compiler.root, keyed by descriptionFileRoot, alongside
globToRegexpCache. Cache both the owning package root and its sideEffects value,
including no-result cases, then compute each module’s relativePath from the
cached root instead of repeating readJson traversal. Preserve existing boundary
and error behavior while avoiding unbounded per-module cache growth.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f1d2eb66-2173-428c-83f0-e3ca40f61717
📥 Commits
Reviewing files that changed from the base of the PR and between 475a3e0 and 4ba77ec.
📒 Files selected for processing (3)
.changeset/047-inherit-nested-sideEffects.md
lib/optimize/SideEffectsFlagPlugin.js
test/configCases/side-effects/nested-package-json-sideEffects/index.js
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
webpack/schema-utils (auto-detected)
webpack/tapable (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (2)
- .changeset/047-inherit-nested-sideEffects.md
- test/configCases/side-effects/nested-package-json-sideEffects/index.js
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is interesting, initially we don’t inherit this specially, yes this idea was too, but as I remember we declined it in testing, let’s take a look how other bundlers do it
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
xiaoxiaojx reacted with heart emoji
|
@alexander-akait Thanks. I checked other bundlers: Rspack/esbuild/Parcel/Rolldown all use the nearest enclosing package.json only (Rolldown explicitly declined walking up for a sideEffects field — rolldown#3336). I noticed this gap while reviewing production bundle output with AI: root sideEffects: false often gets shadowed by a nested type-only package.json under node_modules, which looks like either a packaging omission or an expectation that bundlers would inherit. This PR treats that as a reasonable optimization (scoped to node_modules, with context / named-package stops so app-local nests still shadow). If there was a clearer historical reason not to support this, we’re happy to reconsider.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
hai-x
commented
Aug 12, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Measured the win, across majors:
import { decodeXML } from "entities" with mode: "production" + minimize: false
| version |
layout |
before |
after |
ratio |
note |
| 4.5.0 |
lib/esm/package.json stub |
107,803 |
70,082 |
−35% |
|
| 6.0.1 |
dist/esm + dist/commonjs stubs |
33,649 |
22,498 |
−33% |
|
| 8.0.0 |
ESM-only, no nested manifest |
25,907 |
25,907 |
no change |
It ships ESM-only, no dist/esm dirs |
|
xiaoxiaojx and alexander-akait reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Types CoverageCoverage after merging fix/nested-package-json-sideEffects into main will be
Coverage Report| File | Stmts | Branches | Funcs | Lines | Uncovered Lines |
|---|
| bin | | webpack.js | 98.82% | 100% | 100% | 98.82% | 103 | | examples | | build-common.js | 100% | 100% | 100% | 100% | | | buildAll.js | 100% | 100% | 100% | 100% | | | examples.js | 100% | 100% | 100% | 100% | | | template-common.js | 98.21% | 100% | 100% | 98.21% | 72 | | examples/custom-javascript-parser | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/custom-javascript-parser/internals | | acorn-parse.js | 100% | 100% | 100% | 100% | | | meriyah-parse.js | 100% | 100% | 100% | 100% | | | oxc-parse.js | 100% | 100% | 100% | 100% | | | examples/markdown | | webpack.config.mjs | 100% | 100% | 100% | 100% | | | examples/module-federation | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/reexport-components | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/typescript | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/typescript-non-erasable | | test.filter.js | 50% | 100% | 100% | 50% | 5 | | examples/virtual-modules | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-bindgen-esm | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-complex | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-emscripten | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple-source-phase | | test.filter.js | 100% | 100% | 100% | 100% | | | lib | | APIPlugin.js | 100% | 100% | 100% | 100% | | | AsyncDependenciesBlock.js | 100% | 100% | 100% | 100% | | | AutomaticPrefetchPlugin.js | 100% | 100% | 100% | 100% | | | BannerPlugin.js | 100% | 100% | 100% | 100% | | | Cache.js | 98.21% | 100% | 100% | 98.21% | 101 | | CacheFacade.js | 100% | 100% | 100% | 100% | | | Chunk.js | 99.72% | 100% | 100% | 99.72% | 42 | | ChunkGraph.js | 100% | 100% | 100% | 100% | | | ChunkGroup.js | 100% | 100% | 100% | 100% | | | ChunkTemplate.js | 100% | 100% | 100% | 100% | | | CircularModulesPlugin.js | 99.35% | 100% | 100% | 99.35% | 244 | | CleanPlugin.js | 99.12% | 100% | 100% | 99.12% | 212, 232 | | CodeGenerationResults.js | 100% | 100% | 100% | 100% | | | CompatibilityPlugin.js | 100% | 100% | 100% | 100% | | | Compilation.js | 98.49% | 100% | 100% | 98.49% | 1683, 2002, 2009, 2017, 2039, 2042, 2981, 3460–3461, 3493, 4202, 4232, 4285–4286, 4290, 4295, 4311–4312, 4326–4327, 4332–4333, 4855, 4881, 5691, 5723, 5740, 5758, 5774, 5789, 5814–5815, 5817, 6152, 6157, 6163, 6166, 6173, 6185, 6187, 6191, 6209, 6224, 6258, 6314, 6338, 6454, 807–808 | | Compiler.js | 99.56% | 100% | 100% | 99.56% | 1174–1175, 1183 | | ConcatenationScope.js | 99.12% | 100% | 100% | 99.12% | 303 | | ConditionalInitFragment.js | 100% | 100% | 100% | 100% | | | ConstPlugin.js | 100% | 100% | 100% | 100% | | | ContextExclusionPlugin.js | 100% | 100% | 100% | 100% | | | ContextModule.js | 99.88% | 100% | 100% | 99.88% | 1554 | | ContextModuleFactory.js | 97.29% | 100% | 100% | 97.29% | 289, 465, 486, 491, 532, 543, 545, 549, 558–559 | | ContextReplacementPlugin.js | 100% | 100% | 100% | 100% | | | DefinePlugin.js | 99.12% | 100% | 100% | 99.12% | 1109, 182–183, 199, 218, 292 | | DependenciesBlock.js | 100% | 100% | 100% | 100% | | | Dependency.js | 98.54% | 100% | 100% | 98.54% | 498, 545 | | DependencyTemplate.js | 100% | 100% | 100% | 100% | | | DependencyTemplates.js | 100% | 100% | 100% | 100% | | | DotenvPlugin.js | 98.41% | 100% | 100% | 98.41% | 415, 428–429 | | DynamicEntryPlugin.js | 100% | 100% | 100% | 100% | | | EntryOptionPlugin.js | 100% | 100% | 100% | 100% | | | EntryPlugin.js | 100% | 100% | 100% | 100% | | | Entrypoint.js | 100% | 100% | 100% | 100% | | | EnvironmentPlugin.js | 97.14% | 100% | 100% | 97.14% | 49 | | ErrorHelpers.js | 100% | 100% | 100% | 100% | | | EvalDevToolModulePlugin.js | 100% | 100% | 100% | 100% | | | EvalSourceMapDevToolPlugin.js | 100% | 100% | 100% | 100% | | | ExportsInfo.js | 100% | 100% | 100% | 100% | | | ExportsInfoApiPlugin.js | 100% | 100% | 100% | 100% | | | ExternalModule.js | 98.71% | 100% | 100% | 98.71% | 1270, 1273, 534–538, 540, 686 | | ExternalModuleFactoryPlugin.js | 100% | 100% | 100% | 100% | | | ExternalsPlugin.js | 100% | 100% | 100% | 100% | | | FileSystemInfo.js | 99.53% | 100% | 100% | 99.53% | 187, 2455–2456, 2459, 2470, 2481, 2492, 285, 3929, 3944, 3968 | | FlagAllModulesAsUsedPlugin.js | 100% | 100% | 100% | 100% | | | FlagDependencyExportsPlugin.js | 98.36% | 100% | 100% | 98.36% | 505, 514, 517, 521, 533 | | FlagDependencyUsagePlugin.js | 100% | 100% | 100% | 100% | | | FlagEntryExportAsUsedPlugin.js | 100% | 100% | 100% | 100% | | | Generator.js | 100% | 100% | 100% | 100% | | | HotModuleReplacementPlugin.js | 100% | 100% | 100% | 100% | | | HotUpdateChunk.js | 100% | 100% | 100% | 100% | | | IgnorePlugin.js | 100% | 100% | 100% | 100% | | | IgnoreWarningsPlugin.js | 100% | 100% | 100% | 100% | | | InitFragment.js | 100% | 100% | 100% | 100% | | | JavascriptMetaInfoPlugin.js | 100% | 100% | 100% | 100% | | | LazyBarrel.js | 100% | 100% | 100% | 100% | | | LibraryTemplatePlugin.js | 100% | 100% | 100% | 100% | | | LoaderOptionsPlugin.js | 100% | 100% | 100% | 100% | | | LoaderTargetPlugin.js | 100% | 100% | 100% | 100% | | | MainTemplate.js | 100% | 100% | 100% | 100% | | | ManifestPlugin.js | 100% | 100% | 100% | 100% | | | Module.js | 98.51% | 100% | 100% | 98.51% | 1314, 1319, 1379, 1393, 1455, 1464 | | ModuleFactory.js | 100% | 100% | 100% | 100% | | | ModuleFilenameHelpers.js | 98.90% | 100% | 100% | 98.90% | 111, 113 | | ModuleGraph.js | 99.78% | 100% | 100% | 99.78% | 1180 | | ModuleGraphConnection.js | 100% | 100% | 100% | 100% | | | ModuleInfoHeaderPlugin.js | 100% | 100% | 100% | 100% | | | ModuleNotFoundError.js | 100% | 100% | 100% | 100% | | | ModuleProfile.js | 100% | 100% | 100% | 100% | | | ModuleSourceTypeConstants.js | 100% | 100% | 100% | 100% | | | ModuleTemplate.js | 100% | 100% | 100% | 100% | | | ModuleTypeConstants.js | 100% | 100% | 100% | 100% | | | MultiCompiler.js | 99.72% | 100% | 100% | 99.72% | 729 | | MultiStats.js | 100% | 100% | 100% | 100% | | | MultiWatching.js | 100% | 100% | 100% | 100% | | | NoEmitOnErrorsPlugin.js | 100% | 100% | 100% | 100% | | | NodeStuffPlugin.js | 100% | 100% | 100% | 100% | | | NormalModule.js | 97.99% | 100% | 100% | 97.99% | 1045, 1048, 1065, 1082, 1330, 1364, 1380, 1835, 2132, 2137–2147, 29 | | NormalModuleFactory.js | 99.01% | 100% | 100% | 99.01% | 1341, 1790, 1801, 1811, 1862–1864, 1871, 732, 744 | | NormalModuleReplacementPlugin.js | 100% | 100% | 100% | 100% | | | NullFactory.js | 100% | 100% | 100% | 100% | | | OptimizationStages.js | 100% | 100% | 100% | 100% | | | OptionsApply.js | 100% | 100% | 100% | 100% | | | Parser.js | 100% | 100% | 100% | 100% | | | PlatformPlugin.js | 100% | 100% | 100% | 100% | | | PrefetchPlugin.js | 100% | 100% | 100% | 100% | | | ProgressPlugin.js | 99.80% | 100% | 100% | 99.80% | 694 | | ProvidePlugin.js | 100% | 100% | 100% | 100% | | | RawModule.js | 100% | 100% | 100% | 100% | | | RecordIdsPlugin.js | 100% | 100% | 100% | 100% | | | RequestShortener.js | 100% | 100% | 100% | 100% | | | ResolverFactory.js | 100% | 100% | 100% | 100% | | | RuntimeGlobals.js | 100% | 100% | 100% | 100% | | | RuntimeModule.js | 100% | 100% | 100% | 100% | | | RuntimePlugin.js | 95.71% | 100% | 100% | 95.71% | 312, 368, 377, 380, 404, 422, 443–444, 467, 487–488, 524–525, 548, 561–562, 634, 647, 668, 687 | | RuntimeTemplate.js | 99.87% | 100% | 100% | 99.87% | 251, 3086 | | SelfModuleFactory.js | 100% | 100% | 100% | 100% | | | SingleEntryPlugin.js | 100% | 100% | 100% | 100% | | | SourceMapDevToolModuleOptionsPlugin.js | 100% | 100% | 100% | 100% | | | SourceMapDevToolPlugin.js | 98.63% | 100% | 100% | 98.63% | 229, 233, 235, 429, 440, 899 | | Stats.js | 100% | 100% | 100% | 100% | | | Template.js | 100% | 100% | 100% | 100% | | | TemplatedPathPlugin.js | 99.48% | 100% | 100% | 99.48% | 366–367 | | UseStrictPlugin.js | 100% | 100% | 100% | 100% | | | WarnCaseSensitiveModulesPlugin.js | 100% | 100% | 100% | 100% | | | WarnDeprecatedOptionPlugin.js | 100% | 100% | 100% | 100% | | | WarnNoModeSetPlugin.js | 100% | 100% | 100% | 100% | | | WatchIgnorePlugin.js | 100% | 100% | 100% | 100% | | | Watching.js | 100% | 100% | 100% | 100% | | | WebpackError.js | 100% | 100% | 100% | 100% | | | WebpackIsIncludedPlugin.js | 100% | 100% | 100% | 100% | | | WebpackOptionsApply.js | 100% | 100% | 100% | 100% | | | WebpackOptionsDefaulter.js | 100% | 100% | 100% | 100% | | | buildChunkGraph.js | 99.87% | 100% | 100% | 99.87% | 375 | | cli.js | 98.63% | 100% | 100% | 98.63% | 10, 117, 547, 579, 629, 903 | | index.js | 99.73% | 100% | 100% | 99.73% | 184 | | validateSchema.js | 94.67% | 100% | 100% | 94.67% | 100, 87, 89, 98 | | webpack.js | 97.12% | 100% | 100% | 97.12% | 10, 274, 296, 298 | | lib/asset | | AssetBytesGenerator.js | 100% | 100% | 100% | 100% | | | AssetBytesParser.js | 100% | 100% | 100% | 100% | | | AssetGenerator.js | 100% | 100% | 100% | 100% | | | AssetModule.js | 100% | 100% | 100% | 100% | | | AssetModulesPlugin.js | 98.15% | 100% | 100% | 98.15% | 338, 362, 365, 495, 57, 62 | | AssetParser.js | 100% | 100% | 100% | 100% | | | AssetSourceGenerator.js | 100% | 100% | 100% | 100% | | | AssetSourceParser.js | 100% | 100% | 100% | 100% | | | RawDataUrlModule.js | 100% | 100% | 100% | 100% | | | WebManifestGenerator.js | 100% | 100% | 100% | 100% | | | WebManifestParser.js | 100% | 100% | 100% | 100% | | | lib/async-modules | | AsyncModuleHelpers.js | 100% | 100% | 100% | 100% | | | AwaitDependenciesInitFragment.js | 100% | 100% | 100% | 100% | | | InferAsyncModulesPlugin.js | 100% | 100% | 100% | 100% | | | isGeneratorLowered.js | 100% | 100% | 100% | 100% | | | lib/bun | | BunTargetPlugin.js | 100% | 100% | 100% | 100% | | | lib/cache | | AddBuildDependenciesPlugin.js | 100% | 100% | 100% | 100% | | | AddManagedPathsPlugin.js | 100% | 100% | 100% | 100% | | | IdleFileCachePlugin.js | 97.92% | 100% | 100% | 97.92% | 75, 87, 95 | | MemoryCachePlugin.js | 92% | 100% | 100% | 92% | 33, 42 | | MemoryWithGcCachePlugin.js | 93.42% | 100% | 100% | 93.42% | 107, 121–122, 131, 89 | | PackFileCacheStrategy.js | 96.52% | 100% | 100% | 96.52% | 1317, 1417, 1421, 1483, 1719, 1803, 1826, 1858, 682, 701, 711–713, 715, 731–732, 737, 740, 742, 747, 752, 777, 783, 817, 823, |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alexander-akait
added a commit
that referenced
this pull request
Aug 25, 2026
Follow-up to #21686. The flag was read from the description-file root, so a
symlinked workspace package inherited for the request coming through
node_modules but not for the relative imports its own files make. Report the
ancestor package.json files the walk consults as dependencies of the resolve,
and let an unreadable one decline the inheritance rather than fail the module.
alexander-akait
added a commit
that referenced
this pull request
Aug 25, 2026
…1826)
* fix(side-effects): read the inherited flag from the resolved file
Follow-up to #21686. The flag was read from the description-file root, so a
symlinked workspace package inherited for the request coming through
node_modules but not for the relative imports its own files make. Report the
ancestor package.json files the walk consults as dependencies of the resolve,
and let an unreadable one decline the inheritance rather than fail the module.
* fix(side-effects): stop inheriting past an unreadable ancestor manifest
A manifest that is there but cannot be read declares something unknown, so
letting an outer sideEffects: false speak for it can drop code that runs. Only
an absent one keeps the walk going. Also makes the symlink probe idempotent, so
a probe left behind by a failed cleanup no longer skips the case for good.
* test(side-effects): fail the symlink filter on anything but a missing privilege
* fix(test): keep the symlink filter on the Node 10 baseline
* test(side-effects): shorten the symlink helper annotation
Reviewers
hai-x
Awaiting requested review from hai-x
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
area: optimization
Tree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids)
area: parser
JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies)
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|