Skip to content

Comments

fix: merge chunks after detect circular reference#8154

Merged
IWANABETHATGUY merged 4 commits intomainfrom
02-01-fix_merge_chunks_after_detect_circular_reference
Feb 6, 2026
Merged

fix: merge chunks after detect circular reference#8154
IWANABETHATGUY merged 4 commits intomainfrom
02-01-fix_merge_chunks_after_detect_circular_reference

Conversation

@IWANABETHATGUY
Copy link
Member

@IWANABETHATGUY IWANABETHATGUY commented Feb 1, 2026

closed #8184

Copy link
Member Author

IWANABETHATGUY commented Feb 1, 2026


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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 2, 2026

Open in StackBlitz

@rolldown/browser

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

@rolldown/debug

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

@rolldown/pluginutils

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

rolldown

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

@rolldown/binding-android-arm64

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

@rolldown/binding-darwin-arm64

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

@rolldown/binding-darwin-x64

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

@rolldown/binding-freebsd-x64

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

@rolldown/binding-linux-arm-gnueabihf

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

@rolldown/binding-linux-arm64-gnu

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

@rolldown/binding-linux-arm64-musl

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

@rolldown/binding-linux-x64-gnu

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

@rolldown/binding-linux-x64-musl

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

@rolldown/binding-openharmony-arm64

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

@rolldown/binding-wasm32-wasi

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

@rolldown/binding-win32-arm64-msvc

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

@rolldown/binding-win32-x64-msvc

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

commit: c46f1ff

@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch from 362da47 to 6b87428 Compare February 2, 2026 14:43
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-refactor_prepare_defer_chunk_merging branch 2 times, most recently from 9b70feb to a1f3d60 Compare February 4, 2026 11:08
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch from 6b87428 to 4826d08 Compare February 4, 2026 11:08
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-refactor_prepare_defer_chunk_merging branch from a1f3d60 to 66ebb55 Compare February 4, 2026 11:10
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch from 4826d08 to 2671353 Compare February 4, 2026 13:25
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-refactor_prepare_defer_chunk_merging branch from 66ebb55 to 70b5065 Compare February 4, 2026 13:25
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch 4 times, most recently from b5126c5 to 257620c Compare February 4, 2026 13:58
@graphite-app graphite-app bot changed the base branch from 02-01-refactor_prepare_defer_chunk_merging to graphite-base/8154 February 4, 2026 18:20
@graphite-app graphite-app bot force-pushed the graphite-base/8154 branch from 817c4bb to 78962f4 Compare February 4, 2026 18:30
@graphite-app graphite-app bot force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch from 257620c to 8f6e325 Compare February 4, 2026 18:30
@graphite-app graphite-app bot changed the base branch from graphite-base/8154 to main February 4, 2026 18:31
@graphite-app graphite-app bot force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch from 8f6e325 to 438c84d Compare February 4, 2026 18:31
@netlify
Copy link

netlify bot commented Feb 4, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 028e5b6
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6985c07a35d51f0008ce7263

@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch 4 times, most recently from 66a65e6 to c46f1ff Compare February 5, 2026 12:37
@IWANABETHATGUY IWANABETHATGUY added the test: vite-tests Trigger Vite tests workflow on this PR label Feb 5, 2026
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch 3 times, most recently from 191c239 to a9715d5 Compare February 6, 2026 10:00
@IWANABETHATGUY IWANABETHATGUY force-pushed the 02-01-fix_merge_chunks_after_detect_circular_reference branch from a9715d5 to 028e5b6 Compare February 6, 2026 10:20
@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review February 6, 2026 10:22
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 critical bug where chunk optimization could create circular dependencies, leading to runtime errors like __exportAll is not a function. The fix introduces dependency tracking and circular dependency detection in the chunk optimization process.

Changes:

  • Added dependency tracking to ChunkOptimizationGraph to maintain chunk-to-chunk dependencies during optimization
  • Implemented circular dependency detection using BFS to prevent invalid chunk merges that would create cycles
  • Added comprehensive test case reproducing the circular reference scenario from issue #8184

Reviewed changes

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

File Description
crates/rolldown/src/stages/generate_stage/chunk_optimizer.rs Core fix: renamed TempChunkGraph to ChunkOptimizationGraph, added dependency tracking, circular dependency detection, and dependency merging logic
crates/rolldown/src/stages/generate_stage/code_splitting.rs Integration: updated to call calc_chunk_dependencies and pass temp_chunk_graph to optimization functions
crates/rolldown/tests/rolldown/code_splitting/issue_8184/* Test case: added comprehensive test with circular imports to verify the fix
crates/rolldown/tests/snapshots/integration_rolldown__filename_with_hash.snap Snapshot update: includes expected output for the new test case

@IWANABETHATGUY
Copy link
Member Author

The vite test failure is not related to this pr

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Benchmarks Rust

  • target: main(e669ee6)
  • pr: 02-01-fix_merge_chunks_after_detect_circular_reference(028e5b6)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.01     62.4±1.33ms        ? ?/sec    1.00     61.9±1.21ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.03     69.4±1.46ms        ? ?/sec    1.00     67.5±1.04ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00     93.3±1.30ms        ? ?/sec    1.00     93.1±1.33ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.01    106.0±1.97ms        ? ?/sec    1.00    105.3±1.45ms        ? ?/sec
bundle/bundle@threejs                                        1.03     34.2±2.22ms        ? ?/sec    1.00     33.3±0.39ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.02     39.2±0.70ms        ? ?/sec    1.00     38.6±0.57ms        ? ?/sec
bundle/bundle@threejs10x                                     1.01    343.9±2.40ms        ? ?/sec    1.00    341.2±2.74ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.01    409.0±4.33ms        ? ?/sec    1.00    406.2±3.14ms        ? ?/sec
scan/scan@rome_ts                                            1.00     73.4±1.00ms        ? ?/sec    1.00     73.2±1.00ms        ? ?/sec
scan/scan@threejs                                            1.03     26.2±1.69ms        ? ?/sec    1.00     25.6±0.30ms        ? ?/sec
scan/scan@threejs10x                                         1.01    264.2±3.42ms        ? ?/sec    1.00    262.5±2.44ms        ? ?/sec

@IWANABETHATGUY IWANABETHATGUY merged commit 37b648d into main Feb 6, 2026
65 of 68 checks passed
@IWANABETHATGUY IWANABETHATGUY deleted the 02-01-fix_merge_chunks_after_detect_circular_reference branch February 6, 2026 11:06
This was referenced Feb 11, 2026
shulaoda added a commit that referenced this pull request Feb 11, 2026
## [1.0.0-rc.4] - 2026-02-11

💡 Granular `comments` Option
- New `output.comments` option provides fine-grained control over comment preservation
- The `output.legalComments` option is now deprecated and use `comments.legal` instead

### 🚀 Features

- rename error name to `RolldownError` from `RollupError` (#8262) by @sapphi-red
- add hidden `resolve_tsconfig` function for Vite (#8257) by @sapphi-red
- rust: introduce `rolldown_watcher` (#8161) by @hyf0
- unify `comments` and `legalComments` into a single granular `comments` option (#8229) by @IWANABETHATGUY
- add builtin plugin for visualizing chunk graph (#8162) by @IWANABETHATGUY
- show import declaration location in AssignToImport errors (#8222) by @Copilot
- show import declaration span in CannotCallNamespace error (#8223) by @Copilot
- emit error when plugin accidentally removes runtime module symbols (#8203) by @IWANABETHATGUY
- support tsconfig loading & inputMap for `transform` (#8180) by @sapphi-red
- rolldown_plugin_vite_reporter: update warning message to link to Rolldown docs (#8205) by @sapphi-red

### 🐛 Bug Fixes

- avoid panic on untranspiled JSX syntax by reporting a diagnostic error (#8226) by @IWANABETHATGUY
- rolldown_plugin_vite_import_glob: relax absolute path check and improve invalid glob warning (#8219) by @shulaoda
- merge chunks after detect circular reference (#8154) by @IWANABETHATGUY
- rust: detect runtime module side effects based on its content (#8209) by @hyf0

### 🚜 Refactor

- rename `other` to `jsdoc` in comments options (#8256) by @IWANABETHATGUY
- rename chunk-visualize plugin with bundle-analyzer plugin (#8255) by @IWANABETHATGUY
- remove EXPORT_UNDEFINED_VARIABLE error (#8228) by @Copilot
- consolidate missing runtime symbol errors into a single diagnostic (#8220) by @IWANABETHATGUY
- stabilize `parse` and `parseSync` (#8215) by @sapphi-red
- return errors instead of panicking on builtin plugin conversion failure (#8217) by @shulaoda
- expose `parse` / `minify` / `transform` from `rolldown/utils` (#8214) by @sapphi-red
- prepare defer chunk merging (#8153) by @IWANABETHATGUY

### 📚 Documentation

- remove `<script>` escape behavior difference note from `platform` option (#8253) by @sapphi-red
- TypeScript & JSX support by plugins (#8183) by @sapphi-red

### 🧪 Testing

- ensure runtime module is preserved even if it's not used but has side effects (#8213) by @hyf0

### ⚙️ Miscellaneous Tasks

- deps: update oxc to v0.113.0 (#8267) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.12.0 (#8272) by @renovate[bot]
- deps: update oxc apps (#8269) by @renovate[bot]
- deps: update test262 submodule for tests (#8261) by @sapphi-red
- deps: update crate-ci/typos action to v1.43.4 (#8260) by @renovate[bot]
- deps: update dependency esbuild to v0.27.3 (#8250) by @renovate[bot]
- deps: update rust crates (#8244) by @renovate[bot]
- deps: update dependency semver to v7.7.4 (#8247) by @renovate[bot]
- deps: update github-actions (#8243) by @renovate[bot]
- deps: update npm packages (#8245) by @renovate[bot]
- deps: update oxc resolver to v11.17.1 (#8240) by @renovate[bot]
- deps: update rust crate oxc_sourcemap to v6.0.2 (#8241) by @renovate[bot]
- rust: handle ignored `RUSTSEC-2025-0141` cargo check error (#8235) by @hyf0
- deps: update dependency oxlint-tsgolint to v0.11.5 (#8233) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to ^0.22.0 (#8232) by @renovate[bot]
- deps: update crate-ci/typos action to v1.43.3 (#8225) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.21.9 (#8224) by @renovate[bot]
- deps: update crate-ci/typos action to v1.43.2 (#8212) by @renovate[bot]
- remove rolldown_plugin_vite_wasm_helper (#8207) by @shulaoda
- build docs for production (#8206) by @sapphi-red

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: vite-tests Trigger Vite tests workflow on this PR trigger: preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: __exportAll is not a function since rc.2

3 participants