Skip to content

feat(mcs): support entriesAware#8274

Merged
graphite-app[bot] merged 1 commit intomainfrom
02-11-feat_mcs_support_entriesaware_
Feb 11, 2026
Merged

feat(mcs): support entriesAware#8274
graphite-app[bot] merged 1 commit intomainfrom
02-11-feat_mcs_support_entriesaware_

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Feb 11, 2026


What entriesAware does

Without entriesAware (default false):
All modules matching a group are merged into one chunk. Every entry that imports any of these modules must load the entire chunk — even modules it doesn't need.

With entriesAware: true:
Modules are sub-grouped by their entry-point reachability (which entries can reach them). Modules shared by the same set of entries go into the same chunk; modules shared by a different set go into a separate chunk.

Concrete example

Three entries: entry-a, entry-b, entry-c. One group: { name: "vendor", test: "shared-by", entriesAware: true }.

Modules:

  • shared-by-abc — imported by A, B, C
  • shared-by-ab — imported by A, B only
  • shared-by-a — imported by A only

entriesAware: false → 1 chunk:

  • vendor.js contains all three modules. All three entries import vendor.js, so entry-c loads shared-by-ab and shared-by-a unnecessarily.

entriesAware: true → 3 chunks:

  • vendor.js (shared-by-abc, reachable by A+B+C) — loaded by all entries
  • vendor2.js (shared-by-ab, reachable by A+B) — loaded by entry-a and entry-b only
  • vendor3.js (shared-by-a, reachable by A) — loaded by entry-a only

Each entry only loads exactly the code it needs.

Interaction with maxSize

maxSize splitting happens after entriesAware grouping. The pipeline is:

  1. Group modules by match pattern + (if entriesAware) entry-reachability bits
  2. Filter groups by minSize / minShareCount
  3. Split any group exceeding maxSize into smaller sub-chunks using a two-pointer greedy algorithm (sorted by module size, split so both halves satisfy minSize)
  4. Create final chunks

So with entriesAware: true, maxSize applies to each reachability-based sub-group independently. A group that was already split by entry reachability may be further split if it still exceeds maxSize.

Interaction with minShareCount

When combined with entriesAware: true, minShareCount filters based on how many entries reach each individual module. Example from tests:

  • Group { name: "utils", test: "utils", minShareCount: 2, entriesAware: true }
  • formatDate (shared by A, B → count=2) → goes into utils.js
  • deepClone (shared by B, C → count=2) → goes into utils2.js (different reachability set)
  • debounce (only used by A → count=1) → not captured by the group, stays inlined in entry-a

Copy link
Member Author

hyf0 commented Feb 11, 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.

@hyf0 hyf0 marked this pull request as ready for review February 11, 2026 08:37
Copilot AI review requested due to automatic review settings February 11, 2026 08:37
@netlify
Copy link

netlify bot commented Feb 11, 2026

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit ad79511
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/698c3fa8e3c7c80008c1b37f
😎 Deploy Preview https://deploy-preview-8274--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@netlify
Copy link

netlify bot commented Feb 11, 2026

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 9fa5363
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/698c753069a0100008d2915a
😎 Deploy Preview https://deploy-preview-8274--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

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 adds support for the entriesAware option in manual code splitting (also known as advanced chunks), which enables more granular chunk splitting based on which entry points actually import specific modules. This addresses issue #7117 regarding computation of module groups with import relationships.

Changes:

  • Added entriesAware boolean option to CodeSplittingGroup configuration, allowing modules to be split by entry-point reachability
  • Updated chunk creation debug info to display which entries reference each chunk when entriesAware is enabled
  • Added comprehensive test coverage with three test scenarios demonstrating different behaviors

Reviewed changes

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

