bun-plugin-react-compiler

raw JSON →
0.3.2 verified Fri May 01 auth: no javascript

Bun plugin for the React Compiler (formerly React Forget). Version 0.3.2, maintained actively. Integrates the React Compiler (Babel plugin) directly into Bun's bundler, allowing compilation of React components during bundling without additional Babel setup. Key differentiator: no need to run Babel separately when using Bun; handles both .js and .tsx files. Ships TypeScript types. Requires @babel/core and babel-plugin-react-compiler as peer dependencies.

error TypeError: plugin is not a function
cause Used older import style (direct object) after v0.3.0.
fix
Call plugin as function: plugin() instead of plugin.
error Module not found: @babel/core. Please install it.
cause Missing peer dependency.
fix
Run bun add @babel/core.
error bun-plugin-react-compiler is not a function or its return value is not a plugin
cause Using default import incorrectly (e.g., named import).
fix
Use default import: import plugin from 'bun-plugin-react-compiler' then call plugin().
gotcha Requires @babel/core and babel-plugin-react-compiler as peer dependencies. Must be installed separately.
fix Install with: bun add @babel/core babel-plugin-react-compiler
deprecated The plugin API may change when React Compiler reaches stable release.
fix Monitor release notes for breaking changes.
gotcha Options passed to plugin() are not validated; wrong options may cause silent failures.
fix Ensure options match babel-plugin-react-compiler's options.
breaking In v0.3.0, the default export changed from a plugin object to a factory function. Older usage `Bun.build({ plugins: [plugin] })` no longer works.
fix Change to `Bun.build({ plugins: [plugin()] })`.
npm install bun-plugin-react-compiler
yarn add bun-plugin-react-compiler
pnpm add bun-plugin-react-compiler

Shows how to use the default export as a Bun plugin in a build script. Default export is a factory function that returns a Bun.Plugin object.

// bunfig.toml (Bun 1.2+) or build script
import plugin from 'bun-plugin-react-compiler';

await Bun.build({
  entrypoints: ['./src/index.tsx'],
  outdir: './dist',
  plugins: [plugin()],
});