Skip to content

fix(transformer): don't discard output on non-fatal React Compiler errors#23587

Open
Boshen wants to merge 1 commit into
mainfrom
fix/transformer-react-compiler-non-fatal
Open

fix(transformer): don't discard output on non-fatal React Compiler errors#23587
Boshen wants to merge 1 commit into
mainfrom
fix/transformer-react-compiler-non-fatal

Conversation

@Boshen

@Boshen Boshen commented Jun 18, 2026

Copy link
Copy Markdown
Member

Problem

With the default panicThreshold: 'none' the React Compiler skips a function it can't compile (a Rules-of-Hooks violation, an unsupported syntax bail-out, …) and still succeeds, leaving a valid program. But oxc treated any error-severity diagnostic as fatal and emitted nothing for the whole file — unlike babel-plugin-react-compiler, which emits the rest of the module.

Fix

Surface a fatal flag from oxc_react_compiler (set only for CompileResult::Error, which the compiler returns only when panicThreshold escalates an error to fatal). The transformer now:

  • aborts only when fatal is set (e.g. panicThreshold: 'critical_errors' | 'all_errors');
  • otherwise keeps the compiled (or untouched original) program, runs the rest of the pipeline, and demotes the React Compiler's diagnostics to warnings so code is still emitted.

The react-compiler lint rule is unaffected — it reads diagnostics through its own lint() path and still filters on Severity::Error.

How it was found / impact

By diffing oxc's React Compiler output against babel-plugin-react-compiler across the oxc-ecosystem-ci repos (~42k .tsx/.jsx files):

before after
files where oxc emitted nothing but babel emitted code 1690 11
of those, now byte-for-byte correct output 764
regressions (a previously-matching file now differing) 0

The remaining 11 are genuine panicThreshold-fatal compiles, which correctly still abort.


🤖 Developed with Claude Code (AI-assisted).

Boshen commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@github-actions github-actions Bot added the A-transformer Area - Transformer / Transpiler label Jun 18, 2026
@Boshen Boshen marked this pull request as draft June 18, 2026 07:32
@graphite-app graphite-app Bot changed the base branch from fix/react-compiler-computed-key-imports to graphite-base/23587 June 18, 2026 07:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d8dfe7c78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_transformer/src/lib.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Jun 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing fix/transformer-react-compiler-non-fatal (a4697f8) with main (6b104e8)

Open in CodSpeed

Footnotes

  1. 9 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.

@graphite-app graphite-app Bot force-pushed the fix/transformer-react-compiler-non-fatal branch from 2d8dfe7 to eec3f27 Compare June 18, 2026 07:38
@graphite-app graphite-app Bot force-pushed the graphite-base/23587 branch from 68a6d8b to 20375f9 Compare June 18, 2026 07:38
@graphite-app graphite-app Bot changed the base branch from graphite-base/23587 to main June 18, 2026 07:39
@graphite-app graphite-app Bot force-pushed the fix/transformer-react-compiler-non-fatal branch from eec3f27 to 4e94f85 Compare June 18, 2026 07:39
@Boshen Boshen force-pushed the fix/transformer-react-compiler-non-fatal branch from 4e94f85 to 44450d5 Compare June 18, 2026 10:03
@Boshen Boshen marked this pull request as ready for review June 18, 2026 10:08
@Boshen Boshen force-pushed the fix/transformer-react-compiler-non-fatal branch from 44450d5 to f19c41a Compare June 18, 2026 12:56
…rors

With the default `panicThreshold: 'none'` the React Compiler skips a function it
can't compile and still succeeds, but oxc treated any error-severity diagnostic
as fatal and emitted nothing for the whole file — unlike
babel-plugin-react-compiler, which emits the rest of the module.

Surface a `fatal` flag from `oxc_react_compiler` (set only for
`CompileResult::Error`, which `panicThreshold` escalates to) and only abort the
transform when it is set. Otherwise keep the compiled (or untouched original)
program, run the rest of the pipeline, and demote the React Compiler's
diagnostics to warnings so code is still emitted. The `react-compiler` lint rule
continues to report them at full severity through its own path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant