diff --git a/packages/plugin-react-swc/CHANGELOG.md b/packages/plugin-react-swc/CHANGELOG.md index a0d53d18..b40ae169 100644 --- a/packages/plugin-react-swc/CHANGELOG.md +++ b/packages/plugin-react-swc/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Make compatible with rolldown-vite + +This plugin is now compatible with rolldown-powered version of Vite. + ## 3.9.0-beta.3 (2025-04-15) ### Add `reactRefreshHost` option diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 9c33c224..8e197588 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -110,6 +110,8 @@ const react = (_options?: Options): PluginOption[] => { apply: 'serve', config: () => ({ esbuild: false, + // NOTE: oxc option only exists in rolldown-vite + oxc: false, optimizeDeps: { include: [`${options.jsxImportSource}/jsx-dev-runtime`], esbuildOptions: { jsx: 'automatic' }, diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index 045f3d87..705bb7f3 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +### Make compatible with rolldown-vite + +This plugin is now compatible with rolldown-powered version of Vite. +Note that currently the `__source` property value position might be incorrect. This will be fixed in the near future. + ## 4.4.0-beta.2 (2025-04-15) ### Add `reactRefreshHost` option diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 0923207a..cbaa1604 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -203,7 +203,14 @@ export default function viteReact(opts: Options = {}): PluginOption[] { ]) } - if (opts.jsxRuntime === 'classic' && isJSX) { + if ( + opts.jsxRuntime === 'classic' && + isJSX && + // OXC injects self and source so these plugins are not needed for rolldown-vite + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore -- this.meta.rolldownVersion only exists in rolldown-vite + !this.meta.rolldownVersion + ) { if (!isProduction) { // These development plugins are only needed for the classic runtime. plugins.push(