Skip to content

refactor(rust): use ModuleId instead of raw ArcStr for ScanStageCache#7701

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-30-refactor_rust_use_moduleid_instead_of_raw_arcstr_for_scanstagecache_
Dec 30, 2025
Merged

refactor(rust): use ModuleId instead of raw ArcStr for ScanStageCache#7701
graphite-app[bot] merged 1 commit intomainfrom
12-30-refactor_rust_use_moduleid_instead_of_raw_arcstr_for_scanstagecache_

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Dec 30, 2025

No description provided.

@hyf0 hyf0 marked this pull request as ready for review December 30, 2025 05:25
Copilot AI review requested due to automatic review settings December 30, 2025 05:25
Copy link
Member Author

hyf0 commented Dec 30, 2025


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.

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 refactors ScanStageCache to use the type-safe ModuleId wrapper instead of raw ArcStr for module identification. This improves type safety and makes the code more self-documenting by using a domain-specific type.

Key Changes:

  • Updated ScanStageCache struct fields to use ModuleId instead of ArcStr
  • Changed from RUNTIME_MODULE_KEY string constant to RUNTIME_MODULE_ID typed constant
  • Simplified map operations by leveraging ModuleId directly from ResolvedId

Reviewed changes

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

File Description
crates/rolldown/src/types/scan_stage_cache.rs Updated field types from ArcStr to ModuleId for module_id_to_idx and user_defined_entry; added FIXME comment about API improvement
crates/rolldown/src/module_loader/module_loader.rs Replaced string-based operations with ModuleId; refactored runtime module initialization to use Entry API; simplified map insertions
crates/rolldown/src/module_loader/deferred_scan_data.rs Updated function signature to accept ModuleId instead of ArcStr; converted string to ModuleId for lookups

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

Copy link
Member Author

hyf0 commented Dec 30, 2025

Merge activity

  • Dec 30, 5:39 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Dec 30, 5:50 AM UTC: hyf0 added this pull request to the Graphite merge queue.
  • Dec 30, 5:56 AM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.
  • Dec 30, 8:04 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Dec 30, 8:04 AM UTC: hyf0 added this pull request to the Graphite merge queue.
  • Dec 30, 8:14 AM UTC: Merged by the Graphite merge queue.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Benchmarks Rust

  • target: main(6399853)
  • pr: 12-30-refactor_rust_use_moduleid_instead_of_raw_arcstr_for_scanstagecache_(535c126)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     64.5±2.27ms        ? ?/sec    1.04     67.1±2.23ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     70.2±1.45ms        ? ?/sec    1.06     74.3±3.07ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    107.5±2.46ms        ? ?/sec    1.01    108.0±2.04ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    119.7±2.34ms        ? ?/sec    1.01    120.3±2.15ms        ? ?/sec
bundle/bundle@threejs                                        1.01     41.1±2.36ms        ? ?/sec    1.00     40.8±2.03ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     43.6±0.71ms        ? ?/sec    1.01     44.1±0.92ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    404.6±7.35ms        ? ?/sec    1.00    404.8±8.64ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.01    460.0±6.55ms        ? ?/sec    1.00    456.5±5.61ms        ? ?/sec
scan/scan@rome_ts                                            1.00     84.0±1.59ms        ? ?/sec    1.01     84.6±1.79ms        ? ?/sec
scan/scan@threejs                                            1.04     29.5±1.78ms        ? ?/sec    1.00     28.5±0.43ms        ? ?/sec
scan/scan@threejs10x                                         1.00    300.0±5.60ms        ? ?/sec    1.00    299.4±5.02ms        ? ?/sec

@graphite-app graphite-app bot changed the base branch from hyf_32948902384 to graphite-base/7701 December 30, 2025 05:45
@graphite-app graphite-app bot changed the base branch from graphite-base/7701 to main December 30, 2025 05:55
@hyf0 hyf0 force-pushed the 12-30-refactor_rust_use_moduleid_instead_of_raw_arcstr_for_scanstagecache_ branch from 9a8e2b1 to 535c126 Compare December 30, 2025 06:46
@netlify
Copy link

netlify bot commented Dec 30, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 5e0ea82
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6953879ebd2b710008d7b682

Copilot AI review requested due to automatic review settings December 30, 2025 08:04
@graphite-app graphite-app bot force-pushed the 12-30-refactor_rust_use_moduleid_instead_of_raw_arcstr_for_scanstagecache_ branch from 535c126 to 5e0ea82 Compare December 30, 2025 08:04
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 5e0ea82 into main Dec 30, 2025
33 checks passed
@graphite-app graphite-app bot deleted the 12-30-refactor_rust_use_moduleid_instead_of_raw_arcstr_for_scanstagecache_ branch December 30, 2025 08:14
// merge module_table, index_ast_scope, index_ecma_ast
for (new_idx, new_module) in modules {
let idx = self.module_id_to_idx[new_module.id_clone()].idx();
// FIXME: hyf0 should get `ModuleId` directly from `Module` instead of calling `ModuleId::new`
Copy link
Member Author

Choose a reason for hiding this comment

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

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 <[email protected]>
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

Comments