Skip to content

eve0415/oxc-plugin-react-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oxc-plugin-react-compiler

npm version license

Warning

Experimental: This project may have edge cases where behavior differs from the official React Compiler plugin. If you encounter any differences, please open an issue with a detailed description and a minimal reproduction so we can investigate.

About the Project

oxc-plugin-react-compiler is an experimental project aiming to port the original babel-plugin-react-compiler to a Rust-based implementation on top of the OXC toolchain.

Note

Disclaimer: This is a community-driven project. It is not an official project from the React team or OXC, and we are not affiliated with Meta, the React core team, or the OXC project.

The primary goal is to achieve exact behavior alignment with the original React Compiler implementation while leveraging the performance benefits of Rust.

Current Status

We have achieved 100% conformance parity with the upstream React Compiler. This was verified by running the full conformance test suite against all upstream fixtures. While still experimental, this demonstrates complete behavioral alignment with the original implementation.

Installation

npm install oxc-plugin-react-compiler

Usage

Vite

Note

The Vite integration requires Vite 8.0 or later.

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactCompilerOxc } from 'oxc-plugin-react-compiler';

export default defineConfig({
  plugins: [
    reactCompilerOxc({
      // compilationMode: 'infer',  // 'infer' | 'annotation' | 'all'
      // panicThreshold: 'none',    // 'none' | 'all'
      // target: '19',              // React version to target
      // sources: ['src/'],         // string[] | ((id: string) => boolean)
    }),
    react(),
  ],
});

ESLint

The lint plugin is exposed from the oxc-plugin-react-compiler/eslint subpath:

import reactCompiler from 'oxc-plugin-react-compiler/eslint';

export default [reactCompiler.configs.recommended];

The exported rules use the oxc-react-compiler/* namespace.

Oxlint

Oxlint JS plugin support is also exposed from the same oxc-plugin-react-compiler/eslint subpath:

{
  "jsPlugins": ["oxc-plugin-react-compiler/eslint"],
  "rules": {
    "oxc-react-compiler/purity": "error",
    "oxc-react-compiler/refs": "error",
    "oxc-react-compiler/no-unused-directives": "error"
  }
}

Use oxc-plugin-react-compiler/eslint as the Oxlint JS plugin specifier. The bare oxc-plugin-react-compiler package root is the Vite plugin entrypoint, not the Oxlint plugin entrypoint.

Experimental Nature

This project serves as an experiment to explore AI-assisted development in complex compiler porting tasks. The codebase is being heavily co-developed with AI assistants including Claude Code and Codex. Due to API rate limits and the inherent complexity of the task, development is expected to span several months. The initial primitive implementation took about a month to prove the viability of a Rust-based React compiler.

Goals & Roadmap

  • Primitive implementation proving viability in Rust.
  • Align behavior exactly with the upstream React Compiler (verified via conformance tests).
  • Provide seamless integration with Vite v8 via the included Vite plugin.
  • Publish to npm for easy installation.
  • Source map support.
  • Future exploration: Add support for SWC alongside OXC.

Architecture Overview

  • crates/oxc_react_compiler/: Core compiler implementation (HIR, inference, reactive scopes, optimization, codegen).
  • crates/oxc_react_compiler_napi/: N-API bindings to expose the Rust implementation to JavaScript.
  • napi/: JavaScript wrapper + Vite v8 plugin.
  • tasks/conformance/: Test harness ensuring parity with upstream React Compiler fixtures.

Acknowledgements & Credits

This project wouldn't be possible without the incredible work of the following teams and tools:

  • The React Team: For the original React Compiler architecture, logic, and conformance fixtures.
  • The OXC Team: For the blazingly fast Rust-based JavaScript toolchain that powers this port.
  • Claude Code and Codex: Heavily relied upon to analyze, explore, implement, test, and literally anything else to this project.

Support the Project

If you find this project interesting or useful, please consider giving it a ⭐ on GitHub! Your support helps show that there is interest in a high-performance, Rust-based React Compiler.

Found a bug or unexpected behavior? Please open an issue — detailed reports help us improve.

License

This project is open-source and licensed under the MIT License.

About

The React Compiler, ported to Rust with OXC. 🦀✨

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors