From 7679e49bf4433afe13e7df91a0f2e498720d29db Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Mon, 2 Jun 2025 19:32:42 +0200 Subject: [PATCH 01/16] feat: log recommendation to switch to vite-plugin-react-oxc when rolldown-vite is detected --- packages/plugin-react-swc/src/index.ts | 8 ++++++++ packages/plugin-react/src/index.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 6f20a05df..03e4667cc 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -18,6 +18,7 @@ import { runtimePublicPath, silenceUseClientWarning, } from '@vitejs/react-common' +import * as vite from 'vite' import { exactRegex } from '@rolldown/pluginutils' /* eslint-disable no-restricted-globals */ @@ -141,6 +142,13 @@ const react = (_options?: Options): PluginOption[] => { '[vite:react-swc] The MDX plugin should be placed before this plugin', ) } + + // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no swc plugins are set + if ('rolldownVersion' in vite && !config.plugins.length) { + console.warn( + '[vite:react-swc] We recommend switching to `vite-plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown', + ) + } }, transformIndexHtml: (_, config) => { if (!hmrDisabled) { diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 250c4477e..d6500ede0 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -131,6 +131,12 @@ export default function viteReact(opts: Options = {}): PluginOption[] { name: 'vite:react-babel', enforce: 'pre', config() { + if ('rolldownVersion' in vite) { + // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used + console.warn( + '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', + ) + } if (opts.jsxRuntime === 'classic') { if ('rolldownVersion' in vite) { return { From 6b41764e82e39172450142857501abd9ec4c7aae Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Tue, 3 Jun 2025 18:54:25 +0200 Subject: [PATCH 02/16] chore(swc): check for mutateSwcOptions and fix plugin check --- packages/plugin-react-swc/src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 03e4667cc..9497e85f4 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -143,8 +143,15 @@ const react = (_options?: Options): PluginOption[] => { ) } - // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no swc plugins are set - if ('rolldownVersion' in vite && !config.plugins.length) { + /* Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and: + * No swc plugins are set + * mutateSwcOptions is not set + */ + if ( + 'rolldownVersion' in vite && + !options.useAtYourOwnRisk_mutateSwcOptions && + !options.plugins + ) { console.warn( '[vite:react-swc] We recommend switching to `vite-plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown', ) From 6008c90068270f87f7a6bc8bae56bc39a3b3ccdb Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Tue, 3 Jun 2025 18:54:55 +0200 Subject: [PATCH 03/16] chore(react): do not recommend if babel option is set --- packages/plugin-react/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index d6500ede0..7d8cf836e 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -131,8 +131,8 @@ export default function viteReact(opts: Options = {}): PluginOption[] { name: 'vite:react-babel', enforce: 'pre', config() { - if ('rolldownVersion' in vite) { - // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used + if ('rolldownVersion' in vite && !opts.babel) { + // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no babel config is set console.warn( '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', ) From 0979cd1062d20139732f15b8fe698ce3cb1efff2 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Tue, 3 Jun 2025 18:59:13 +0200 Subject: [PATCH 04/16] feat: introduce option to disable the warning --- packages/plugin-react-swc/src/index.ts | 10 +++++++++- packages/plugin-react/src/index.ts | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 9497e85f4..613276761 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -76,6 +76,11 @@ type Options = { * feature doesn't work is not fun, so we won't provide support for it, hence the name `useAtYourOwnRisk` */ useAtYourOwnRisk_mutateSwcOptions?: (options: SWCOptions) => void + + /** + * If set, disables the recommendation to use `vite-plugin-react-oxc` + */ + disableOxcRecommendation?: boolean } const react = (_options?: Options): PluginOption[] => { @@ -91,6 +96,7 @@ const react = (_options?: Options): PluginOption[] => { reactRefreshHost: _options?.reactRefreshHost, useAtYourOwnRisk_mutateSwcOptions: _options?.useAtYourOwnRisk_mutateSwcOptions, + disableOxcRecommendation: _options?.disableOxcRecommendation, } return [ @@ -143,12 +149,14 @@ const react = (_options?: Options): PluginOption[] => { ) } - /* Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and: + /* + * Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and: * No swc plugins are set * mutateSwcOptions is not set */ if ( 'rolldownVersion' in vite && + !options.disableOxcRecommendation && !options.useAtYourOwnRisk_mutateSwcOptions && !options.plugins ) { diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 7d8cf836e..6d703eb0e 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -62,6 +62,11 @@ export interface Options { * reactRefreshHost: 'http://localhost:3000' */ reactRefreshHost?: string + + /** + * If set, disables the recommendation to use `vite-plugin-react-oxc` + */ + disableOxcRecommendation?: boolean } export type BabelOptions = Omit< @@ -131,7 +136,11 @@ export default function viteReact(opts: Options = {}): PluginOption[] { name: 'vite:react-babel', enforce: 'pre', config() { - if ('rolldownVersion' in vite && !opts.babel) { + if ( + 'rolldownVersion' in vite && + !opts.disableOxcRecommendation && + !opts.babel + ) { // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no babel config is set console.warn( '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', From d52a6c2a62d83714802da6d1f2e2d844b27dac41 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Tue, 3 Jun 2025 19:35:45 +0200 Subject: [PATCH 05/16] docs: info for oxc option --- packages/plugin-react-swc/README.md | 8 ++++++++ packages/plugin-react/README.md | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/packages/plugin-react-swc/README.md b/packages/plugin-react-swc/README.md index 76bd52e6f..d3b1a8659 100644 --- a/packages/plugin-react-swc/README.md +++ b/packages/plugin-react-swc/README.md @@ -117,6 +117,14 @@ react({ }) ``` +### disableOxcRecommendation + +If set, disables the recommendation to use `vite-plugin-react-oxc` (which is shown when `rolldown-vite` is detected and neither `swc` plugins are used nor the `swc` options are mutated). + +```ts +react({ disableOxcRecommendation: true }) +``` + ## Consistent components exports For React refresh to work correctly, your file should only export React components. The best explanation I've read is the one from the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works). diff --git a/packages/plugin-react/README.md b/packages/plugin-react/README.md index 7eaa29ab4..1406310b9 100644 --- a/packages/plugin-react/README.md +++ b/packages/plugin-react/README.md @@ -129,6 +129,10 @@ Otherwise, you'll probably get this error: Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. ``` +### disableOxcRecommendation + +If set, disables the recommendation to use `vite-plugin-react-oxc` (which is shown when `rolldown-vite` is detected and `babel` is not configured). + ## Consistent components exports For React refresh to work correctly, your file should only export React components. You can find a good explanation in the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works). From 2b0a0ce7c2a72d3dc0dd89be48ad163544d5945a Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 4 Jun 2025 09:02:02 +0200 Subject: [PATCH 06/16] fix: correct vite pkg name --- packages/plugin-react-swc/README.md | 2 +- packages/plugin-react-swc/src/index.ts | 2 +- packages/plugin-react/README.md | 2 +- packages/plugin-react/src/index.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/plugin-react-swc/README.md b/packages/plugin-react-swc/README.md index d3b1a8659..c74f11d72 100644 --- a/packages/plugin-react-swc/README.md +++ b/packages/plugin-react-swc/README.md @@ -119,7 +119,7 @@ react({ ### disableOxcRecommendation -If set, disables the recommendation to use `vite-plugin-react-oxc` (which is shown when `rolldown-vite` is detected and neither `swc` plugins are used nor the `swc` options are mutated). +If set, disables the recommendation to use `@vitejs/plugin-react-oxc` (which is shown when `rolldown-vite` is detected and neither `swc` plugins are used nor the `swc` options are mutated). ```ts react({ disableOxcRecommendation: true }) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 613276761..ce78c0c32 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -78,7 +78,7 @@ type Options = { useAtYourOwnRisk_mutateSwcOptions?: (options: SWCOptions) => void /** - * If set, disables the recommendation to use `vite-plugin-react-oxc` + * If set, disables the recommendation to use `@vitejs/plugin-react-oxc` */ disableOxcRecommendation?: boolean } diff --git a/packages/plugin-react/README.md b/packages/plugin-react/README.md index 1406310b9..af7a2d545 100644 --- a/packages/plugin-react/README.md +++ b/packages/plugin-react/README.md @@ -131,7 +131,7 @@ Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. ### disableOxcRecommendation -If set, disables the recommendation to use `vite-plugin-react-oxc` (which is shown when `rolldown-vite` is detected and `babel` is not configured). +If set, disables the recommendation to use `@vitejs/plugin-react-oxc` (which is shown when `rolldown-vite` is detected and `babel` is not configured). ## Consistent components exports diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 6d703eb0e..1ba538567 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -64,7 +64,7 @@ export interface Options { reactRefreshHost?: string /** - * If set, disables the recommendation to use `vite-plugin-react-oxc` + * If set, disables the recommendation to use `@vitejs/plugin-react-oxc` */ disableOxcRecommendation?: boolean } From 8ee3ad114490bb6e38a4d667a22e11de5e94b9f2 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 4 Jun 2025 09:04:35 +0200 Subject: [PATCH 07/16] chore: use config.logger.warn --- packages/plugin-react-swc/src/index.ts | 4 ++-- packages/plugin-react/src/index.ts | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index ce78c0c32..a46488f3a 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -78,7 +78,7 @@ type Options = { useAtYourOwnRisk_mutateSwcOptions?: (options: SWCOptions) => void /** - * If set, disables the recommendation to use `@vitejs/plugin-react-oxc` + * If set, disables the recommendation to use `vite-plugin-react-oxc` */ disableOxcRecommendation?: boolean } @@ -160,7 +160,7 @@ const react = (_options?: Options): PluginOption[] => { !options.useAtYourOwnRisk_mutateSwcOptions && !options.plugins ) { - console.warn( + config.logger.warn( '[vite:react-swc] We recommend switching to `vite-plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown', ) } diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 1ba538567..5bac66131 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -64,7 +64,7 @@ export interface Options { reactRefreshHost?: string /** - * If set, disables the recommendation to use `@vitejs/plugin-react-oxc` + * If set, disables the recommendation to use `vite-plugin-react-oxc` */ disableOxcRecommendation?: boolean } @@ -136,16 +136,6 @@ export default function viteReact(opts: Options = {}): PluginOption[] { name: 'vite:react-babel', enforce: 'pre', config() { - if ( - 'rolldownVersion' in vite && - !opts.disableOxcRecommendation && - !opts.babel - ) { - // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no babel config is set - console.warn( - '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', - ) - } if (opts.jsxRuntime === 'classic') { if ('rolldownVersion' in vite) { return { @@ -184,6 +174,17 @@ export default function viteReact(opts: Options = {}): PluginOption[] { config.command === 'build' || config.server.hmr === false + if ( + 'rolldownVersion' in vite && + !opts.disableOxcRecommendation && + !opts.babel + ) { + // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no babel config is set + config.logger.warn( + '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', + ) + } + if ('jsxPure' in opts) { config.logger.warnOnce( '[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly.', From 7b55598a2f6ba890615f1ecf5b00011026ac549b Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 4 Jun 2025 09:07:50 +0200 Subject: [PATCH 08/16] chore: check for babel hooks and disable if needed --- packages/plugin-react-swc/src/index.ts | 5 +++-- packages/plugin-react/src/index.ts | 28 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index a46488f3a..5aad5e1e4 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -153,12 +153,13 @@ const react = (_options?: Options): PluginOption[] => { * Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and: * No swc plugins are set * mutateSwcOptions is not set + * It is not disabled by the user */ if ( 'rolldownVersion' in vite && - !options.disableOxcRecommendation && + !options.plugins && !options.useAtYourOwnRisk_mutateSwcOptions && - !options.plugins + !options.disableOxcRecommendation ) { config.logger.warn( '[vite:react-swc] We recommend switching to `vite-plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown', diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 5bac66131..f758be75c 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -174,17 +174,6 @@ export default function viteReact(opts: Options = {}): PluginOption[] { config.command === 'build' || config.server.hmr === false - if ( - 'rolldownVersion' in vite && - !opts.disableOxcRecommendation && - !opts.babel - ) { - // Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no babel config is set - config.logger.warn( - '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', - ) - } - if ('jsxPure' in opts) { config.logger.warnOnce( '[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly.', @@ -195,6 +184,23 @@ export default function viteReact(opts: Options = {}): PluginOption[] { .map((plugin) => plugin.api?.reactBabel) .filter(defined) + if ( + 'rolldownVersion' in vite && + !opts.babel && + !hooks.length && + !opts.disableOxcRecommendation + ) { + /* + * Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and: + * No babel config is set + * No other plugin is using the `api.reactBabel` hook + * It is not disabled by the user + */ + config.logger.warn( + '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', + ) + } + if (hooks.length > 0) { runPluginOverrides = (babelOptions, context) => { hooks.forEach((hook) => hook(babelOptions, context, config)) From 63290ea58f441a1dfbeaf260c3e35cd64fec1fac Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 4 Jun 2025 09:16:13 +0200 Subject: [PATCH 09/16] fix: dupe import --- packages/plugin-react-swc/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 8d236e83d..c9891a708 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -12,7 +12,6 @@ import { transform, } from '@swc/core' import type { PluginOption } from 'vite' -import * as vite from 'vite' import { addRefreshWrapper, getPreambleCode, From 0c2fd28ed18ba0378163ee7a0fa03d6642f6ab2c Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 5 Jun 2025 09:45:34 +0200 Subject: [PATCH 10/16] Update packages/plugin-react-swc/src/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 --- packages/plugin-react-swc/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index c9891a708..8ad88ac79 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -78,7 +78,7 @@ type Options = { useAtYourOwnRisk_mutateSwcOptions?: (options: SWCOptions) => void /** - * If set, disables the recommendation to use `vite-plugin-react-oxc` + * If set, disables the recommendation to use `@vitejs/plugin-react-oxc` */ disableOxcRecommendation?: boolean } From d74feca639f1907b5d6e8e3c53c2d03aa74818a5 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 5 Jun 2025 09:45:43 +0200 Subject: [PATCH 11/16] Update packages/plugin-react-swc/src/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 --- packages/plugin-react-swc/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 8ad88ac79..134398ed3 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -164,7 +164,7 @@ const react = (_options?: Options): PluginOption[] => { !options.disableOxcRecommendation ) { config.logger.warn( - '[vite:react-swc] We recommend switching to `vite-plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown', + '[vite:react-swc] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown', ) } }, From 5f19ec9dd8cec21d72c0f6391121d6e5e48dd3b2 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 5 Jun 2025 09:46:08 +0200 Subject: [PATCH 12/16] Update packages/plugin-react/src/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 --- packages/plugin-react/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 587aef819..9fbafa098 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -64,7 +64,7 @@ export interface Options { reactRefreshHost?: string /** - * If set, disables the recommendation to use `vite-plugin-react-oxc` + * If set, disables the recommendation to use `@vitejs/plugin-react-oxc` */ disableOxcRecommendation?: boolean } From 04eabc0e5acd14f33d16176735f37914b8e0c413 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 5 Jun 2025 09:46:21 +0200 Subject: [PATCH 13/16] Update packages/plugin-react-swc/src/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 --- packages/plugin-react-swc/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 134398ed3..deac8453c 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -152,7 +152,7 @@ const react = (_options?: Options): PluginOption[] => { } /* - * Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and: + * Suggest to use @vitejs/plugin-react-oxc if `rolldown-vite` is used and: * No swc plugins are set * mutateSwcOptions is not set * It is not disabled by the user From 4d367b52730185c7d60512d425d9b1425efb3da6 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 5 Jun 2025 09:46:38 +0200 Subject: [PATCH 14/16] Update packages/plugin-react/src/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 --- packages/plugin-react/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 9fbafa098..111623626 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -200,7 +200,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] { * It is not disabled by the user */ config.logger.warn( - '[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', + '[vite:react-babel] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', ) } From a6f523d2b7590facee1e9be06ba84e25f6648d27 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 5 Jun 2025 10:00:10 +0200 Subject: [PATCH 15/16] chore: add changelog --- packages/plugin-react-swc/CHANGELOG.md | 4 ++++ packages/plugin-react/CHANGELOG.md | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/packages/plugin-react-swc/CHANGELOG.md b/packages/plugin-react-swc/CHANGELOG.md index f9166a84c..456128748 100644 --- a/packages/plugin-react-swc/CHANGELOG.md +++ b/packages/plugin-react-swc/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Suggest `@vitejs/plugin-react-oxc` if rolldown-vite is detected [#491](https://github.com/vitejs/vite-plugin-react/pull/491) + +Emit a log which recommends `@vitejs/plugin-react-oxc` when `rolldown-vite` is detected to improve performance and use Oxc under the hood. The warning can be disabled by setting `disableOxcRecommendation: false` in the plugin options. + ### Use `optimizeDeps.rollupOptions` instead of `optimizeDeps.esbuildOptions` for rolldown-vite [#489](https://github.com/vitejs/vite-plugin-react/pull/489) This suppresses the warning about `optimizeDeps.esbuildOptions` being deprecated in rolldown-vite. diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index 7f5082a81..f7d2e708a 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +### Suggest `@vitejs/plugin-react-oxc` if rolldown-vite is detected [#491](https://github.com/vitejs/vite-plugin-react/pull/491) + +Emit a log which recommends `@vitejs/plugin-react-oxc` when `rolldown-vite` is detected to improve performance and use Oxc under the hood. The warning can be disabled by setting `disableOxcRecommendation: false` in the plugin options. + + ### Use `optimizeDeps.rollupOptions` instead of `optimizeDeps.esbuildOptions` for rolldown-vite [#489](https://github.com/vitejs/vite-plugin-react/pull/489) This suppresses the warning about `optimizeDeps.esbuildOptions` being deprecated in rolldown-vite. From 2ac7620a12f2f451bcf5bd3b58ba7ab91d8ac1a6 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 5 Jun 2025 10:01:01 +0200 Subject: [PATCH 16/16] chore: remove verbose comments --- packages/plugin-react-swc/src/index.ts | 6 ------ packages/plugin-react/src/index.ts | 6 ------ 2 files changed, 12 deletions(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index deac8453c..9f9f6738b 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -151,12 +151,6 @@ const react = (_options?: Options): PluginOption[] => { ) } - /* - * Suggest to use @vitejs/plugin-react-oxc if `rolldown-vite` is used and: - * No swc plugins are set - * mutateSwcOptions is not set - * It is not disabled by the user - */ if ( 'rolldownVersion' in vite && !options.plugins && diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 111623626..8103e2f25 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -193,12 +193,6 @@ export default function viteReact(opts: Options = {}): PluginOption[] { !hooks.length && !opts.disableOxcRecommendation ) { - /* - * Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and: - * No babel config is set - * No other plugin is using the `api.reactBabel` hook - * It is not disabled by the user - */ config.logger.warn( '[vite:react-babel] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown', )