react-compiler-cli
v0.1.0
Published
Fast Rust CLI that reports which React files and components are processed by React Compiler.
Maintainers
Readme
react-compiler-cli
See what the React Compiler actually compiles — in milliseconds. A fast, Rust-powered auditor for projects adopting React Compiler. Zero config, monorepo-aware, AI-friendly output, with an MCP server for agents.
npx react-compiler-cli ai .compiler: enabled=true mode=Infer source=vite.config.ts
stats: 301f 397c | enabled=397
issues: 29
src/features/cart/Cart.tsx:42 CartList [enabled] useMemo=1 useCallback=2
src/features/checkout/Pay.tsx:18 PayButton [enabled] React.memo
...One command. Every component. Nothing to set up.
Install
npm i -g react-compiler-cli
# or:
npx react-compiler-cli ai .Prebuilt binaries ship for darwin-arm64, darwin-x64, linux-x64, linux-arm64, linux-x64-musl (Alpine), and win32-x64. npm picks the right one automatically via optionalDependencies — no postinstall compile step, no Rust toolchain required.
What it does
scan— full structured report (JSON / text / Markdown) of every React file & component and whether the compiler processes it.ai— compact digest optimized for LLM input. ~10× smaller than the full report.doctor— verifies compiler config, lists workspaces, checks--deepavailability.cleanup— suggests (and optionally applies) removal of manualuseMemo/useCallbackthat the compiler makes redundant.- MCP server —
react-compiler-mcpbinary exposes all four as MCP tools for Claude Desktop, Cursor, and any MCP-capable agent.
Programmatic API
Import it in a Node script or CI check:
const { scan, ai, cleanup } = require("react-compiler-cli");
const report = await scan("./apps/web", { summary: true });
console.log(report.stats); // { enabled: 152, "opted-out-file": 3, ... }
const digest = await ai("./apps/web"); // compact JSON, LLM-ready
const hunks = await cleanup("./apps/web"); // dry-run — pass { apply: true } to rewriteAll functions spawn the prebuilt binary and return parsed JSON (or the raw
string when you pass format: "text" | "markdown"). binaryPath() returns
the resolved binary path for custom spawns.
MCP integration
Point your agent at:
{
"mcpServers": {
"react-compiler": {
"command": "npx",
"args": ["-y", "react-compiler-mcp"]
}
}
}Then ask “which components in this repo would benefit from removing manual memoization?” — grounded in your actual code.
Highlights
- Orders of magnitude faster than Babel-based tools for coverage reports. Backed by
oxc+rayon. Runbench/run.shfor numbers on your own tree — see README for the author's reference run. - Monorepo-native —
pnpm-workspace.yaml,package.json#workspaces, mixed per-workspace compiler configs. - Detects everything: Vite / Next / Expo / Babel / SWC configs,
"use memo"/"use no memo"/"use forget"directives,React.memo,forwardRef, annotation mode, and more. --deepmode runs the realbabel-plugin-react-compilerto confirm bailouts with reasons and spans.
Full documentation and examples: github.com/TheHypnoo/react-compiler-cli.
License
Licensed under either of MIT or Apache-2.0 at your option.
© TheHypnoo
