Repository navigation
fix(transform): transformer gate skips newer syntax that oxc can lower - #10564
Conversation
bfcad53 to
aae9ade
Compare
aae9ade to
2334259
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
…ture `should_transform_js` named two ES features, so it answered correctly only where those two happened to subsume the rest. That is what let `using` declarations through on an `es2024` target, and any future oxc lowering reopens the same hole. Decide it from `LOWERABLE_ES_FEATURES` instead — the full set oxc's `impl From<EngineTargets> for EnvOptions` turns into transform flags. The ES2025 RegExp features stay out on purpose: oxc knows them but cannot lower them, so listing them would buy a transform pass that cannot change anything. Precompute the answer in the constructors. The widened list walks oxc's static feature table once per entry (a `OnceLock` load, a hash into the feature map, then a lookup per engine in it) and `PreProcessEcmaAst` reads it once per JS module, so computing it on demand is no longer cheap. `tests::env_lowers_anything` destructures `EnvOptions` and every ES-edition group exhaustively, so an oxc upgrade that adds a group stops compiling until the list is revisited. `RegExpOptions` lives in a private oxc module and cannot be named in a pattern, so its flags are read field by field and a brand new RegExp lowering would still slip past. Two fixtures cover what the es2024 one cannot: `chrome133` for the engine target path (it ships unicode-sets RegExp but not `using`, and engine targets do not reduce to a single ES version), and `tsconfig: false` for the `Normal` transform-options variant — tsconfig defaults to auto-discovery, so every other fixture exercises `Raw`.
✅ Deploy Preview for rolldown-rs canceled.
|
|
I’ll make a few small changes directly on your branch to avoid unnecessary back-and-forth and help move this forward more efficiently. |
|
Nice find — this is a real bug, and the reasoning in the description holds up. I checked the chain you assert: I also confirmed your fixture is a genuine regression test: reverting only Since maintainer edits are on, I pushed one commit (000d621) rather than round-tripping review comments. Happy to drop or rework any of it — details below. 1. Derive the gate from every lowerable featureThe two-feature check is correct today, but only by accident of ordering: unicode-sets is ES2024, so for pure ES targets it subsumes every older lowering, and ERM is the newest thing oxc can lower. It now derives from The guard against this rotting again is Verified the test bites: dropping 2. Precompute itTwo reasons. The widened list walks oxc's static feature table once per entry — a It is now a 3. Two more fixturesOne correction to something I initially got wrong: Also added Both are genuine regression tests — with the pre-PR gate restored, all three fixtures emit raw Verification
Two notes, neither blockingThe description has an inverted sentence. "Check whether the target supports Explicit Resource Management" — An upstream gap worth knowing about: |
|
I appreciate your sincere comments and ongoing feedback. I just revised the sentences. I apologize for not addressing the meaning clearly. I was also aware of the fragility of the feature enumeration — I went with minimal hardcoding because oxc has no API to ask whether a target needs any lowering. On the Safari gap: I had run into the same thing while verifying the oxc compat data — the ES2026ExplicitResourceManagement entry has no Safari/iOS, and it's still missing on oxc's latest main. It took time as I'm not get used to express something in English. |
|
@IWANABETHATGUY oxc-project/oxc#25155 I just checked the PR you opened on oxc. Seems I was a bit late this time. Thanks a lot. |
And don't read the extra commits as a knock on the PR. You found a real bug, diagnosed the cause correctly, and your instincts were right on both counts — that the enumeration was fragile, and that oxc's compat data was missing Safari. That's the hard part. Nice work. |
… exists The three `using` fixtures added in #10564 sit as siblings under `function/`, distinguished only by a suffix on the directory name, and the first carries no `_comment` — `"target": "es2024"` alone does not convey why that target in particular. Nest them under one group, following the `advanced_chunks/` convention where the parent is a plain directory with no `_config.json` of its own, and name each leaf after the case it pins rather than after how it differs from its neighbour: explicit_resource_management_target/ es2024/ the ES-target gap the old gate fell through chrome133/ engine targets, which do not reduce to one ES version es2024_no_tsconfig/ the `Normal` transform-options variant Each leaf gets a `_comment` explaining what it covers. Snapshots are unchanged — their contents do not encode the fixture path.
… exists (#10569) Test-only follow-up to #10564. No source changes, and the snapshots are byte-identical — their contents do not encode the fixture path. ## What The three `using` fixtures added in #10564 sat as siblings under `function/`, told apart only by a suffix on the directory name: ``` explicit_resource_management_target/ explicit_resource_management_target_chrome/ explicit_resource_management_target_no_tsconfig/ ``` They are now one group, following the `advanced_chunks/` convention where the parent is a plain directory with no `_config.json` of its own, with each leaf named after the case it pins rather than after how it differs from its neighbour: ``` explicit_resource_management_target/ es2024/ the ES-target gap the old gate fell through chrome133/ engine targets, which do not reduce to one ES version es2024_no_tsconfig/ the `Normal` transform-options variant ``` ## Why Two things the old layout left implicit. The `es2024` fixture carried no `_comment`, and `"target": "es2024"` alone does not explain why *that* target. It is the one that exposed the bug: unicode-sets RegExp is supported from es2024 on, so a gate keyed on that single feature concluded "nothing left to lower" — while `using` is not supported until es2026 and does need lowering. Without the fix it emits `using resource = acquireResource();` unchanged. The `_no_tsconfig` comment said the variant differs from "every other fixture", which was true while the three were scattered and misleading once they are siblings. It now names what it actually pins: the same `es2024` target on the `Normal` options variant, since `tsconfig` defaults to auto-discovery and puts the other two on `Raw`. Each leaf now carries a `_comment` saying what it covers. ## Test plan - `cargo test -p rolldown --test integration` — 1971 passed, 0 failed - The three fixtures pass at their new paths; no snapshot regeneration was needed
## [1.2.2] - 2026-08-03 ### 🚀 Features - code-splitting: support inlining of shared deps in dynamic entries (#10526) by @nicolo-ribaudo - plugin: time the user callbacks configured on the options (#10509) by @IWANABETHATGUY ### 🐛 Bug Fixes - dev: force `cleanDir` off in dev mode (#10579) by @shulaoda - dev: keep `?rolldown-lazy` proxy ids out of user `resolveId` hooks (#10580) by @btea - initialize re-exported wrapped ESM modules at the entry chunk (#10567) by @hyfdev - link: resolve circular star reexports as null (#10445) by @Nic-Polumeyv - transform: transformer gate skips newer syntax that oxc can lower (#10564) by @sekyungk - code-splitting: materialize consumer-local barrel routing when the order-wrap plan is empty (#10544) by @hyfdev - plugin: measure plugin hooks in JavaScript, report them from Rust (#10508) by @IWANABETHATGUY - plugin: include external dynamic imports in chunk metadata (#10557) by @hyfdev - plugin: report plugin timings after closeBundle has run (#10521) by @IWANABETHATGUY - browser: avoid using node builtin modules (#10542) by @sapphi-red ### 🚜 Refactor - plugin: give the build's own clocks their own type (#10520) by @shulaoda ### 📚 Documentation - correct stale `buildStart` comment in `ScanStageCache::merge` (#10577) by @shulaoda - update outdated pluginutils references (#10574) by @dogledogle ### ⚡ Performance - external: drop the runtime import from chunks that never wrap (#10517) by @IWANABETHATGUY - plugin: clock the build only when it is being measured (#10558) by @IWANABETHATGUY ### 🧪 Testing - vite-tests: drop the dead `@rolldown/pluginutils` pnpm override (#10575) by @IWANABETHATGUY - transform: group the transform-target fixtures and say why each exists (#10569) by @IWANABETHATGUY - dev: fix hmr-hot-update-hook-vite fixture on Windows (#10565) by @h-a-n-a - dev: match Vite's renamed full-reload log (#10547) by @shulaoda ### ⚙️ Miscellaneous Tasks - deps: update napi (#10576) by @renovate[bot] - deps: bump `@napi-rs/wasm-runtime` to 1.2.2 (#10570) by @shulaoda - deps: update npm packages (#10583) by @renovate[bot] - deps: update dependency rolldown-plugin-dts to ^0.28.0 (#10588) by @renovate[bot] - deps: update taiki-e/install-action action to v2.85.5 (#10587) by @renovate[bot] - deps: update codspeedhq/action action to v5 (#10584) by @renovate[bot] - deps: update github actions (#10582) by @renovate[bot] - deps: update rust crates (#10581) by @renovate[bot] - deps: update dependency vite-plus to v0.2.7 (#10568) by @renovate[bot] - deps: update dependency rolldown-plugin-dts to v0.27.14 (#10531) by @renovate[bot] - deps: update pnpm to v11.17.0 (#10571) by @renovate[bot] - deps: update @napi-rs/wasm-runtime to 1.2.1 (#10545) by @sapphi-red ### ❤️ New Contributors * @sekyungk made their first contribution in [#10564](#10564) * @nicolo-ribaudo made their first contribution in [#10526](#10526) Co-authored-by: shulaoda <[email protected]>
Summary
usingdeclarations).should_transform_js(). ItsNormal/Rawarms always returned the same result. Now it checksself.targetdirectly.Problem
should_transform_js()only checked whether the target needed Unicode Sets RegExp transformed. Targets such as Chrome 133 support Unicode Sets RegExp but not Explicit Resource Management, so the transformer never ran andusingdeclarations were emitted unchanged. To fix this, it now also checks whether the target needs Explicit Resource Management lowered.Along the way,
should_transform_js()itself is cleaned up. The env flags that theNormalvariant used to read are computed from the sametargetby oxc'sEnvOptions::from(EngineTargets)viahas_feature(), so they always agree with theRawvariant'sself.target.has_feature()checks by construction (tsconfig merging never touchestarget). The per-variant branching is replaced with a single expression overself.target.The new es2024 fixture verifies that
usingis lowered through the default build path.AI usage
Drafted with Codex and double-checked with Claude. I reviewed and verified all changes myself.