Skip to content

refactor(rust): remove Module#id_as_str and use Module#id directly#7708

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

refactor(rust): remove Module#id_as_str and use Module#id directly#7708
graphite-app[bot] merged 1 commit intomainfrom
12-30-refactor_rust_remove_module_id_as_str_and_use_module_id_directly

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Dec 30, 2025

No description provided.

Copy link
Member Author

hyf0 commented Dec 30, 2025

@hyf0 hyf0 marked this pull request as ready for review December 30, 2025 08:36
Copilot AI review requested due to automatic review settings December 30, 2025 08:36
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 Module API by removing the id_as_str() method and replacing it with id() that returns &ModuleId instead of &str. This provides better encapsulation and allows callers to access the full ModuleId API when needed.

Key changes:

  • Changed Module::id_as_str() to Module::id() with return type &ModuleId instead of &str
  • Updated all call sites to use .id().as_str() or .id().to_string() as appropriate
  • Simplified code in scan_stage_cache.rs by removing unnecessary ModuleId::new() wrapper

Reviewed changes

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

Show a summary per file
File Description
crates/rolldown_common/src/module/mod.rs Changed method signature from id_as_str() -> &str to id() -> &ModuleId; added ModuleId to imports
crates/rolldown/src/utils/chunk/mod.rs Updated calls to use .id().as_str() for string conversion
crates/rolldown/src/types/scan_stage_cache.rs Simplified by using .id() directly instead of wrapping with ModuleId::new()
crates/rolldown/src/types/generator.rs Updated to use .id().as_str() for debug output
crates/rolldown/src/stages/link_stage/tree_shaking/include_statements.rs Updated tracing call to use .id().to_string()
crates/rolldown/src/stages/link_stage/mod.rs Updated sorting key to use .id().as_str()
crates/rolldown/src/stages/link_stage/bind_imports_and_exports.rs Updated error messages to use .id().to_string()
crates/rolldown/src/stages/generate_stage/mod.rs Updated multiple locations to use .id().as_str() or .id().to_string(); added clippy attribute
crates/rolldown/src/stages/generate_stage/compute_cross_chunk_links.rs Updated debug/panic messages to use .id().as_str()
crates/rolldown/src/module_loader/module_loader.rs Changed to use .id().clone() for owned ModuleId
crates/rolldown/src/module_finalizers/mod.rs Updated to use .id().as_str() for string literal generation
crates/rolldown/src/hmr/hmr_stage.rs Updated sorting and debug output to use .id().as_str()
crates/rolldown/src/chunk_graph.rs Updated module filtering and sorting to use .id().as_str()
crates/rolldown/src/bundle/bundle.rs Updated to use .id().to_string() for module import tracking

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

@hyf0 hyf0 force-pushed the 12-30-refactor_rust_make_externalmodule_id_have_the_type_moduleid_ branch from 22bd4a6 to a21d7f2 Compare December 30, 2025 08:43
@hyf0 hyf0 force-pushed the 12-30-refactor_rust_remove_module_id_as_str_and_use_module_id_directly branch from bcae979 to a84d271 Compare December 30, 2025 08:43
@github-actions
Copy link
Contributor

Benchmarks Rust

  • target: 12-30-refactor_rust_make_externalmodule_id_have_the_type_moduleid_(a21d7f2)
  • pr: 12-30-refactor_rust_remove_module_id_as_str_and_use_module_id_directly(a84d271)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.02     66.2±1.51ms        ? ?/sec    1.00     64.6±1.65ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.01     71.8±1.68ms        ? ?/sec    1.00     71.0±1.71ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    107.9±2.45ms        ? ?/sec    1.00    107.9±2.62ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.01    120.8±2.23ms        ? ?/sec    1.00    119.8±1.90ms        ? ?/sec
bundle/bundle@threejs                                        1.00     39.4±1.32ms        ? ?/sec    1.02     40.3±2.12ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.04     44.7±1.01ms        ? ?/sec    1.00     43.1±0.99ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    390.2±3.90ms        ? ?/sec    1.01    395.6±7.34ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    453.8±4.79ms        ? ?/sec    1.00    455.1±5.42ms        ? ?/sec
scan/scan@rome_ts                                            1.00     84.7±1.70ms        ? ?/sec    1.01     85.1±1.54ms        ? ?/sec
scan/scan@threejs                                            1.00     28.5±1.61ms        ? ?/sec    1.01     28.8±0.44ms        ? ?/sec
scan/scan@threejs10x                                         1.00    288.8±3.86ms        ? ?/sec    1.03    298.8±5.49ms        ? ?/sec

@graphite-app graphite-app bot changed the base branch from 12-30-refactor_rust_make_externalmodule_id_have_the_type_moduleid_ to graphite-base/7708 December 30, 2025 09:21
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 30, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-30-refactor_rust_remove_module_id_as_str_and_use_module_id_directly branch from a84d271 to 11e76ac Compare December 30, 2025 09:37
@graphite-app graphite-app bot changed the base branch from graphite-base/7708 to 12-30-refactor_rust_make_externalmodule_id_have_the_type_moduleid_ December 30, 2025 09:37
Base automatically changed from 12-30-refactor_rust_make_externalmodule_id_have_the_type_moduleid_ to main December 30, 2025 09:47
Copilot AI review requested due to automatic review settings December 30, 2025 14:12
@hyf0 hyf0 force-pushed the 12-30-refactor_rust_remove_module_id_as_str_and_use_module_id_directly branch from 11e76ac to 8bab8c9 Compare December 30, 2025 14:12
@netlify
Copy link

netlify bot commented Dec 30, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 8bab8c9
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6953ddd4e299ab0008d85098

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

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


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

@graphite-app graphite-app bot merged commit 8bab8c9 into main Dec 30, 2025
39 checks passed
@graphite-app graphite-app bot deleted the 12-30-refactor_rust_remove_module_id_as_str_and_use_module_id_directly branch December 30, 2025 14:29
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 <165626830+shulaoda@users.noreply.github.com>
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.

3 participants