React Compiler Rewritten in Rust—Most of the Code Generated by Claude AI
The React team merged a massive PR that ports the React Compiler from TypeScript to Rust, adding over 123,000 lines, delivering roughly 3× overall speed and 10× pure transform speed, preserving the original architecture, passing 1,725 tests, supporting Babel, OXC and SWC integrations, and largely written with Claude AI, though it remains an early‑sharing experimental build.
React merged a PR titled "[compiler] Port React Compiler to Rust" authored by core team member Joseph Savona. The change adds 123,289 lines and deletes 306, and it is an official effort rather than a community experiment.
What is React Compiler
React Compiler, introduced in React 19, is a compilation‑time optimization tool that automatically inserts memoization calls such as useMemo and useCallback into ordinary React components, yielding hand‑tuned performance after compilation. The original implementation was written in TypeScript; this PR rewrites it in Rust.
How Much Faster
The PR description provides preliminary numbers (the author notes the benchmark environment is not yet fully verified):
When run as a Babel plugin, the Rust version is overall about 3× faster .
The pure transformation logic alone is about 10× faster .
The gap between the two figures is attributed to serialization overhead, which lowers the overall multiplier.
If the compiler is integrated natively via OXC or SWC, the serialization layer can be bypassed, theoretically exceeding the 3× gain.
Architecture Unchanged
The migration kept the architecture intact. The TypeScript version uses a High‑level Intermediate Representation (HIR) based on a control‑flow graph (CFG) and static single‑assignment (SSA) form to analyze components. The Rust version translates this architecture pass‑by‑pass, comparing intermediate states at each step to ensure behavioral parity.
1,725 tests passed , covering final output code comparison and internal state checks after every compilation pass. This rigorous verification means the migration risk is low, with each step explicitly matched.
Supports Babel, OXC, and SWC
The Rust implementation offers three integration entry points:
Babel plugin : a drop‑in replacement for babel-plugin-react-compiler, slated for eventual merge.
OXC integration : provided by the react_compiler_oxc crate.
SWC integration : provided by the react_compiler_swc crate.
For Vite projects, the OXC integration is most direct because Vite 5 already binds OXC for transpilation, and the Rolldown ecosystem also relies on OXC. Once the integration stabilises, Vite build times will reflect the performance boost directly.
The public API design uses a "Rust Babel AST + scope information" format as the input and output. Each integration converts its native AST to this unified format, allowing the core compilation logic to be maintained in a single place.
Most Code Written by Claude
The PR description notes that the "majority coded by AI" without naming the tool. A comment asked, "Did you use Codex?" Joseph Savona replied:
I used Claude for the initial work that got from zero to OSS tests being green. Since then @mvitousek, @mofeiZ, @poteto and others have picked up the work and may be using other tools. Again, this just to clarify, not to endorse any particular tool.
From zero to all OSS tests passing, Claude was used for the foundational work. The process mirrors Bun’s approach, where Jarred Sumner used an Anthropic coding agent to translate Zig to Rust, producing nearly a million lines in six days. React Compiler’s scale is smaller, but its verification is stricter, with precise state comparison after each pass.
Still Experimental
This PR is marked as "early sharing"; there is no ready‑to‑use build artifact. To try it now, developers must compile manually. The next steps involve internal testing at Meta and collaboration with OXC and SWC teams to polish the integration layer. Teams interested in OXC/SWC integration are encouraged to review the crate APIs and provide feedback.
Production‑ready usage will take more time, but the direction is set and the PR has already been merged into the main line.
Rustisation of the Front‑End Toolchain Continues
The trend of rewriting front‑end tooling in Rust persists: Bun rewrote its Zig‑based core in Rust, Rolldown reached a stable release, Vite 8 refactored its bundler core, Deno switched its TypeScript parser from SWC to OXC, and Node.js core is gradually introducing Rust components.
React Compiler’s Rust port confirms that compiler‑level performance still has ample headroom and that Rust is the chosen tool for unlocking it. When native OXC and SWC integrations mature, developers will only need to upgrade dependencies to reap the speed benefits.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Full-Stack Cultivation Path
Focused on sharing practical tech content about TypeScript, Vue 3, front-end architecture, and source code analysis.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
