Skip to content

feat(test): enable React Compiler in vitest#2711

Merged
devmgn merged 2 commits intomainfrom
feat/vitest-react-compiler
Apr 18, 2026
Merged

feat(test): enable React Compiler in vitest#2711
devmgn merged 2 commits intomainfrom
feat/vitest-react-compiler

Conversation

@devmgn
Copy link
Copy Markdown
Owner

@devmgn devmgn commented Apr 18, 2026

Summary

  • @rolldown/plugin-babel + reactCompilerPreset を vitest の unit プロジェクトに配線し、babel-plugin-react-compiler を有効化
  • これにより本番 (Next.js) と同じ自動 memoize 挙動がユニットテストでも再現され、フックやコンポーネント側で useCallback / useMemo を書かなくても useSyncExternalStore 等の参照安定性を前提にしたコードがテストで検証できる
  • @vitejs/plugin-react v6 以降 babel オプションが削除されたため、公式 README が案内する @rolldown/plugin-babel 経由の構成を採用

依存追加

  • @rolldown/plugin-babel
  • @babel/core
  • @types/babel__core (TS 用)

Test plan

  • pnpm test:unit が通る
  • pnpm check が通る
  • memoize 前提のフック(useSyncExternalStore を使うもの)で再レンダー時の参照安定をテストで担保できる

Reference

🤖 Generated with Claude Code

devmgn and others added 2 commits April 18, 2026 17:21
Run `babel-plugin-react-compiler` through `@rolldown/plugin-babel` +
`reactCompilerPreset` so the memoize behavior in unit tests matches
production (Next.js). Keeps hooks and components free of manual
`useCallback` / `useMemo` while still catching regressions in tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@devmgn devmgn enabled auto-merge (squash) April 18, 2026 08:27
@devmgn devmgn merged commit 33cda31 into main Apr 18, 2026
4 checks passed
@devmgn devmgn deleted the feat/vitest-react-compiler branch April 18, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant