feat(transform): run React Compiler as a pre-transform pass#9671
Conversation
|
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.
How to use the Graphite Merge QueueAdd 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. |
7eed539 to
8371021
Compare
04849da to
5cfff49
Compare
8371021 to
fdc4298
Compare
✅ Deploy Preview for rolldown-rs canceled.
|
c3a5bf0 to
eb4729c
Compare
eb4729c to
1137df7
Compare
|
rolldown/crates/rolldown_binding/src/transform.rs Lines 42 to 48 in 1137df7 rolldown/crates/rolldown_common/src/utils/enhanced_transform.rs Lines 261 to 266 in 1137df7 rolldown/crates/rolldown_common/src/utils/enhanced_transform.rs Lines 393 to 400 in 1137df7 |

Run the React Compiler as a standalone pre-transform pass, before any other transform (define, TS/JSX lowering, DCE) runs, on the pristine AST.
Enabled via
transform: { reactCompiler: true | ReactCompilerOptions }.Where it runs
The compiler runs in the same position (first, before JSX lowering) across all three entry points, so bundled and unbundled (Vite dev) builds behave identically:
crates/rolldown/src/utils/pre_process_ecma_ast.rs(Step 1.5), rebuilding scoping for the downstream transformer.crates/rolldown_plugin_vite_transform/src/lib.rs, between semantic build and theTransformer.react_compileris threaded throughBundlerTransformOptionsso it is exposed to the Vite transform plugin.Notes
oxc::transformer::TransformOptions; it is a separate pass, so it is threaded through separately and pulled out before the per-file options are consumed.transform()API (EnhancedTransformOptions) does not expose React Compiler yet.jsxonly acceptspreserveas a string preset (Vite passes a resolved jsx options object); the bundler additionally accepts thereact-jsxstring shorthand.Tests
transform/react-compiler— bundler pathbuiltin-plugin/ecma-transform/react-compiler— Vite transform plugin path🤖 Generated with Claude Code