Skip to content

fix: explicit moduleSideEffects from a hook must take priority over the package.json#sideEffects#9688

Merged
graphite-app[bot] merged 1 commit into
mainfrom
06-09-fix_explicit_modulesideeffects_from_a_hook_must_take_priority_over_the_package.json_sideeffects_
Jun 9, 2026
Merged

fix: explicit moduleSideEffects from a hook must take priority over the package.json#sideEffects#9688
graphite-app[bot] merged 1 commit into
mainfrom
06-09-fix_explicit_modulesideeffects_from_a_hook_must_take_priority_over_the_package.json_sideeffects_

Conversation

@sapphi-red

@sapphi-red sapphi-red commented Jun 9, 2026

Copy link
Copy Markdown
Member

An explicit moduleSideEffects from a hook had lower priority than package.json#sideEffects. This was not the priority order described in the docs:

The precedence of this option is as follows (highest to lowest):

  1. transform hook's returned moduleSideEffects option
  2. load hook's returned moduleSideEffects option
  3. resolveId hook's returned moduleSideEffects option
  4. treeshake.moduleSideEffects option
  5. sideEffects field in the package.json file
  6. true (default)
    https://rolldown.rs/reference/Interface.SourceDescription#modulesideeffects

This PR will fix, vitejs/vite#22620

sapphi-red commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sapphi-red sapphi-red force-pushed the 06-09-fix_explicit_modulesideeffects_from_a_hook_must_take_priority_over_the_package.json_sideeffects_ branch from 598b05b to fe25f5e Compare June 9, 2026 10:03
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 598b05b
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a27df272064aa0008dab585
😎 Deploy Preview https://deploy-preview-9688--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes moduleSideEffects precedence so that an explicit moduleSideEffects value returned from plugin hooks (e.g. load) is not overridden by package.json#sideEffects, aligning the Rust implementation with the documented priority order and addressing the linked Vite regression scenario.

Changes:

  • Adjust side-effects normalization to optionally skip package.json#sideEffects when hook-provided moduleSideEffects is present.
  • Add a new tree-shaking fixture to verify hook moduleSideEffects: true overrides package.json#sideEffects: false.
  • Register the new fixture package in the pnpm workspace and lockfile.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pnpm-workspace.yaml Adds the new tree-shaking fixture package to the workspace.
pnpm-lock.yaml Registers the new fixture as a pnpm importer with workspace dependency wiring.
packages/rolldown/tests/fixtures/tree-shake/hook-side-effects-overrides-package-json/package.json Fixture package with sideEffects: false to reproduce the precedence issue.
packages/rolldown/tests/fixtures/tree-shake/hook-side-effects-overrides-package-json/main.js Imports the virtual module to exercise side-effect retention.
packages/rolldown/tests/fixtures/tree-shake/hook-side-effects-overrides-package-json/_config.ts Defines the repro plugin and asserts the side-effectful code remains in output.
crates/rolldown/src/ecmascript/ecma_module_view_factory.rs Updates side-effects determination logic to ensure hook-provided values take priority over package.json.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread crates/rolldown/src/ecmascript/ecma_module_view_factory.rs
@sapphi-red sapphi-red requested review from IWANABETHATGUY and hyf0 June 9, 2026 10:16
@codspeed-hq

codspeed-hq Bot commented Jun 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing 06-09-fix_explicit_modulesideeffects_from_a_hook_must_take_priority_over_the_package.json_sideeffects_ (fe25f5e) with main (924620a)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 3b0b5ad
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a281b5fd700de0008c1988b

@graphite-app

graphite-app Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Merge activity

… the `package.json#sideEffects` (#9688)

An explicit `moduleSideEffects` from a hook had lower priority than `package.json#sideEffects`. This was not the priority order described in the docs:

> The precedence of this option is as follows (highest to lowest):
> 1. [`transform`](https://rolldown.rs/reference/Interface.Plugin#transform) hook's returned moduleSideEffects option
> 1. [`load`](https://rolldown.rs/reference/Interface.Plugin#load) hook's returned moduleSideEffects option
> 1. [`resolveId`](https://rolldown.rs/reference/Interface.Plugin#resolveid) hook's returned moduleSideEffects option
> 1. [`treeshake.moduleSideEffects`](https://rolldown.rs/reference/TypeAlias.TreeshakingOptions#modulesideeffects) option
> 1. `sideEffects` field in the `package.json` file
> 1. true (default)
> https://rolldown.rs/reference/Interface.SourceDescription#modulesideeffects

This PR will fix, vitejs/vite#22620
@graphite-app graphite-app Bot force-pushed the 06-09-fix_explicit_modulesideeffects_from_a_hook_must_take_priority_over_the_package.json_sideeffects_ branch from fe25f5e to 3b0b5ad Compare June 9, 2026 13:55
@graphite-app graphite-app Bot merged commit 3b0b5ad into main Jun 9, 2026
34 checks passed
@graphite-app graphite-app Bot deleted the 06-09-fix_explicit_modulesideeffects_from_a_hook_must_take_priority_over_the_package.json_sideeffects_ branch June 9, 2026 14:02
@shulaoda shulaoda mentioned this pull request Jun 11, 2026
@rolldown-guard rolldown-guard Bot mentioned this pull request Jun 11, 2026
shulaoda pushed a commit that referenced this pull request Jun 11, 2026
## [1.1.1] - 2026-06-11

### 🚀 Features

- ecmascript_utils: introduce AstFactory for AST construction (#9682) by @hyf0
- drop no-op init calls for empty wrapped-ESM modules (#9678) by @IWANABETHATGUY

### 🐛 Bug Fixes

- resolver: honor package.json#type for .jsx/.tsx extensions (#9690) (#9699) by @IWANABETHATGUY
- hmr: report the full-reload reason for the invalidate-loop case (#9708) by @hyf0
- explicit `moduleSideEffects` from a hook must take priority over the `package.json#sideEffects` (#9688) by @sapphi-red
- keep the `rolldown-runtime` name for the standalone runtime chunk (#9685) by @shulaoda
- lazy-barrel: request all exports for entry barrels on first encounter (#9672) by @shulaoda
- finalizer: skip init_*() for tree-shaken wrapped ESM owners (#9669) by @IWANABETHATGUY
- order `chunk.imports` by execution order (#9654) by @chuganzy
- vite-resolve: preserve slash separators for Sass partial exports (#9546) by @cjc0013
- cross-chunk CJS wrapper shadowed by author-local binding (#9648) by @IWANABETHATGUY

### 🚜 Refactor

- precompute wrapped-ESM init metadata in generate stage (#9712) by @IWANABETHATGUY
- ecmascript_utils: fold construction ext traits onto AstFactory and delete AstSnippet (#9702) by @hyf0
- finalizer: finish ScopeHoistingFinalizer migration to AstFactory (#9701) by @hyf0
- finalizer: migrate module_finalizers/mod.rs to AstFactory (#9700) by @hyf0
- hmr: migrate hmr finalizer to AstFactory (#9695) by @hyf0
- plugin: migrate vite_build_import_analysis to AstFactory (#9693) by @hyf0
- scanner: migrate tweak_ast_for_scanning to AstFactory (#9683) by @hyf0
- always split runtime module first (#9419) by @IWANABETHATGUY

### 📚 Documentation

- tsconfig: correct auto-discovery resolution to match TypeScript (#9714) by @shulaoda
- design: plan to unify all internal AST construction (#9673) by @hyf0
- tsconfig: align reference resolution docs with TypeScript behavior (#9641) by @shulaoda

### ⚡ Performance

- avoid per-module join Strings in scope-hoisting concatenation (#9645) by @Boshen
- avoid intermediate Strings in the ESM export clause (#9644) by @Boshen
- reuse a scratch buffer for facade namespace names in the scanner (#9642) by @Boshen
- reuse the import-matching tracker stack across named imports (#9643) by @Boshen
- avoid cloning the per-chunk export-items map in render_chunk_exports (#9639) by @Boshen
- avoid CompactStr allocation in sorted-exports membership check (#9640) by @Boshen

### 🧪 Testing

- add more `moduleSideEffects` precedence tests (#9689) by @sapphi-red
- 9651: drop shimMissingExports from regression fixture (#9674) by @IWANABETHATGUY

### ⚙️ Miscellaneous Tasks

- update react repo links (#9711) by @iiio2
- remove outdated pnpm configurations (#9666) by @btea
- deps: update github actions to v2.81.5 (#9665) by @renovate[bot]
- testing: migrate test harness off deprecated inlineDynamicImports (#9710) by @IWANABETHATGUY
- hmr: delete commented-out dead code left from old register-module codegen (#9707) by @hyf0
- deps: update napi-rs toolchain (#9706) by @shulaoda
- deps: update rollup submodule for tests to v4.61.1 (#9676) by @rolldown-guard[bot]
- deps: update test262 submodule for tests (#9677) by @rolldown-guard[bot]
- deps: update oxc to 0.135.0 (#9670) by @Boshen
- pass ALGOLIA_APP_ID and ALGOLIA_API_KEY to void deploy (#9667) by @Boshen
- deps: update github actions (#9662) by @renovate[bot]
- deps: update rust crates (#9663) by @renovate[bot]
- deps: update rolldown-plugin-dts to v0.25.2 (#9661) by @renovate[bot]
- deps: update typos to v1.47.2 (#9660) by @renovate[bot]
- deps: update docs dependencies (#9657) by @bddjr
- deps: update typos to v1.47.1 (#9655) by @renovate[bot]
- deploy website in its own workflow, only on docs output change (#9650) by @Boshen
- publish to pkg.pr.new add pm and `commentWithDev` option (#9638) by @btea

### ❤️ New Contributors

* @chuganzy made their first contribution in [#9654](#9654)
* @cjc0013 made their first contribution in [#9546](#9546)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants