Skip to content

fix: cjs namespace merging regression#7665

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-26-fix_cjs_module_merging_regression
Dec 26, 2025
Merged

fix: cjs namespace merging regression#7665
graphite-app[bot] merged 1 commit intomainfrom
12-26-fix_cjs_module_merging_regression

Conversation

@IWANABETHATGUY
Copy link
Member

No description provided.

Copy link
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.

@netlify
Copy link

netlify bot commented Dec 26, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit bdb61d4
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/694e95443d0ba600081acca3

@IWANABETHATGUY IWANABETHATGUY force-pushed the 12-26-fix_cjs_module_merging_regression branch from a4d7472 to 48b0d56 Compare December 26, 2025 09:37
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 26, 2025

Open in StackBlitz

@rolldown/browser

npm i https://pkg.pr.new/@rolldown/browser@7665

@rolldown/debug

npm i https://pkg.pr.new/@rolldown/debug@7665

@rolldown/pluginutils

npm i https://pkg.pr.new/@rolldown/pluginutils@7665

rolldown

npm i https://pkg.pr.new/rolldown@7665

@rolldown/binding-android-arm64

npm i https://pkg.pr.new/@rolldown/binding-android-arm64@7665

@rolldown/binding-darwin-arm64

npm i https://pkg.pr.new/@rolldown/binding-darwin-arm64@7665

@rolldown/binding-darwin-x64

npm i https://pkg.pr.new/@rolldown/binding-darwin-x64@7665

@rolldown/binding-freebsd-x64

npm i https://pkg.pr.new/@rolldown/binding-freebsd-x64@7665

@rolldown/binding-linux-arm-gnueabihf

npm i https://pkg.pr.new/@rolldown/binding-linux-arm-gnueabihf@7665

@rolldown/binding-linux-arm64-gnu

npm i https://pkg.pr.new/@rolldown/binding-linux-arm64-gnu@7665

@rolldown/binding-linux-arm64-musl

npm i https://pkg.pr.new/@rolldown/binding-linux-arm64-musl@7665

@rolldown/binding-linux-x64-gnu

npm i https://pkg.pr.new/@rolldown/binding-linux-x64-gnu@7665

@rolldown/binding-linux-x64-musl

npm i https://pkg.pr.new/@rolldown/binding-linux-x64-musl@7665

@rolldown/binding-openharmony-arm64

npm i https://pkg.pr.new/@rolldown/binding-openharmony-arm64@7665

@rolldown/binding-wasm32-wasi

npm i https://pkg.pr.new/@rolldown/binding-wasm32-wasi@7665

@rolldown/binding-win32-arm64-msvc

npm i https://pkg.pr.new/@rolldown/binding-win32-arm64-msvc@7665

@rolldown/binding-win32-x64-msvc

npm i https://pkg.pr.new/@rolldown/binding-win32-x64-msvc@7665

commit: 48b0d56

@IWANABETHATGUY IWANABETHATGUY force-pushed the 12-26-fix_cjs_module_merging_regression branch from 48b0d56 to fce95bc Compare December 26, 2025 10:07
@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review December 26, 2025 10:33
Copilot AI review requested due to automatic review settings December 26, 2025 10:33
Copy link
Contributor

Copilot AI left a comment

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 a regression in CommonJS module namespace merging where namespace imports that were tree-shaken were incorrectly being merged with active namespace imports. The fix adds statement inclusion checking during the generate stage to ensure only namespaces from actually included statements participate in the merging optimization.

  • Adds statement inclusion check in merge_cjs_namespace to filter out tree-shaken namespace imports
  • Includes test case demonstrating the issue: a module importing CommonJS but not using it
  • Updates snapshots to reflect the corrected output

Reviewed changes

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

Show a summary per file
File Description
crates/rolldown/src/stages/generate_stage/code_splitting.rs Adds filtering logic to check if namespace symbol's declaring statements are included before merging CJS namespaces
crates/rolldown/tests/rolldown/cjs_compat/react-like/lib.js New test file that imports a CommonJS module but doesn't use it (tests tree-shaking scenario)
crates/rolldown/tests/rolldown/cjs_compat/react-like/main.js Updated to import and test the new lib.js module
crates/rolldown/tests/rolldown/cjs_compat/react-like/artifacts.snap Updated snapshot showing namespace import correctly scoped to lib.js region instead of being incorrectly merged
crates/rolldown/tests/snapshots/integration_rolldown__filename_with_hash.snap Hash update due to changed output

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 26, 2025

Benchmarks Rust

  • target: main(dea663c)
  • pr: 12-26-fix_cjs_module_merging_regression(bdb61d4)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.01     62.9±1.07ms        ? ?/sec    1.00     62.4±1.15ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.02     69.4±1.27ms        ? ?/sec    1.00     68.3±1.22ms        ? ?/sec
bundle/bundle@rome_ts                                        1.01    107.7±2.92ms        ? ?/sec    1.00    107.1±1.67ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    119.3±1.40ms        ? ?/sec    1.00    119.1±2.10ms        ? ?/sec
bundle/bundle@threejs                                        1.01     39.0±1.01ms        ? ?/sec    1.00     38.7±0.42ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     42.4±0.48ms        ? ?/sec    1.00     42.6±0.52ms        ? ?/sec
bundle/bundle@threejs10x                                     1.01    395.5±7.17ms        ? ?/sec    1.00    392.2±5.22ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.01    451.8±2.85ms        ? ?/sec    1.00    448.5±3.94ms        ? ?/sec
scan/scan@rome_ts                                            1.01     83.9±1.50ms        ? ?/sec    1.00     83.2±1.18ms        ? ?/sec
scan/scan@threejs                                            1.00     28.4±0.49ms        ? ?/sec    1.00     28.2±0.56ms        ? ?/sec
scan/scan@threejs10x                                         1.00    294.0±4.25ms        ? ?/sec    1.00    294.1±5.10ms        ? ?/sec

@IWANABETHATGUY IWANABETHATGUY force-pushed the 12-26-fix_cjs_module_merging_regression branch from fce95bc to a29d8c3 Compare December 26, 2025 11:18
Copilot AI review requested due to automatic review settings December 26, 2025 12:56
@IWANABETHATGUY IWANABETHATGUY force-pushed the 12-26-fix_cjs_module_merging_regression branch from a29d8c3 to d72bd9d Compare December 26, 2025 12:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@IWANABETHATGUY IWANABETHATGUY changed the title fix: cjs module merging regression fix: cjs namespace merging regression Dec 26, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 26, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-26-fix_cjs_module_merging_regression branch from d72bd9d to bdb61d4 Compare December 26, 2025 14:01
@graphite-app graphite-app bot merged commit bdb61d4 into main Dec 26, 2025
33 checks passed
@graphite-app graphite-app bot deleted the 12-26-fix_cjs_module_merging_regression branch December 26, 2025 14:10
This was referenced Dec 31, 2025
shulaoda added a commit that referenced this pull request Dec 31, 2025
## [1.0.0-beta.58] - 2025-12-31

### 💥 BREAKING CHANGES

- experimental/devtools: rename InputOptions#debug to InputOptions#devtools (#7686) by @Copilot

### 🚀 Features

- implement target feature check in `should_transform_js` for raw options (#7697) by @shulaoda
- support `output.dynamicImportInCjs` option (#7677) by @shulaoda
- types: expose `ChecksOptions` type (#7653) by @sapphi-red

### 🐛 Bug Fixes

- export runtime helpers for cross-chunk access (#7658) by @shulaoda
- cjs namespace merging regression (#7665) by @IWANABETHATGUY
- replace panic with proper error handling for hash placeholder generation (#7661) by @shulaoda
- remove the blank line between shebang and postBanner (#7643) by @btea
- rolldown_plugin_vite_reporter: apply padding before ANSI coloring for proper size column alignment (#7649) by @shulaoda

### 🚜 Refactor

- rust: use `StableModuleId` as the map key if possible (#7718) by @hyf0
- rust: return `StableModuleId` instead of `&str` from `Module#stable_id()` (#7717) by @hyf0
- rust: return correct stable id of external module from `Module#stable_id()` (#7716) by @hyf0
- rust: introduce `StableModuleId` type (#7715) by @hyf0
- rust: reduce unnecessary `id.as_arc_str().clone().into()` (#7714) by @hyf0
- rust: remove `ModuleId#resource_id` and use `as_arc_str` directly (#7710) by @hyf0
- rust: remove unused `Module#id_clone` (#7709) by @hyf0
- rust: remove `Module#id_as_str` and use `Module#id` directly (#7708) by @hyf0
- consolidate namespace call analysis into import analyzer (#7657) by @IWANABETHATGUY
- rust: make `ExternalModule#id` have the type `ModuleId` (#7707) by @hyf0
- rust: rename `Module#id` to `Module#id_as_str` (#7706) by @hyf0
- rust: use `ModuleId` instead of raw `ArcStr` for `ScanStageCache` (#7701) by @hyf0
- simplify error propagation in cache merge (#7702) by @shulaoda
- use `ModuleId` as the type of `ResolvedId#id` (#7694) by @hyf0
- types: rename `resolved_request_info.rs` to `resolved_id.rs` and move its contents (#7687) by @hyf0
- devtools: emit data to `<CWD>/node_modules/.rolldown` (#7692) by @hyf0
- use `InvalidOption` for hash placeholder generation errors (#7674) by @shulaoda
- rolldown_error: remove dependency on rolldown_utils (#7672) by @shulaoda
- use nodejs-built-in-modules v1.0.0 directly in callsites (#7667) by @Boshen

### 📚 Documentation

- migrate input options content from options to auto gen docs (#7663) by @mdong1909
- create reference index page (#7659) by @mdong1909
- tweak auto-generated reference output (#7654) by @sapphi-red
- initialize auto-gen docs (#7252) by @mdong1909

### ⚙️ Miscellaneous Tasks

- deps: update napi (#7705) by @renovate[bot]
- pin Node.js version to 24.12.0 LTS in .node-version file (#7713) by @Copilot
- update esbuild test reasons (#7703) by @sapphi-red
- deps: update crate-ci/typos action to v1.40.1 (#7696) by @renovate[bot]
- deps: update oxc to v0.106.0 (#7512) by @renovate[bot]
- js: replace dprint with oxfmt (#7214) by @Boshen
- deps: update dependency oxlint to v1.36.0 (#7691) by @renovate[bot]
- deps: update github-actions (#7679) by @renovate[bot]
- deps: update npm packages (#7680) by @renovate[bot]
- deps: update rust crates (#7678) by @renovate[bot]
- deps: update oxc resolver to v11.16.2 (#7668) by @renovate[bot]
- add API reference files to knip entry points (#7669) by @Copilot
- deps: update notify (#7651) by @sapphi-red
- add `homepage` field to package.json (#7648) by @trivikr
- deps: update oxc resolver to v11.16.1 (#7647) by @renovate[bot]
- deps: update rolldown-plugin-dts to 0.20.0 (#7645) by @shulaoda

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants