React Compiler Rewritten in Rust—Most Code Generated by Claude AI
Meta merged a massive PR that rewrites the official React Compiler in Rust, adding 123,289 lines, delivering roughly 3× overall speed‑up (10× on pure transforms), preserving the original architecture, passing 1,725 tests, and largely authored by Claude AI.
Meta’s React repository quietly merged a large PR titled "[compiler] Port React Compiler to Rust" authored by core team member Joseph Savona, with 123,289 lines added and 306 lines removed.
What the React Compiler Does
The React Compiler, introduced in React 19, automatically inserts memoization calls such as useMemo and useCallback at compile time, allowing developers to write ordinary React components that compile to hand‑optimized performance.
Porting to Rust
The original implementation was written in TypeScript; the new PR rewrites it in Rust. Preliminary test numbers (not yet verified on a detailed benchmark environment) show:
When run as a Babel plugin, the Rust version is roughly 3× faster overall.
For the pure transformation logic alone, the Rust version is about 10× faster .
The gap between the two figures is due to serialization overhead, which lowers the overall multiplier.
If integrated natively via OXC or SWC, the serialization layer can be bypassed, potentially exceeding the 3× gain.
Architecture Remains Unchanged
The migration kept the full 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. The Rust version translates each pass against this architecture, performing strict state‑by‑state comparisons to ensure behavioral parity.
All 1,725 tests passed, including output code diffs and intermediate state checks after each pass, indicating a very low migration risk.
Supported Integrations
The Rust implementation offers three integration entry points:
Babel plugin : a drop‑in replacement for babel-plugin-react-compiler that will eventually be merged upstream.
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; Vite 5 already binds tightly to OXC for transpilation, and the upcoming stable integration will make build‑time improvements visible during vite build.
The public API uses a unified "Rust Babel AST + scope information" format, letting each integration translate its native AST into this common representation while the core compiler logic stays singular.
AI‑Generated Code
The PR description notes that the "majority coded by AI" without naming the tool. In the comment thread, Joseph Savona confirmed: "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."
This mirrors the approach taken by Bun, 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 the verification process is far more rigorous, with precise per‑pass state comparisons.
Early‑Sharing Status
The PR is marked as "early sharing"; no ready‑to‑use build artifacts are provided. Interested teams must compile manually. The next steps involve internal testing at Meta and collaboration with OXC and SWC teams to polish the integration layer. Tooling teams can review the crate APIs now and provide feedback.
Ongoing Rustization of Front‑End Toolchains
This move is part of a broader trend: Bun rewrote its Zig core in Rust, Rolldown reached a stable release, Vite 8 refactored its bundling core, Deno switched its TypeScript parser from SWC to OXC, and Node.js is gradually introducing Rust components.
React Compiler’s Rust rewrite confirms that the compiler layer still holds significant performance potential, and Rust is the chosen implementation language. Once native OXC and SWC integrations mature, developers will benefit from faster builds simply by upgrading dependencies.
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.
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.
