setup-react-compiler
Setup React Compiler
What This Sets Up
- babel-plugin-react-compiler with rsbuild
- PostToolUse hook flags:
useMemo/useCallback/React.memo(compiler handles it), derived-state-via-useEffect,useRefas memo cache 'use no memo'escape hatch + auto-skip component library dirs- Annotation mode (
REACT_COMPILER_MODE=annotation) for brownfield: only flags in files with"use memo"
See REFERENCE.md for post-compiler coding rules.
Steps
1. Install
bun add -D babel-plugin-react-compiler @rsbuild/plugin-babel --yarn
2. Configure rsbuild
import { pluginBabel } from '@rsbuild/plugin-babel';
export default {
plugins: [
pluginBabel({
babelLoaderOptions: {
plugins: [['babel-plugin-react-compiler', {
compilationMode: 'annotation', // 'infer' for greenfield
}]],
},
}),
],
};
Brownfield: set REACT_COMPILER_MODE=annotation in session-env.sh.
3. Component library
Add 'use no memo' to all .tsx in component library dir.
4. Hook
Copy scripts/react-compiler-check.sh + scripts/_hook-lib.sh → .claude/hooks/. chmod +x. Add to PostToolUse (Edit|Write).
5. Verify
- rsbuild config includes babel plugin
- Hook executable and configured
- Component library files have
'use no memo'
More from malinskibeniamin/skills
setup-react-rules
Enforce React/TS/security rules via PostToolUse hooks — bans raw HTML, TS escape hatches, XSS vectors, barrel imports, missing passive listeners. Use when enforcing React patterns or component library standards.
9setup-biome
Install Biome linter with Ultracite preset, create biome.jsonc config, and configure Claude Code Stop hook for auto-fix before finishing. Use when setting up linting, formatting, Biome, Ultracite, or code quality enforcement.
9frontend-starter-kit
Complete frontend stack — 14 setup skills + diagnostics + 13 community workflow skills in one command. Use when starting a new frontend project or bootstrapping frontend best practices from scratch.
7setup-tanstack-router
Auto-generate TanStack Router route tree and enforce router patterns via PostToolUse hooks. Bans react-router-dom, window.location, untyped hooks. Use when setting up TanStack Router or file-based routing.
7setup-react-doctor
React health scoring via react-doctor with Stop hook to fail on score regression. Use when setting up react-doctor or preventing UI quality regressions.
7setup-accessibility
Enforce ARIA accessibility via PostToolUse hooks — labels, keyboard handlers, widget attributes, Playwright AXE setup. Use when setting up a11y enforcement, WCAG 2.1 AA compliance, or accessibility testing.
5