Skip to content

refactor(rust/plugin): use Option<ModuleIdx>::None to represent invalid module idx#8152

Merged
shulaoda merged 1 commit intographite-base/8152from
02-01-refactor_rust_plugin_use_option_moduleidx_none_to_represent_invalid_module_idx
Feb 1, 2026
Merged

refactor(rust/plugin): use Option<ModuleIdx>::None to represent invalid module idx#8152
shulaoda merged 1 commit intographite-base/8152from
02-01-refactor_rust_plugin_use_option_moduleidx_none_to_represent_invalid_module_idx

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Feb 1, 2026

No description provided.

Copy link
Member Author

hyf0 commented Feb 1, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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 February 1, 2026 08:48
Copilot AI review requested due to automatic review settings February 1, 2026 08:48
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 plugin context structs to use Option<ModuleIdx> instead of a bare ModuleIdx to represent cases where no valid module index is available, particularly for NAPI contexts.

Changes:

  • Modified LoadPluginContext and TransformPluginContext to store module_idx as Option<ModuleIdx>
  • Updated all constructor calls to wrap valid module indices with Some() and use None for NAPI contexts
  • Added conditional logic to only track dependencies when a valid module index exists

Reviewed changes

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

File Description
crates/rolldown_plugin/src/plugin_driver/build_hooks.rs Wrapped module_idx arguments with Some() when creating plugin contexts
crates/rolldown_plugin/src/plugin_context/transform_plugin_context.rs Changed module_idx field to Option type and added conditional checks before using it
crates/rolldown_plugin/src/plugin_context/load_plugin_context.rs Changed module_idx field to Option type and added conditional checks before using it
crates/rolldown_binding/src/options/plugin/binding_callable_builtin_plugin.rs Used None for module_idx in NAPI contexts with explanatory comments

@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

Benchmarks Rust

  • target: 01-28-test_dev_add_load-dependencies_test_case(ba58644)
  • pr: 02-01-refactor_rust_plugin_use_option_moduleidx_none_to_represent_invalid_module_idx(931b74c)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     68.8±1.48ms        ? ?/sec    1.01     69.7±1.44ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     75.8±2.24ms        ? ?/sec    1.00     75.8±1.78ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    100.3±2.47ms        ? ?/sec    1.00    100.1±1.72ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    112.0±2.32ms        ? ?/sec    1.00    112.5±2.40ms        ? ?/sec
bundle/bundle@threejs                                        1.03     36.3±2.07ms        ? ?/sec    1.00     35.4±0.43ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     40.6±0.85ms        ? ?/sec    1.00     40.8±1.51ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    368.8±5.21ms        ? ?/sec    1.00    367.7±3.50ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.01    426.6±5.29ms        ? ?/sec    1.00    424.3±4.10ms        ? ?/sec
scan/scan@rome_ts                                            1.01     82.8±1.77ms        ? ?/sec    1.00     81.7±1.81ms        ? ?/sec
scan/scan@threejs                                            1.00     28.2±0.53ms        ? ?/sec    1.03     29.2±1.66ms        ? ?/sec
scan/scan@threejs10x                                         1.01    290.1±4.53ms        ? ?/sec    1.00    288.1±4.65ms        ? ?/sec

@hyf0 hyf0 changed the base branch from 01-28-test_dev_add_load-dependencies_test_case to graphite-base/8152 February 1, 2026 09:27
@hyf0 hyf0 requested a review from shulaoda February 1, 2026 09:27
Copy link
Member Author

hyf0 commented Feb 1, 2026

Merge activity

  • Feb 1, 12:25 PM 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.
  • Feb 1, 12:25 PM UTC: hyf0 added this pull request to the Graphite merge queue.
  • Feb 1, 12:26 PM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.

@shulaoda shulaoda merged commit 2cec7bc into graphite-base/8152 Feb 1, 2026
48 checks passed
@shulaoda shulaoda deleted the 02-01-refactor_rust_plugin_use_option_moduleidx_none_to_represent_invalid_module_idx branch February 1, 2026 13:07
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