Skip to content

refactor: use NormalizedId to ensure consistent behavior for id#7688

Closed
hyf0 wants to merge 1 commit intomainfrom
12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id
Closed

refactor: use NormalizedId to ensure consistent behavior for id#7688
hyf0 wants to merge 1 commit intomainfrom
12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Dec 29, 2025

NormalizedId is a temporary abstraction to represent normalized resolved id, but if we call it NormalizedResolvedId, it may confuse with ResolvedId.

Copy link
Member Author

hyf0 commented Dec 29, 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.

@hyf0 hyf0 marked this pull request as ready for review December 29, 2025 07:49
Copilot AI review requested due to automatic review settings December 29, 2025 07:49
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 introduces a new NormalizedId type to ensure consistent handling of module identifiers across the codebase. The key change is wrapping the id field in ResolvedId with NormalizedId, which automatically normalizes Windows paths by converting backslashes to forward slashes for absolute paths.

Key changes:

  • New NormalizedId type that wraps ArcStr and performs path normalization on Windows
  • Refactored ResolvedId.id from ArcStr to NormalizedId
  • Updated all usages throughout the codebase to work with the new type using .as_str() and .as_arc_str() accessor methods

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rolldown_common/src/types/normalized_id.rs New type definition for NormalizedId with Windows path normalization logic and trait implementations
crates/rolldown_common/src/types/mod.rs Adds the new normalized_id module to exports
crates/rolldown_common/src/lib.rs Exports NormalizedId for public use
crates/rolldown_common/src/types/resolved_id.rs Changes id field type from ArcStr to NormalizedId, updates usages to call .as_str()
crates/rolldown_resolver/src/resolver.rs Wraps resolved path with NormalizedId::new() when creating ResolvedId
crates/rolldown_plugin/src/utils/resolve_id_with_plugins.rs Updates all ResolvedId constructions to use NormalizedId::new()
crates/rolldown_plugin/src/utils/resolve_id_check_external.rs Wraps external IDs with NormalizedId::new()
crates/rolldown_plugin/src/types/hook_resolve_id_output.rs Accesses id via .as_arc_str().clone() instead of direct field access
crates/rolldown_plugin/src/plugin_context/native_plugin_context.rs Wraps specifier with NormalizedId::new() when creating ResolvedId
crates/rolldown_plugin_vite_import_glob/src/utils.rs Converts resolved_id.id to string using .to_string() instead of .into()
crates/rolldown_plugin_vite_import_glob/src/utils_2.rs Converts resolved_id.id to string using .to_string() instead of .into()
crates/rolldown/src/module_loader/resolve_utils.rs Updates all ID accesses to use .as_str() or .as_arc_str().clone()
crates/rolldown/src/module_loader/runtime_module_task.rs Wraps runtime module ID with NormalizedId::new()
crates/rolldown/src/module_loader/module_task.rs Updates ID accesses to use .as_str() or .as_arc_str().clone()
crates/rolldown/src/module_loader/module_loader.rs Updates all map lookups and insertions to use .as_str() or .as_arc_str().clone()
crates/rolldown/src/module_loader/external_module_task.rs Adds explicit type annotation for ArcStr and uses accessor methods
crates/rolldown/src/ecmascript/ecma_module_view_factory.rs Uses .as_str() when creating ModuleId
crates/rolldown/tests/rolldown/plugin/plugin_context/custom_arg_in_resolve/mod.rs Uses .as_str() for string comparison in test

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

@@ -0,0 +1,50 @@
// This's a temporary abstraction to represent `normalized` resolved id, but if we call it `NormalizedResolvedId`, it may confuse with `ResolvedId`.
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

The comment contains a grammatical error. "This's" should be "This is".

Suggested change
// This's a temporary abstraction to represent `normalized` resolved id, but if we call it `NormalizedResolvedId`, it may confuse with `ResolvedId`.
// This is a temporary abstraction to represent `normalized` resolved id, but if we call it `NormalizedResolvedId`, it may confuse with `ResolvedId`.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +11
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
pub struct NormalizedId(ArcStr);
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

According to Rust API Guidelines (C-COMMON-TRAITS), common traits should be implemented where applicable. Consider implementing the PartialOrd and Ord traits for NormalizedId since it wraps ArcStr which implements these traits. This would allow NormalizedId instances to be used in contexts that require ordering, such as BTreeMap keys or sorting collections.

Copilot generated this review using guidance from repository custom instructions.
@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

Benchmarks Rust

  • target: main(938617b)
  • pr: 12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id(22353de)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.07     65.9±1.52ms        ? ?/sec    1.00     61.6±1.49ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.09     73.6±1.71ms        ? ?/sec    1.00     67.6±1.09ms        ? ?/sec
bundle/bundle@rome_ts                                        1.02    107.7±2.17ms        ? ?/sec    1.00    105.8±1.55ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.03    121.3±2.81ms        ? ?/sec    1.00    118.1±1.66ms        ? ?/sec
bundle/bundle@threejs                                        1.01     39.6±2.05ms        ? ?/sec    1.00     39.3±2.28ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.03     43.8±0.71ms        ? ?/sec    1.00     42.3±0.57ms        ? ?/sec
bundle/bundle@threejs10x                                     1.02    401.0±6.91ms        ? ?/sec    1.00    393.5±6.55ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    453.3±5.90ms        ? ?/sec    1.00    454.2±8.27ms        ? ?/sec
scan/scan@rome_ts                                            1.00     85.9±1.68ms        ? ?/sec    1.01     86.8±1.93ms        ? ?/sec
scan/scan@threejs                                            1.02     29.1±1.66ms        ? ?/sec    1.00     28.6±0.49ms        ? ?/sec
scan/scan@threejs10x                                         1.00    299.1±5.30ms        ? ?/sec    1.01    301.5±5.60ms        ? ?/sec

@hyf0 hyf0 force-pushed the 12-29-refactor_types_rename_resolved_request_info.rs_to_resolved_id.rs_and_move_its_contents branch from df2b5a8 to 32127bd Compare December 29, 2025 10:58
@hyf0 hyf0 force-pushed the 12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id branch from 3f00fd2 to aaaea8d Compare December 29, 2025 10:58
@graphite-app graphite-app bot changed the base branch from 12-29-refactor_types_rename_resolved_request_info.rs_to_resolved_id.rs_and_move_its_contents to graphite-base/7688 December 29, 2025 11:18
@graphite-app graphite-app bot force-pushed the 12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id branch from aaaea8d to a3db8c3 Compare December 29, 2025 11:32
@graphite-app graphite-app bot force-pushed the graphite-base/7688 branch from 32127bd to 10262da Compare December 29, 2025 11:32
@graphite-app graphite-app bot changed the base branch from graphite-base/7688 to main December 29, 2025 11:33
@graphite-app graphite-app bot force-pushed the 12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id branch from a3db8c3 to cbe5fe8 Compare December 29, 2025 11:33
@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 22353de
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69528130b355d5000873ea9d

Copilot AI review requested due to automatic review settings December 29, 2025 11:55
@hyf0 hyf0 force-pushed the 12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id branch from cbe5fe8 to 30cbc23 Compare December 29, 2025 11:55
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 19 out of 19 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.

@hyf0 hyf0 force-pushed the 12-29-refactor_use_normalizedid_to_ensure_consistent_behavior_for_id branch from 30cbc23 to 22353de Compare December 29, 2025 13:25
@hyf0 hyf0 closed this Dec 30, 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