Skip to content

refactor(rust): use StableModuleId as the map key if possible#7718

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible
Dec 31, 2025
Merged

refactor(rust): use StableModuleId as the map key if possible#7718
graphite-app[bot] merged 1 commit intomainfrom
12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Dec 30, 2025

No description provided.

Copy link
Member Author

hyf0 commented Dec 30, 2025

@graphite-app graphite-app bot force-pushed the 12-31-refactor_rust_return_stablemoduleid_instead_of_str_from_module_stable_id_ branch from 294029e to be86ee5 Compare December 30, 2025 22:26
@graphite-app graphite-app bot force-pushed the 12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible branch from 229981c to d200918 Compare December 30, 2025 22:26
@graphite-app graphite-app bot force-pushed the 12-31-refactor_rust_return_stablemoduleid_instead_of_str_from_module_stable_id_ branch 2 times, most recently from b29bcdd to 37aa020 Compare December 30, 2025 22:58
@graphite-app graphite-app bot force-pushed the 12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible branch from d200918 to 2fd6ed7 Compare December 30, 2025 22:58
@hyf0 hyf0 force-pushed the 12-31-refactor_rust_return_stablemoduleid_instead_of_str_from_module_stable_id_ branch from 37aa020 to 2ad6b7b Compare December 31, 2025 03:44
@hyf0 hyf0 force-pushed the 12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible branch from 2fd6ed7 to 95e363d Compare December 31, 2025 03:44
Copilot AI review requested due to automatic review settings December 31, 2025 03:50
@hyf0 hyf0 force-pushed the 12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible branch from 95e363d to 49e4638 Compare December 31, 2025 03:50
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 the codebase to use StableModuleId as HashMap keys instead of String, improving type safety and performance. The change leverages the Borrow<str> trait to enable efficient lookups using &str references while storing the more semantically appropriate StableModuleId type.

Key Changes:

  • Removed redundant PartialEq implementations from StableModuleId (now using Borrow<str> for comparisons)
  • Changed module_idx_by_stable_id from FxHashMap<String, ModuleIdx> to FxHashMap<StableModuleId, ModuleIdx>
  • Replaced .to_string() with .clone() when inserting stable IDs (more efficient with ArcStr-backed values)

Reviewed changes

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

File Description
crates/rolldown_common/src/types/stable_module_id.rs Removed PartialEq<str> and PartialEq<&str> trait implementations; added comment explaining Borrow<str> usage
crates/rolldown/src/types/scan_stage_cache.rs Updated HashMap type and insertion calls to use StableModuleId keys with .clone()
crates/rolldown/src/hmr/hmr_stage.rs Updated HashMap lookup to use .as_str() method, leveraging Borrow<str> trait

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

@graphite-app graphite-app bot changed the base branch from 12-31-refactor_rust_return_stablemoduleid_instead_of_str_from_module_stable_id_ to graphite-base/7718 December 31, 2025 03:54
@hyf0 hyf0 force-pushed the 12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible branch from 49e4638 to 8ef466a Compare December 31, 2025 03:54
@hyf0 hyf0 force-pushed the graphite-base/7718 branch from 2ad6b7b to 8359676 Compare December 31, 2025 03:54
@hyf0 hyf0 changed the base branch from graphite-base/7718 to 12-31-refactor_rust_return_stablemoduleid_instead_of_str_from_module_stable_id_ December 31, 2025 03:54
Base automatically changed from 12-31-refactor_rust_return_stablemoduleid_instead_of_str_from_module_stable_id_ to main December 31, 2025 04:05
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 31, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible branch from 8ef466a to e5e2ce7 Compare December 31, 2025 04:05
@netlify
Copy link

netlify bot commented Dec 31, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit e5e2ce7
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6954a1234513e500086064ae

@graphite-app graphite-app bot merged commit e5e2ce7 into main Dec 31, 2025
33 checks passed
@graphite-app graphite-app bot deleted the 12-31-refactor_rust_use_stablemoduleid_as_the_map_key_if_possible branch December 31, 2025 04:18
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