Skip to content

refactor(runtime_helper): wrap DependedRuntimeHelperMap in a struct#9215

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-23-refactor_runtime_helper_wrap_dependedruntimehelpermap_in_a_struct
Apr 23, 2026
Merged

refactor(runtime_helper): wrap DependedRuntimeHelperMap in a struct#9215
graphite-app[bot] merged 1 commit intomainfrom
04-23-refactor_runtime_helper_wrap_dependedruntimehelpermap_in_a_struct

Conversation

@IWANABETHATGUY
Copy link
Copy Markdown
Member

@IWANABETHATGUY IWANABETHATGUY commented Apr 23, 2026

Replaces the DependedRuntimeHelperMap type alias ([Vec<StmtInfoIdx>; N]) with a newtype struct that encapsulates the bit-indexing logic, so callsites no longer need to translate a RuntimeHelper into a bit index.

Before

depended_runtime_helper_map[RuntimeHelper::ToEsm.bit_index()].push(stmt_info_idx);

After

depended_runtime_helper_map.push(RuntimeHelper::ToEsm, stmt_info_idx);

Changes

  • tasks/generator/src/generators/runtime_helper.rs — generator emits a newtype pub struct DependedRuntimeHelperMap([Vec<StmtInfoIdx>; N]) with inherent methods:
    • push(helper: RuntimeHelper, stmt_info_idx: StmtInfoIdx) — wraps the old index lookup.
    • iter() yields (RuntimeHelper, &Vec<StmtInfoIdx>) pairs, so callers no longer need the RuntimeHelper::from_bits(1 << index as u32).unwrap() round-trip.
    • debug_print() moved from the old DependedRuntimeHelperMapExt trait onto the struct directly.
    • Derives Debug + Default + Clone to match the prior type alias's auto-implementations.
  • crates/rolldown_common/src/lib.rs — drops the DependedRuntimeHelperMapExt re-export.
  • crates/rolldown/src/stages/link_stage/reference_needed_symbols.rs — all 10 map[Helper.bit_index()].push(idx) sites now use map.push(Helper, idx).
  • crates/rolldown/src/stages/link_stage/tree_shaking/include_statements.rs — the enumerate() + from_bits(1 << index as u32) pattern is replaced with for (helper, stmt_info_idxs) in module.depended_runtime_helper.iter(), and the #[expect(clippy::cast_possible_truncation)] is no longer needed.

Verification

  • cargo check -p rolldown -p rolldown_common --tests — clean.
  • cargo clippy -p rolldown -p rolldown_common --all-targets -- -D warnings — clean.
  • Rolldown lib unit tests: 53 pass.
  • Integration fixtures issues/5930, issues/7115, issues/7233 — no snapshot drift, confirming the refactor is behaviourally equivalent.

Copy link
Copy Markdown
Member Author

IWANABETHATGUY commented Apr 23, 2026


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.

@graphite-app graphite-app Bot changed the base branch from 04-23-refactor_docs_wording to graphite-base/9215 April 23, 2026 05:23
@graphite-app graphite-app Bot force-pushed the graphite-base/9215 branch from 4ee5324 to ac63d43 Compare April 23, 2026 05:24
@graphite-app graphite-app Bot force-pushed the 04-23-refactor_runtime_helper_wrap_dependedruntimehelpermap_in_a_struct branch from 181ecf0 to 00b8d74 Compare April 23, 2026 05:24
@graphite-app graphite-app Bot changed the base branch from graphite-base/9215 to main April 23, 2026 05:25
@graphite-app graphite-app Bot force-pushed the 04-23-refactor_runtime_helper_wrap_dependedruntimehelpermap_in_a_struct branch from 00b8d74 to 12fe8d7 Compare April 23, 2026 05:25
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 23, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit a71934b
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69e9aefe8430e10008a7de9b

Copy link
Copy Markdown
Member Author

IWANABETHATGUY commented Apr 23, 2026

Merge activity

  • Apr 23, 5:28 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.
  • Apr 23, 5:31 AM UTC: IWANABETHATGUY added this pull request to the Graphite merge queue.
  • Apr 23, 5:34 AM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Repo Validation', 'Rust Validation', 'Docs Validation', 'Node Validation', 'Detect Changes', 'Spell Check', 'Pluginutils Test', 'Vite Test Windows').
  • Apr 23, 5:35 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.
  • Apr 23, 5:37 AM UTC: The merge label 'graphite: merge-when-ready' was removed. This PR will no longer be merged by the Graphite merge queue
  • Apr 23, 5:45 AM UTC: IWANABETHATGUY added this pull request to the Graphite merge queue.
  • Apr 23, 5:45 AM UTC: Merged by the Graphite merge queue.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 23, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing 04-23-refactor_runtime_helper_wrap_dependedruntimehelpermap_in_a_struct (12fe8d7) with main (ec0950b)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (ac63d43) during the generation of this report, so ec0950b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

…9215)

Replaces the `DependedRuntimeHelperMap` type alias (`[Vec<StmtInfoIdx>; N]`) with a newtype struct that encapsulates the bit-indexing logic, so callsites no longer need to translate a `RuntimeHelper` into a bit index.

## Before

```rust
depended_runtime_helper_map[RuntimeHelper::ToEsm.bit_index()].push(stmt_info_idx);
```

## After

```rust
depended_runtime_helper_map.push(RuntimeHelper::ToEsm, stmt_info_idx);
```

## Changes

- **`tasks/generator/src/generators/runtime_helper.rs`** — generator emits a newtype `pub struct DependedRuntimeHelperMap([Vec<StmtInfoIdx>; N])` with inherent methods:
  - `push(helper: RuntimeHelper, stmt_info_idx: StmtInfoIdx)` — wraps the old index lookup.
  - `iter()` yields `(RuntimeHelper, &Vec<StmtInfoIdx>)` pairs, so callers no longer need the `RuntimeHelper::from_bits(1 << index as u32).unwrap()` round-trip.
  - `debug_print()` moved from the old `DependedRuntimeHelperMapExt` trait onto the struct directly.
  - Derives `Debug + Default + Clone` to match the prior type alias's auto-implementations.
- **`crates/rolldown_common/src/lib.rs`** — drops the `DependedRuntimeHelperMapExt` re-export.
- **`crates/rolldown/src/stages/link_stage/reference_needed_symbols.rs`** — all 10 `map[Helper.bit_index()].push(idx)` sites now use `map.push(Helper, idx)`.
- **`crates/rolldown/src/stages/link_stage/tree_shaking/include_statements.rs`** — the `enumerate()` + `from_bits(1 << index as u32)` pattern is replaced with `for (helper, stmt_info_idxs) in module.depended_runtime_helper.iter()`, and the `#[expect(clippy::cast_possible_truncation)]` is no longer needed.

## Verification

- `cargo check -p rolldown -p rolldown_common --tests` — clean.
- `cargo clippy -p rolldown -p rolldown_common --all-targets -- -D warnings` — clean.
- Rolldown lib unit tests: 53 pass.
- Integration fixtures `issues/5930`, `issues/7115`, `issues/7233` — no snapshot drift, confirming the refactor is behaviourally equivalent.
@graphite-app graphite-app Bot force-pushed the 04-23-refactor_runtime_helper_wrap_dependedruntimehelpermap_in_a_struct branch from 12fe8d7 to a71934b Compare April 23, 2026 05:32
@graphite-app graphite-app Bot merged commit a71934b into main Apr 23, 2026
48 of 56 checks passed
@graphite-app graphite-app Bot deleted the 04-23-refactor_runtime_helper_wrap_dependedruntimehelpermap_in_a_struct branch April 23, 2026 05:46
This was referenced Apr 29, 2026
shulaoda added a commit that referenced this pull request Apr 29, 2026
## [1.0.0-rc.18] - 2026-04-29

### 💥 BREAKING CHANGES

- optimization: default unspecified inlineConst.mode to smart (#9248) by @IWANABETHATGUY

### 🐛 Bug Fixes

- rolldown_plugin_vite_import_glob: return error instead of panicking when virtual module uses a relative glob (#9241) by @shulaoda
- binding: treat empty inlineConst object as omitted (#9247) by @IWANABETHATGUY
- rolldown: keep enum declaration for optional-chain access (#9229) by @Dunqing
- link_stage: restore inline let-else in exports-kind filter (#9237) by @IWANABETHATGUY
- dev/lazy: avoid module reinitialization in lazy compilation patches (#9179) by @h-a-n-a
- dev: visit identifier references for runtime rewrites in HMR finalizer (#9191) by @h-a-n-a
- chunk-optimizer: pick dominator for runtime placement to avoid cycles (#9164) by @IWANABETHATGUY
- make `this.emitFile` chunk path synchronous to avoid deadlock (#9031) by @lazarv
- use sentinel id for `browser: false` ignored modules (#9192) by @shulaoda
- prevent chunk optimizer from creating import cycles (#9228) by @IWANABETHATGUY

### 🚜 Refactor

- replace tokio::sync::Mutex with std::sync::Mutex for non-IO data (#9176) by @shulaoda
- rolldown_plugin_vite_import_glob: do not rewrite import path for absolute base (#9195) by @shulaoda
- runtime_helper: wrap DependedRuntimeHelperMap in a struct (#9215) by @IWANABETHATGUY
- drop redundant clear() in determine_safely_merge_cjs_ns (#9206) by @IWANABETHATGUY
- clean up generate_lazy_export (#9208) by @IWANABETHATGUY
- bitset: return bool from set_bit to fuse guard-and-set (#9207) by @IWANABETHATGUY
- link_stage: simplify exports-kind filter and clarify safety comments (#9205) by @IWANABETHATGUY

### 📚 Documentation

- determine_module_exports_kind (#9252) by @IWANABETHATGUY
- fix dead link to esbuild ESM/CJS interop tests (#9230) by @Copilot
- remove CSS bundling references (#9234) by @shulaoda
- correct IncrementalFullBuild row in BundleMode table (#9214) by @IWANABETHATGUY
- design: add bundler data lifecycle design doc (#9212) by @hyf0
- remove minifier alpha status notices (#9202) by @sapphi-red

### ⚙️ Miscellaneous Tasks

- upgrade oxc to 0.128.0 (#9260) by @shulaoda
- deps: bump rolldown-ariadne to 0.6.0 (#9254) by @IWANABETHATGUY
- deps: update github actions (#9259) by @renovate[bot]
- deps: update github actions (#9258) by @renovate[bot]
- remove renovate overrides (#9257) by @Boshen
- use ubuntu-latest for security workflow (#9256) by @Boshen
- notify Discord around release publish (#9251) by @Boshen
- add release environment to npm publish workflow (#9250) by @Boshen
- justfile: drop the `--` separator before forwarded args in `vp run` (#9246) by @shulaoda
- deps: update test262 submodule for tests (#9243) by @sapphi-red
- add more tracing instrumentations (#9220) by @sapphi-red
- rolldown_plugin_vite_import_glob: remove outdated sourcemap doc comment (#9213) by @shulaoda
- update security workflow (#9201) by @Boshen

### ❤️ New Contributors

* @lazarv made their first contribution in [#9031](#9031)

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
@rolldown-guard rolldown-guard Bot mentioned this pull request Apr 29, 2026
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