Repository navigation
fix(generator): filter DISABLE_JS_HOOK bits from generated HookUsage - #10346
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_bf4614d1-491b-46df-b45b-4dea89f6b64e) |
✅ Deploy Preview for rolldown-rs canceled.
|
Merging this PR will not alter performance
Comparing Footnotes
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_8fc50dfb-3fdb-4eb6-94ae-f036361ca674) |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Merge activity
|
6ed07d3 to
54c0c8c
Compare
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-hook-usage-skip-disabled-js-hooks-rolldown-rs.voidzero-docs.workers.dev (commit 37f4b00)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
…10346) ### Summary Extracted from #10268 as a standalone fix (part of the breakup of that PR). The generated TS `HookUsageKind` enum included `transformAst` even though `transform_ast` is listed in `DISABLE_JS_HOOK` and can never be registered from a JS plugin (`extractHookUsage` already skipped it). The TS enum and the Rust `HookUsage` bitflags share one bit sequence: the binding reads the number from `extractHookUsage(plugin).inner()` with `HookUsage::from_bits` (`crates/rolldown_binding/src/options/plugin/js_plugin.rs`). So the generator now gives hooks in `DISABLE_JS_HOOK` the highest bits. The TS enum drops `transformAst` and stays contiguous (`banner = 1 << 16` … `hotUpdate = 1 << 21`), Rust moves `TransformAst` to `1 << 22`, and every shared hook keeps the same bit on both sides. ### Changes - `tasks/generator/src/generators/hook_usage.rs`: one `hook_bit_order()` (JS-registrable hooks in `HOOK_KIND` order, then the `DISABLE_JS_HOOK` ones) feeds both emitters. The TS enum and `extractHookUsage` use its JS prefix; the Rust bitflags use the whole order. `DISABLE_JS_HOOK` stays the single source of truth. A unit test checks that the TS enum holds no disabled hook, its bits run from `1 << 0` with no gap, every TS member has the same bit as the Rust flag of the same hook, and the disabled hooks hold the highest Rust bits. - `tasks/generator/Cargo.toml`: `[lib] test = true` so the unit test runs. - `packages/rolldown/src/plugin/generated/hook-usage.ts`, `crates/rolldown_plugin/src/generated/hook_usage.rs`: regenerated with `cargo run --bin generator`. Rust code uses the flags by name only (`HookUsage::Banner`, …); no bit value is stored anywhere, so renumbering both sides together changes nothing at runtime. The JS package and its binding always ship from the same build. The files land together because CI's repo-validation job re-runs the generator and fails on drift. ### Verification - `cargo test -p generator --lib`: 1 passed. Making the Rust emitter use plain `HOOK_KIND` order instead fails it (`banner` differs between TS and Rust). - `cargo run --bin generator` twice, then `git diff`: no drift (regeneration is idempotent) - `cargo clippy -p generator -p rolldown_plugin --all-targets -- -D warnings`, `cargo fmt --check`, `just lint-repo`: clean - `cargo test -p rolldown_plugin`: 8 passed - `just build-rolldown`, then `pnpm run test:main` in `packages/rolldown/tests`: 55 files, 1228 passed, 15 skipped - End-to-end check with the native binding: a JS plugin with `banner`, `footer` and `hotUpdate` under `dev({ hotUpdate: true })` gets all three called. With the old TS bit values swapped into the built JS, `banner` and `hotUpdate` are no longer called, and the `plugin/banner` fixture fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T34fMrYCf2V13Mg8BKmnda
54c0c8c to
37f4b00
Compare
## [1.2.13] - 2026-10-07 ### 🚀 Features - rolldown_plugin_vite_import_glob: follow file creation and deletion via hotUpdate (#10550) by @shulaoda - inline-common-chunks: deduplicate shared code along known loading paths (#11093) by @hyfdev - rolldown_plugin_vite_import_glob: record a matcher per glob call in dev (#10592) by @shulaoda - rolldown_plugin_vite_import_glob: watch the directory each glob reads (#10549) by @shulaoda - watch: hand watch.exclude to notify as its ignore filter (#11008) by @shulaoda - dev: add `experimental.devMode.hotUpdate` option (#11123) by @h-a-n-a ### 🐛 Bug Fixes - renamer: check the printed name of namespace-alias imports for captures (#11129) by @IWANABETHATGUY - devtools: honor `devtools.sessionId` by @Brooooooklyn - renamer: keep a renamed nested binding off its module's top-level bindings (#11128) by @IWANABETHATGUY - dev: keep `this` undefined when calling an imported function in HMR patches and lazy chunks (#11126) by @h-a-n-a - dev: read string-named imports correctly in HMR patches and lazy chunks (#11127) by @h-a-n-a - sanitize preserveModules chunk names after resolving the relative path (#11087) by @waltuov - keep the `with` clause on bare external imports (#11100) by @IWANABETHATGUY - generator: filter DISABLE_JS_HOOK bits from generated HookUsage (#10346) by @Brooooooklyn - dev: make the module factory async for top-level await (#11118) by @h-a-n-a - node: give each renderChunk call its own meta object (#11115) by @Brooooooklyn - honor `externalLiveBindings` for imported exports (#11048) by @camc314 - dev: keep a late payload from replacing newer module code (#11030) by @h-a-n-a - binding: use-after-free in async `transform` with a `TsconfigCache` (#11080) by @shulaoda - fail on chunk syntax errors and escape export names once (#11051) by @hyfdev - dev: ship newly imported modules the client never received (#11029) by @h-a-n-a - code-splitting: avoid cycles from redundant re-export initialization (#11073) by @hyfdev - link: treat re-exports of the same external binding as one export (#11069) by @IWANABETHATGUY - escape namespace properties in IIFE and UMD output (#11085) by @hyfdev - escape dependency paths in CJS and UMD output (#11084) by @hyfdev - use computed access for arbitrary import names (#11083) by @hyfdev - generate valid bindings for shimmed exports (#11082) by @hyfdev - dev: reload the page when an HMR update fails after merging its edit (#11031) by @h-a-n-a - dev/lazy: ship the deps of a module that a patch shipped but never ran (#11028) by @h-a-n-a - code-splitting: don't move init calls in front of unwrapped JSON modules (#11062) by @IWANABETHATGUY - escape export names in `defineProperty` calls (#11047) by @camc314 ### 📚 Documentation - say the CLI bundles multiple configs one after another (#11111) by @Brooooooklyn - add `renderChunk` hook filter docs (#11065) by @sapphi-red ### ⚡ Performance - use `concat_string!` instead of `format!` for plain string joins (#11139) by @IWANABETHATGUY - utils: evaluate each `concat_string!` argument once (#11105) by @IWANABETHATGUY - json: escape `JSON.parse` string with `json-escape-simd` (#11104) by @IWANABETHATGUY - unwrap JSON modules with a non-object root (#11066) by @IWANABETHATGUY ### 🧪 Testing - inline-common-chunks: fix flaky inlineCommonChunks concurrent imports (#11088) by @hyfdev ### ⚙️ Miscellaneous Tasks - deps: upgrade oxc to 0.153.0 (#11109) by @camc314 - update pnpm to v12 (#10876) by @btea - deps: update pnpm to v11.28.0 (#11049) by @renovate[bot] - deps: update rollup submodule for tests to v4.64.0 (#11116) by @rolldown-guard[bot] - deps: update napi (#11137) by @renovate[bot] - scripts: spawn the rolldown CLI without a shell in setup-vite (#10875) by @Brooooooklyn - deps: bump `@napi-rs/wasm-runtime` to `~1.2.5` (#11117) by @shulaoda - deps: update napi (#11108) by @renovate[bot] - deps: update taiki-e/install-action action to v2.87.22 (#11096) by @renovate[bot] - deps: update npm packages (#11095) by @renovate[bot] - deps: update rust crates (#11097) by @renovate[bot] - deps: update napi (#11063) by @renovate[bot] - deps: update dependency rust to v1.99.0 (#11071) by @renovate[bot] - deps: update dependency vite-plus to v1 (#11056) by @renovate[bot] Co-authored-by: shulaoda <[email protected]>
Summary
Extracted from #10268 as a standalone fix (part of the breakup of that PR).
The generated TS
HookUsageKindenum includedtransformAsteven thoughtransform_astis listed inDISABLE_JS_HOOKand can never be registered from a JS plugin (extractHookUsagealready skipped it).The TS enum and the Rust
HookUsagebitflags share one bit sequence: the binding reads the number fromextractHookUsage(plugin).inner()withHookUsage::from_bits(crates/rolldown_binding/src/options/plugin/js_plugin.rs). So the generator now gives hooks inDISABLE_JS_HOOKthe highest bits. The TS enum dropstransformAstand stays contiguous (banner = 1 << 16…hotUpdate = 1 << 21), Rust movesTransformAstto1 << 22, and every shared hook keeps the same bit on both sides.Changes
tasks/generator/src/generators/hook_usage.rs: onehook_bit_order()(JS-registrable hooks inHOOK_KINDorder, then theDISABLE_JS_HOOKones) feeds both emitters. The TS enum andextractHookUsageuse its JS prefix; the Rust bitflags use the whole order.DISABLE_JS_HOOKstays the single source of truth. A unit test checks that the TS enum holds no disabled hook, its bits run from1 << 0with no gap, every TS member has the same bit as the Rust flag of the same hook, and the disabled hooks hold the highest Rust bits.tasks/generator/Cargo.toml:[lib] test = trueso the unit test runs.packages/rolldown/src/plugin/generated/hook-usage.ts,crates/rolldown_plugin/src/generated/hook_usage.rs: regenerated withcargo run --bin generator.Rust code uses the flags by name only (
HookUsage::Banner, …); no bit value is stored anywhere, so renumbering both sides together changes nothing at runtime. The JS package and its binding always ship from the same build.The files land together because CI's repo-validation job re-runs the generator and fails on drift.
Verification
cargo test -p generator --lib: 1 passed. Making the Rust emitter use plainHOOK_KINDorder instead fails it (bannerdiffers between TS and Rust).cargo run --bin generatortwice, thengit diff: no drift (regeneration is idempotent)cargo clippy -p generator -p rolldown_plugin --all-targets -- -D warnings,cargo fmt --check,just lint-repo: cleancargo test -p rolldown_plugin: 8 passedjust build-rolldown, thenpnpm run test:maininpackages/rolldown/tests: 55 files, 1228 passed, 15 skippedbanner,footerandhotUpdateunderdev({ hotUpdate: true })gets all three called. With the old TS bit values swapped into the built JS,bannerandhotUpdateare no longer called, and theplugin/bannerfixture fails.🤖 Generated with Claude Code
https://claude.ai/code/session_01T34fMrYCf2V13Mg8BKmnda