Show a summary per file
File Description
packages/rolldown/src/utils/validator.ts Added schema validation for new entriesAware field
packages/rolldown/src/options/output-options.ts Added comprehensive documentation and type definition for entriesAware option
packages/rolldown/src/binding.d.cts Updated TypeScript binding interface to include entriesAware
crates/rolldown_utils/src/bitset.rs Minor formatting improvement (added blank line)
crates/rolldown_testing/_config.schema.json Added JSON schema for entriesAware in test configs
crates/rolldown_common/src/inner_bundler_options/types/manual_code_splitting_options.rs Added entries_aware field to MatchGroup struct
crates/rolldown_binding/src/utils/normalize_binding_options.rs Forwarded entries_aware from binding to internal options
crates/rolldown_binding/src/options/binding_output_options/binding_manual_code_splitting_options.rs Added entries_aware field to binding struct
crates/rolldown/tests/snapshots/integration_rolldown__filename_with_hash.snap Updated snapshot with new test outputs
crates/rolldown/tests/rolldown/function/advanced_chunks/entries_aware_true/* Test case demonstrating entriesAware: true with multiple vendor chunks
crates/rolldown/tests/rolldown/function/advanced_chunks/entries_aware_min_share_count/* Test case combining entriesAware: true with minShareCount
crates/rolldown/tests/rolldown/function/advanced_chunks/entries_aware_false/* Test case demonstrating default behavior (entriesAware: false)
crates/rolldown/src/stages/generate_stage/manual_code_splitting.rs Core implementation using BitSet as part of unique key when entriesAware is enabled
crates/rolldown/src/stages/generate_stage/chunk_ext.rs Refactored ChunkCreationReason to include entry information and extracted helper function

@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

Benchmarks Rust

  • target: main(179df16)
  • pr: 02-11-feat_mcs_support_entriesaware_(9fa5363)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     74.8±2.48ms        ? ?/sec    1.01     75.5±1.97ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     80.6±2.27ms        ? ?/sec    1.02     82.2±1.87ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    104.3±3.08ms        ? ?/sec    1.00    103.9±1.88ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    115.0±1.64ms        ? ?/sec    1.01    116.5±2.01ms        ? ?/sec
bundle/bundle@threejs                                        1.02     38.2±2.39ms        ? ?/sec    1.00     37.6±2.00ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     42.4±0.70ms        ? ?/sec    1.00     42.6±0.67ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    376.5±5.11ms        ? ?/sec    1.01    380.1±3.92ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    432.8±6.17ms        ? ?/sec    1.01    436.7±9.12ms        ? ?/sec
scan/scan@rome_ts                                            1.02     82.0±1.65ms        ? ?/sec    1.00     80.8±1.79ms        ? ?/sec
scan/scan@threejs                                            1.03     28.7±1.81ms        ? ?/sec    1.00     27.8±0.43ms        ? ?/sec
scan/scan@threejs10x                                         1.00    287.3±4.70ms        ? ?/sec    1.00    286.5±5.03ms        ? ?/sec

@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 11, 2026

Merge activity

- Fixes #7117 in a rolldown-style, which means considering the fact that rolldown enforcing esm and singleton.
- MCS -> Manual Code Splitting

---

## What `entriesAware` does

**Without `entriesAware` (default `false`):**
All modules matching a group are merged into one chunk. Every entry that imports any of these modules must load the entire chunk — even modules it doesn't need.

**With `entriesAware: true`:**
Modules are sub-grouped by their entry-point reachability (which entries can reach them). Modules shared by the **same set** of entries go into the same chunk; modules shared by a **different set** go into a separate chunk.

## Concrete example

Three entries: `entry-a`, `entry-b`, `entry-c`. One group: `{ name: "vendor", test: "shared-by", entriesAware: true }`.

Modules:
- `shared-by-abc` — imported by A, B, C
- `shared-by-ab` — imported by A, B only
- `shared-by-a` — imported by A only

**`entriesAware: false`** → 1 chunk:
- `vendor.js` contains all three modules. All three entries import `vendor.js`, so entry-c loads `shared-by-ab` and `shared-by-a` unnecessarily.

**`entriesAware: true`** → 3 chunks:
- `vendor.js` (`shared-by-abc`, reachable by A+B+C) — loaded by all entries
- `vendor2.js` (`shared-by-ab`, reachable by A+B) — loaded by entry-a and entry-b only
- `vendor3.js` (`shared-by-a`, reachable by A) — loaded by entry-a only

Each entry only loads exactly the code it needs.

## Interaction with `maxSize`

`maxSize` splitting happens **after** `entriesAware` grouping. The pipeline is:

1. **Group** modules by match pattern + (if `entriesAware`) entry-reachability bits
2. **Filter** groups by `minSize` / `minShareCount`
3. **Split** any group exceeding `maxSize` into smaller sub-chunks using a two-pointer greedy algorithm (sorted by module size, split so both halves satisfy `minSize`)
4. **Create** final chunks

So with `entriesAware: true`, `maxSize` applies to each reachability-based sub-group independently. A group that was already split by entry reachability may be further split if it still exceeds `maxSize`.

## Interaction with `minShareCount`

When combined with `entriesAware: true`, `minShareCount` filters based on how many entries reach each individual module. Example from tests:
- Group `{ name: "utils", test: "utils", minShareCount: 2, entriesAware: true }`
- `formatDate` (shared by A, B → count=2) → goes into `utils.js`
- `deepClone` (shared by B, C → count=2) → goes into `utils2.js` (different reachability set)
- `debounce` (only used by A → count=1) → **not captured** by the group, stays inlined in entry-a
Copilot AI review requested due to automatic review settings February 11, 2026 12:24
@graphite-app graphite-app bot force-pushed the 02-11-feat_mcs_support_entriesaware_ branch from 94aa580 to 9fa5363 Compare February 11, 2026 12:24
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@graphite-app graphite-app bot merged commit 9fa5363 into main Feb 11, 2026
35 checks passed
@graphite-app graphite-app bot deleted the 02-11-feat_mcs_support_entriesaware_ branch February 11, 2026 12:36
shulaoda pushed a commit that referenced this pull request Feb 18, 2026
## [1.0.0-rc.5] - 2026-02-18

💡 Smarter `entriesAware` Manual Code Splitting                                                                 
                                             
New `entriesAware` and `entriesAwareMergeThreshold` options for `manualCodeSplitting.groups[]` enable              
entry-reachability-based chunk splitting with automatic small chunk merging.                                       
                                                                                                                   
- `entriesAware: true` splits matched modules by entry reachability — modules reached by the same set of entries are grouped together, providing the most precise loading behavior with less over-fetching
- Chunks now get more readable names reflecting their entry associations (e.g. `vendor-entry-a-entry-b.js`) instead of opaque hashes
- `entriesAwareMergeThreshold` sets a byte-size threshold to merge tiny subgroups into the closest sibling with the fewest extra entries, reducing micro-chunk fragmentation while preserving precision
- Recommended to use together with `maxSize`: merge tiny chunks first to reduce request overhead, then cap large chunks to control payload size

```js
manualCodeSplitting: {
  groups: [{
    name: 'vendor',
    test: /node_modules/,
    entriesAware: true,
    entriesAwareMergeThreshold: 28000, // bytes
  }]
}
```

### 🚀 Features

- add `Visitor` to `rolldown/utils` (#8373) by @sapphi-red
- module-info: add `inputFormat` property to `ModuleInfo` (#8329) by @shulaoda
- default `treeshake.invalid_import_side_effects` to `false` (#8357) by @sapphi-red
- rolldown_utils: add `IndexBitSet` (#8343) by @sapphi-red
- rolldown_utils: add more methods and trait impls to BitSet (#8342) by @sapphi-red
- rolldown_plugin_vite_build_import_analysis: add support for `await import().then((m) => m.prop)` (#8328) by @sapphi-red
- rolldown_plugin_vite_reporter: support custom logger for build infos (#7652) by @shulaoda
- rust/mcs: support `entriesAwareMergeThreshold` (#8312) by @hyf0
- mcs: `maxSize` will split the oversized chunk with taking file relevance into account (#8277) by @hyf0
- rolldown_plugin_vite_import_glob: support template literal in glob import patterns (#8298) by @shulaoda
- rolldown_plugin_chunk_import_map: output importmap without spaces (#8297) by @sapphi-red
- add INEFFECTIVE_DYNAMIC_IMPORT warning in core (#8284) by @shulaoda
- mcs: generate more readable name for `entriesAware` chunks (#8275) by @hyf0
- mcs: support `entriesAware` (#8274) by @hyf0

### 🐛 Bug Fixes

- improve circular dependency detection in chunk optimizer (#8371) by @IWANABETHATGUY
- align `minify.compress: true` and `minify.mangle: true` with `minify: true` (#8367) by @sapphi-red
- rolldown_plugin_esm_external_require: apply conversion to UMD and IIFE outputs (#8359) by @sapphi-red
- cjs: bailout treeshaking on cjs modules that have multiple re-exports (#8348) by @hyf0
- handle member expression and this expression in JSX element name rewriting (#8323) by @IWANABETHATGUY
- pad `encode_hash_with_base` output to fixed length to prevent slice panics (#8320) by @shulaoda
- `xxhash_with_base` skips hashing when input is exactly 16 bytes (#8319) by @shulaoda
- complete `ImportKind::try_from` with missing variants and correct `url-import` to `url-token` (#8310) by @shulaoda
- mark Node.js builtin modules as side-effect-free when resolved via `external` config (#8304) by @IWANABETHATGUY
- mcs: `maxSize` should split chunks correctly based on sizes (#8289) by @hyf0

### 🚜 Refactor

- introduce `RawMangleOptions` and `RawCompressOptions` (#8366) by @sapphi-red
- mcs: refactor `apply_manual_code_splitting` into `ManualSplitter` (#8346) by @hyf0
- rolldown_plugin_vite_reporter: simplify hook registration and remove redundant state (#8322) by @shulaoda
- use set to store user defined entry modules (#8315) by @IWANABETHATGUY
- rust/mcs: collect groups into map at first for having clean and performant operations (#8313) by @hyf0
- mcs: introduce newtype `ModuleGroupOrigin` and `ModuleGroupId` (#8311) by @hyf0
- remove unnecessary `FinalizerMutableState` struct (#8303) by @shulaoda
- move module finalization into `finalize_modules` (#8302) by @shulaoda
- extract `apply_transfer_parts_mutation` into its own module (#8301) by @shulaoda
- move ESM format check into `determine_export_mode` (#8294) by @shulaoda
- remove `warnings` field from `GenerateContext` (#8293) by @shulaoda
- extract util function remove clippy supression (#8290) by @IWANABETHATGUY
- move `is_in_node_modules` to `PathExt` trait in `rolldown_std_utils` (#8286) by @shulaoda
- rolldown_plugin_vite_reporter: remove unnecessary ineffective dynamic import detection logic (#8285) by @shulaoda
- dev: inject hmr runtime to `\0rolldown/runtime.js` (#8234) by @hyf0
- improve naming in chunk_optimizer (#8287) by @IWANABETHATGUY
- simplify PostChunkOptimizationOperation from bitflags to enum (#8283) by @IWANABETHATGUY
- optimize BitSet.index_of_one to return iterator instead of Vec (#8282) by @IWANABETHATGUY

### 📚 Documentation

- change default value in `format` JSDoc from `'esm'` to `'es'` (#8372) by @shulaoda
- in-depth: remove `invalidImportSideEffects` option mention from lazy barrel optimization doc (#8355) by @sapphi-red
- mcs: clarify `minSize` constraints (#8279) by @ShroXd

### ⚡ Performance

- use IndexVec for chunk TLA detection (#8341) by @sapphi-red
- only invoke single resolve call for the same specifier and import kind (#8332) by @sapphi-red
- rolldown_plugin_vite_reporter: skip gzip computation when `report_compressed_size` is disabled (#8321) by @shulaoda

### 🧪 Testing

- use `vi.waitFor` and `expect.poll` instead of custom `waitUtil` function (#8369) by @sapphi-red
- rolldown_plugin_esm_external_require_plugin: add tests (#8358) by @sapphi-red
- add watch file tests (#8330) by @sapphi-red
- rolldown_plugin_vite_build_import_analysis: add test for dynamic import treeshaking (#8327) by @sapphi-red

### ⚙️ Miscellaneous Tasks

- prepare-release: skip workflow on forked repositories (#8368) by @shulaoda
- format more files (#8360) by @sapphi-red
- deps: update oxc to v0.114.0 (#8347) by @camc314
- deps: update test262 submodule for tests (#8354) by @sapphi-red
- deps: update crate-ci/typos action to v1.43.5 (#8350) by @renovate[bot]
- deps: update oxc apps (#8351) by @renovate[bot]
- rolldown_plugin_vite_reporter: remove unnecessary README.md (#8334) by @shulaoda
- deps: update npm packages (#8338) by @renovate[bot]
- deps: update rust crates (#8339) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.13.0 (#8337) by @renovate[bot]
- deps: update github-actions (#8336) by @renovate[bot]
- deps: update napi to v3.8.3 (#8331) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.12.2 (#8325) by @renovate[bot]
- remove unnecessary transform.decorator (#8314) by @IWANABETHATGUY
- deps: update dependency rust to v1.93.1 (#8305) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.12.1 (#8300) by @renovate[bot]
- deps: update oxc apps (#8296) by @renovate[bot]
- docs: don't skip for build runs without cache (#8281) by @sapphi-red
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.

[AdvancedChunks] Compute module groups with considering the import relationships

4 participants