Skip to content

Comments

feat: support chunkModulesOrder #5227

Merged
IWANABETHATGUY merged 1 commit intomainfrom
07-09-feat_sort_chunk_modules_by_stable_id
Jul 10, 2025
Merged

feat: support chunkModulesOrder #5227
IWANABETHATGUY merged 1 commit intomainfrom
07-09-feat_sort_chunk_modules_by_stable_id

Conversation

@IWANABETHATGUY
Copy link
Member

@IWANABETHATGUY IWANABETHATGUY commented Jul 9, 2025

opt-in support sort chunk modules by their moduleId, only if

  • All those modules are leaf module (without any dependency)
  • Those modules should not have side effects

I have tried other ways:

  • construct a matrix that could O(1) search if module a is a descendant of module b but the time complexity is O(n ^ 3) and O(n ^2) space complexity, n is the count of module in module graph , one case would be:
    a -> b -> c -> ..... -> n, they you need to calc descendant of n, n-1 ... a, that simply equals to 1 + 2 + 3 + 4 + ... + n, this is only for one entry if it is a fully connected module then the overall complexity would be O(n ^3), But since we would bailout for circular reference, a more proper estimitate would be O(n ^2) which is still not scale, the worse thing is this sometimes leads a none total order sorting, so I came up such a simple strategy, but it is good enoguh for now.

Copy link
Member Author

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

@netlify
Copy link

netlify bot commented Jul 9, 2025

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit b31b23b
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/686ea45b05a2d100080de87c
😎 Deploy Preview https://deploy-preview-5227--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.

@IWANABETHATGUY IWANABETHATGUY force-pushed the 07-09-feat_sort_chunk_modules_by_stable_id branch from d08ea2d to 8bdc374 Compare July 9, 2025 14:31
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2025

Benchmarks Rust

  • target: main(1337d71)
  • pr: 07-09-feat_sort_chunk_modules_by_stable_id(b31b23b)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     77.2±1.92ms        ? ?/sec    1.03     79.8±3.40ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     88.5±1.55ms        ? ?/sec    1.06     94.1±3.14ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    114.7±3.61ms        ? ?/sec    1.02    117.3±2.15ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    135.1±1.66ms        ? ?/sec    1.03    139.0±1.59ms        ? ?/sec
bundle/bundle@threejs                                        1.00     42.0±1.50ms        ? ?/sec    1.04     43.6±2.57ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     52.2±1.26ms        ? ?/sec    1.01     52.8±0.78ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    445.3±4.68ms        ? ?/sec    1.01    452.0±9.06ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    520.0±3.29ms        ? ?/sec    1.02    528.7±7.46ms        ? ?/sec
scan/scan@rome_ts                                            1.00     89.7±1.90ms        ? ?/sec    1.03     92.9±1.60ms        ? ?/sec
scan/scan@threejs                                            1.00     31.4±1.91ms        ? ?/sec    1.04     32.6±1.87ms        ? ?/sec
scan/scan@threejs10x                                         1.00    326.1±4.09ms        ? ?/sec    1.03    336.7±7.84ms        ? ?/sec

@IWANABETHATGUY IWANABETHATGUY force-pushed the 07-09-feat_sort_chunk_modules_by_stable_id branch from 8bdc374 to ed15dde Compare July 9, 2025 16:23
@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review July 9, 2025 16:35
@IWANABETHATGUY IWANABETHATGUY force-pushed the 07-09-feat_sort_chunk_modules_by_stable_id branch from ed15dde to 5060437 Compare July 9, 2025 16:35
@IWANABETHATGUY IWANABETHATGUY changed the title feat: sort chunk modules by stable_id feat: support chunkModulesOrder Jul 9, 2025
@IWANABETHATGUY IWANABETHATGUY force-pushed the 07-09-feat_sort_chunk_modules_by_stable_id branch from 7942991 to 9d738ec Compare July 9, 2025 16:44
@IWANABETHATGUY IWANABETHATGUY force-pushed the 07-09-feat_sort_chunk_modules_by_stable_id branch from 9d738ec to b31b23b Compare July 9, 2025 17:18
@IWANABETHATGUY IWANABETHATGUY requested review from hyf0 and shulaoda July 10, 2025 03:24
@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Jul 10, 2025
Merged via the queue into main with commit fb5d21c Jul 10, 2025
23 checks passed
@IWANABETHATGUY IWANABETHATGUY deleted the 07-09-feat_sort_chunk_modules_by_stable_id branch July 10, 2025 04:56
IWANABETHATGUY pushed a commit that referenced this pull request Jul 10, 2025
## [1.0.0-beta.25] - 2025-07-10

### 🚀 Features

- hmr: should initialize cjs with correct initializer (#5234) by @hyf0
- hmr: handle `import(..)` on cjs modules (#5225) by @hyf0
- support `chunkModulesOrder`  (#5227) by @IWANABETHATGUY
- add `export`s to `rolldown:runtime` (#5224) by @hyf0
- hmr: support `import(..)` (#5223) by @hyf0
- add analyzed source code side effects field in ecmaMeta (#5226) by
@IWANABETHATGUY
- hmr: return `undefined` from `generateHmrPatch` when there is no patch
(#5218) by @sapphi-red
- pass `isEntry` to resolveId hook of CallableBuiltinPlugin (#5215) by
@sapphi-red
- pass `isEntry` from `this.resolve` (#5214) by @sapphi-red
- node: support `OutputOptions#minifyInternalExports` (#5210) by @hyf0
- rolldown: oxc v0.76.0 (#5212) by @Boshen
- rust: support `minify_internal_exports` (#5208) by @hyf0
- support opt-in `topLevelVar` (#5188) by @7086cmd
- rolldown: oxc-resolver v11.5.0 (yarn pnp) (#5147) by @Boshen

### 🐛 Bug Fixes

- do not optimize interop code for `mod.default` if mod bind from
default import (#5232) by @IWANABETHATGUY
- return `moduleSideEffects` instead of `sideEffects` from callable
plugins (#5206) by @sapphi-red
- return `moduleSideEffects` set by native plugins from `this.resolve`
(#5205) by @sapphi-red
- incorrect output when importing CJS package (#5201) by @IWANABETHATGUY
- use resolved id instead of module_request when analysis if a module is
a json module (#5200) by @IWANABETHATGUY

### 🚜 Refactor

- use `sort_unstable_by_key` for simple property access (#5233) by
@IWANABETHATGUY
- add Deref impl for TransformPluginContext to access PluginContext
(#5221) by @sapphi-red
- use `BindingHookSideEffects` in CallableBuiltinPlugin (#5204) by
@sapphi-red
- move side effects type bindings logic to rust side (#5203) by
@sapphi-red
- test: improve experience of writing manual integration test (#5186) by
@hyf0
- rust: unify logic of `IntegrationTest` (#5185) by @hyf0

### 🧪 Testing

- rust: automatically run extented test for `minify_internal_exports:
true` (#5213) by @hyf0
- rust: add basic tests for minifying internal exports (#5211) by @hyf0

### ⚙️ Miscellaneous Tasks

- deps: oxc-browserslist v2.0.10 and oxc-resolver v11.5.2 (#5222) by
@Boshen
- use jsonc schema for knip config (#5207) by @sapphi-red
- rust: remove unused code related to
`safe_cjs_to_eliminate_interop_default` (#5202) by @shulaoda
- inject test variant name to rust unit test script (#5195) by
@IWANABETHATGUY
- change CC => TARGET_CC (#5194) by @Brooooooklyn
- deps: lock file maintenance npm packages (#5191) by @renovate[bot]
- deps: lock file maintenance (#5193) by @renovate[bot]
- deps: lock file maintenance rust crates (#5192) by @renovate[bot]
- deps: update github-actions (#5190) by @renovate[bot]
- test: remove unnecessary test snapshots (#5183) by @shulaoda
- rolldown: upgrade to NAPI-RS 3.0.0-beta.12 (#5184) by @Brooooooklyn

Co-authored-by: shulaoda <[email protected]>
pull bot pushed a commit to Stars1233/rolldown that referenced this pull request Jul 10, 2025
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.

2 participants