Skip to main content

setup-react-compiler

Install React Compiler with rsbuild and enforce compiler-friendly patterns via PostToolUse hooks. Flags manual memoization, derived state, useRef cache. Use when setting up React Compiler or post-compiler patterns.

来源信息

仓库
redpanda-data/ui-harness
最近来源活动
2026年5月8日 11:21
检测到的 SKILL.md 语言
英语
星标
34
Forks
4

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

文件资源管理器
4 个文件

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
setup-react-compiler
description
Install React Compiler with rsbuild and enforce compiler-friendly patterns via PostToolUse hooks. Flags manual memoization, derived state, useRef cache. Use when setting up React Compiler or post-compiler patterns.
# Setup React Compiler ## What This Sets Up - **babel-plugin-react-compiler** with rsbuild - PostToolUse hook flags: `useMemo`/`useCallback`/`React.memo` (compiler handle), derived-state-via-useEffect, `useRef` as memo cache - `'use no memo'` escape hatch + auto-skip component library dirs - Annotation mode (`REACT_COMPILER_MODE=annotation`) for brownfield: flag only files with `"use memo"` See [REFERENCE.md](REFERENCE.md) for post-compiler rules. ## Steps ### 1. Install ```bash bun add -D babel-plugin-react-compiler @rsbuild/plugin-babel --yarn ``` ### 2. Configure rsbuild ```ts 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 has babel plugin - [ ] Hook executable + configured - [ ] Component library files have `'use no memo'`
在 GitHub 查看