Skip to content

Commit 8ee3ad1

Browse files
chore: use config.logger.warn
1 parent 2b0a0ce commit 8ee3ad1

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

packages/plugin-react-swc/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type Options = {
7878
useAtYourOwnRisk_mutateSwcOptions?: (options: SWCOptions) => void
7979

8080
/**
81-
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
81+
* If set, disables the recommendation to use `vite-plugin-react-oxc`
8282
*/
8383
disableOxcRecommendation?: boolean
8484
}
@@ -160,7 +160,7 @@ const react = (_options?: Options): PluginOption[] => {
160160
!options.useAtYourOwnRisk_mutateSwcOptions &&
161161
!options.plugins
162162
) {
163-
console.warn(
163+
config.logger.warn(
164164
'[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',
165165
)
166166
}

packages/plugin-react/src/index.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface Options {
6464
reactRefreshHost?: string
6565

6666
/**
67-
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
67+
* If set, disables the recommendation to use `vite-plugin-react-oxc`
6868
*/
6969
disableOxcRecommendation?: boolean
7070
}
@@ -136,16 +136,6 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
136136
name: 'vite:react-babel',
137137
enforce: 'pre',
138138
config() {
139-
if (
140-
'rolldownVersion' in vite &&
141-
!opts.disableOxcRecommendation &&
142-
!opts.babel
143-
) {
144-
// Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no babel config is set
145-
console.warn(
146-
'[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown',
147-
)
148-
}
149139
if (opts.jsxRuntime === 'classic') {
150140
if ('rolldownVersion' in vite) {
151141
return {
@@ -184,6 +174,17 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
184174
config.command === 'build' ||
185175
config.server.hmr === false
186176

177+
if (
178+
'rolldownVersion' in vite &&
179+
!opts.disableOxcRecommendation &&
180+
!opts.babel
181+
) {
182+
// Suggest to use vite-plugin-react-oxc if `rolldown-vite` is used and no babel config is set
183+
config.logger.warn(
184+
'[vite:react-babel] We recommend switching to `vite-plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown',
185+
)
186+
}
187+
187188
if ('jsxPure' in opts) {
188189
config.logger.warnOnce(
189190
'[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly.',

0 commit comments

Comments
 (0)