网页 综合 更新时间 2026-08-18 00:00:00

React Compiler Support | The JavaScript Oxidation Compiler

自动蜘蛛 oxc.rs 正文约 4597 字
React Compiler Support | The JavaScript Oxidation Compiler
React Compiler Support
Type-Aware Linting Stable
Oxlint JS Plugins Alpha
Type-Aware Linting Alpha
Oxlint JS Plugins Preview
Oxlint Type-Aware Preview
Oxlint v0.10 Release
Oxlint Import Plugin Alpha
Oxlint General Availability
We are excited to announce React Compiler support in Oxlint and Oxc Transform.
Oxlint now includes 22 React Compiler-powered rules that use the compiler's validation passes to catch violations of the Rules of React.
The package oxc-transform-react applies React Compiler's automatic memoization. It is more than 10 times faster than Babel in our preliminary benchmark.
Vite integration is available in @vitejs/plugin-react v6.1.0.
Enable the React plugin and its correctness rules:
React Compiler rule categories are aligned with the upstream ESLint presets. We added all recommended rules to Oxlint's correctness category.
If you enabled the previous nursery react/react-compiler rule, remove it from your configuration. It has been replaced by the category-specific rules below.
Install oxc-transform-react:
Vite integration is available in @vitejs/plugin-react v6.1.0 for Vite 8. Install the plugin and its optional oxc-transform-react peer dependency:
Enable the experimental integration with the compiler option:
We keep this framework-specific integration in @vitejs/plugin-react, rather than adding it to Vite or Rolldown, so the core toolchain remains vendor-neutral.
Our preliminary benchmark shows that oxc-transform-react is more than 10 times faster than babel-plugin-react-compiler.
Files that used to take around 100 ms to compile now take around 10 ms.
React Compiler is a build-time compiler that automatically memoizes React components and hooks. React Compiler 1.0 was released last year as babel-plugin-react-compiler.
Earlier this year, the React team ported React Compiler to Rust. We started looking for ways to integrate it into Oxc.
Our initial integration added more than 5 MiB to the binary, and we believed we could improve its performance significantly.
Our first attempt was to maintain a synchronized fork and publish it as crates. The goal was to let the Rust tooling ecosystem, including SWC, Bun, and Biome, use and maintain one shared fork.
We then discovered that this version of React Compiler maintained its own Babel-shaped AST. Oxc had to convert its AST into that representation before running the compiler, then convert it back afterwards. We knew we could make it faster by running the compiler directly on Oxc's AST. The Rust port was also unfinished, had bugs, and did not yet conform to the original Babel implementation.
We eventually decided to vendor React Compiler into Oxc for tighter integration. This allowed us to remove the intermediate Babel AST and make React Compiler operate directly on the Oxc AST.
After a lot of work, we made it significantly faster and smaller, with better conformance, diagnostics, and source maps.
The original Rust port was unfinished when it was merged. We finished many missing pieces, fixed bugs, and added the improvements below.
In our local measurements, Oxc's version is about twice as fast as the original Rust port of React Compiler.
Running directly on Oxc's AST also reduced memory allocations.
Oxc conforms to the latest experimental release of babel-plugin-react-compiler, while its default options remain aligned with Babel React Compiler v1 because the latest experimental release changed some defaults.
We have compared our output against this version across more than 100 large and popular repositories, covering over 100,000 source files, and made sure all files compile to the same output.
We improved React Compiler diagnostics to make issues easier for coding agents to fix. Oxlint now shows compact codeframes, related source locations, help messages, and links.
Our first fork-based integration produced an 8.66 MiB macOS ARM64 binary. After removing the Babel AST and JSON round-trip, replacing the full regex engine, and removing unused compiler code, the published oxc-transform-react v0.144.0 binding is 3.97 MiB.
React Compiler remains in a separate optional package, so it does not increase the binary size for Oxc Transform.
The original Rust port had incomplete source map support.
We made sure source maps work correctly across React Compiler, TypeScript, JSX, and React Fast Refresh.
There are still many TODOs in the code. At the time of writing, the original Rust crates contain 16 literal TODO markers and 62 code paths that emit Todo diagnostics. Oxc's vendored compiler contains 10 literal TODO markers and 57 centralized Todo diagnostic constructors.
访问原文 返回搜索 https://oxc.rs/blog/2026-08-18-react-compiler-support
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。