File tree 1 file changed +20
-12
lines changed
packages/plugin-react/src 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { readFileSync } from 'node:fs'
4
4
import type * as babelCore from '@babel/core'
5
5
import type { ParserOptions , TransformOptions } from '@babel/core'
6
6
import { createFilter } from 'vite'
7
+ import * as vite from 'vite'
7
8
import type { Plugin , PluginOption , ResolvedConfig } from 'vite'
8
9
import {
9
10
addRefreshWrapper ,
@@ -124,10 +125,24 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
124
125
enforce : 'pre' ,
125
126
config ( ) {
126
127
if ( opts . jsxRuntime === 'classic' ) {
127
- return {
128
- esbuild : {
129
- jsx : 'transform' ,
130
- } ,
128
+ if ( 'rolldownVersion' in vite ) {
129
+ return {
130
+ oxc : {
131
+ jsx : {
132
+ runtime : 'classic' ,
133
+ // disable __self and __source injection even in dev
134
+ // as this plugin injects them by babel and oxc will throw
135
+ // if development is enabled and those properties are already present
136
+ development : false ,
137
+ } ,
138
+ } ,
139
+ }
140
+ } else {
141
+ return {
142
+ esbuild : {
143
+ jsx : 'transform' ,
144
+ } ,
145
+ }
131
146
}
132
147
} else {
133
148
return {
@@ -203,14 +218,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
203
218
] )
204
219
}
205
220
206
- if (
207
- opts . jsxRuntime === 'classic' &&
208
- isJSX &&
209
- // OXC injects self and source so these plugins are not needed for rolldown-vite
210
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
211
- // @ts -ignore -- this.meta.rolldownVersion only exists in rolldown-vite
212
- ! this . meta . rolldownVersion
213
- ) {
221
+ if ( opts . jsxRuntime === 'classic' && isJSX ) {
214
222
if ( ! isProduction ) {
215
223
// These development plugins are only needed for the classic runtime.
216
224
plugins . push (
You can’t perform that action at this time.
0 commit comments