Skip to content

feat(transform): run React Compiler as a pre-transform pass#9671

Draft
Boshen wants to merge 1 commit into
mainfrom
feat/react-compiler-transform
Draft

feat(transform): run React Compiler as a pre-transform pass#9671
Boshen wants to merge 1 commit into
mainfrom
feat/react-compiler-transform

Conversation

@Boshen

@Boshen Boshen commented Jun 8, 2026

Copy link
Copy Markdown
Member

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:

  • rolldown bundlercrates/rolldown/src/utils/pre_process_ecma_ast.rs (Step 1.5), rebuilding scoping for the downstream transformer.
  • Vite unbundled devcrates/rolldown_plugin_vite_transform/src/lib.rs, between semantic build and the Transformer.
  • rolldown_commonreact_compiler is threaded through BundlerTransformOptions so it is exposed to the Vite transform plugin.

Notes

  • The React Compiler is not part of the per-file oxc::transformer::TransformOptions; it is a separate pass, so it is threaded through separately and pulled out before the per-file options are consumed.
  • The standalone transform() API (EnhancedTransformOptions) does not expose React Compiler yet.
  • In the Vite plugin, jsx only accepts preserve as a string preset (Vite passes a resolved jsx options object); the bundler additionally accepts the react-jsx string shorthand.

Tests

  • transform/react-compiler — bundler path
  • builtin-plugin/ecma-transform/react-compiler — Vite transform plugin path

🤖 Generated with Claude Code

Boshen commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

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.

@graphite-app graphite-app Bot changed the base branch from chore/upgrade-oxc-0.135.0 to graphite-base/9671 June 8, 2026 16:07
@graphite-app graphite-app Bot force-pushed the feat/react-compiler-transform branch from 7eed539 to 8371021 Compare June 8, 2026 16:14
@graphite-app graphite-app Bot force-pushed the graphite-base/9671 branch from 04849da to 5cfff49 Compare June 8, 2026 16:14
@graphite-app graphite-app Bot changed the base branch from graphite-base/9671 to main June 8, 2026 16:15
@graphite-app graphite-app Bot force-pushed the feat/react-compiler-transform branch from 8371021 to fdc4298 Compare June 8, 2026 16:15
@netlify

netlify Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 1137df7
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a282b0ddee3ac0008cefe38

@Boshen Boshen force-pushed the feat/react-compiler-transform branch 3 times, most recently from c3a5bf0 to eb4729c Compare June 9, 2026 14:12
@Boshen Boshen force-pushed the feat/react-compiler-transform branch from eb4729c to 1137df7 Compare June 9, 2026 15:02
@shulaoda

shulaoda commented Jun 10, 2026

Copy link
Copy Markdown
Member

fn enhanced_transform_internal(
filename: &str,
source_text: &str,
options: Option<BindingEnhancedTransformOptions>,
cache: Option<&TsconfigCache>,
yarn_pnp: bool,
) -> napi::Result<BindingEnhancedTransformResult> {

pub fn enhanced_transform(
filename: &str,
source_text: &str,
transform_options: EnhancedTransformOptions,
yarn_pnp: bool,
) -> EnhancedTransformResult {

let transform_ret = Transformer::new(&allocator, Path::new(filename), &oxc_transform_options)
.build_with_scoping(scoping, &mut program);
if !transform_ret.errors.is_empty() {
append_oxc_diagnostics(transform_ret.errors, &source, filename, &mut warnings, &mut errors);
if !errors.is_empty() {
return EnhancedTransformResult::new_for_error(errors, warnings, tsconfig_file_paths);
}
}

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