An esbuild plugin (v0.2.6) that enables library authors to build React components compatible with React 18 Server Components (RSC), including automatic 'use client' directive injection, test file exclusion, data-testid removal, and custom ignore/replace patterns. Supports both ESM and CJS output, full TypeScript types, and works with tsup or esbuild. Actively maintained with frequent releases. Differentiators: specifically targets RSC library development, not just client-side builds; handles JSX runtime deduplication and CSS variable renaming; provides a GitHub template for quick setup.
npm install esbuild-plugin-react18No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic configuration of the plugin with esbuild, including 'use client' directive injection, test file exclusion, and custom text replacement patterns.
tsup({ esbuildPlugins: [plugin()] })Change `import { plugin } from 'esbuild-plugin-react18'` to `import plugin from 'esbuild-plugin-react18'`.Ensure your source code uses standard JSX; for advanced JSX transforms, consider using Babel outside esbuild.
Add 'use client' manually in barrel files or use the 'replacePatterns' option to inject it.
Install react as a peer dependency and add `external: ['react', 'react-dom']` to esbuild build options.
Change to default import: `import plugin from 'esbuild-plugin-react18'`.