File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed
packages/plugin-react/src Expand file tree Collapse file tree 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'
44import type * as babelCore from '@babel/core'
55import type { ParserOptions , TransformOptions } from '@babel/core'
66import { createFilter } from 'vite'
7+ import * as vite from 'vite'
78import type { Plugin , PluginOption , ResolvedConfig } from 'vite'
89import {
910 addRefreshWrapper ,
@@ -124,10 +125,24 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
124125 enforce : 'pre' ,
125126 config ( ) {
126127 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+ }
131146 }
132147 } else {
133148 return {
@@ -203,14 +218,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
203218 ] )
204219 }
205220
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 ) {
214222 if ( ! isProduction ) {
215223 // These development plugins are only needed for the classic runtime.
216224 plugins . push (
You can’t perform that action at this time.
0 commit comments