@@ -27,8 +27,8 @@ export interface Options {
27
27
jsxRuntime ?: 'classic' | 'automatic'
28
28
/**
29
29
* Control where the JSX factory is imported from.
30
- * This option is ignored when `jsxRuntime` is not `"automatic"`.
31
- * @default "react"
30
+ * https://esbuild.github.io/api/#jsx-import-source
31
+ * For TS projects this is read from tsconfig
32
32
*/
33
33
jsxImportSource ?: string
34
34
/**
@@ -314,6 +314,12 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
314
314
name : 'vite:react-refresh' ,
315
315
enforce : 'pre' ,
316
316
config : ( ) => ( {
317
+ optimizeDeps : {
318
+ // We can't add `react-dom` because the dependency is `react-dom/client`
319
+ // for React 18 while it's `react-dom` for React 17. We'd need to detect
320
+ // what React version the user has installed.
321
+ include : [ 'react' ] ,
322
+ } ,
317
323
resolve : {
318
324
dedupe : [ 'react' , 'react-dom' ] ,
319
325
} ,
@@ -340,24 +346,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
340
346
} ,
341
347
}
342
348
343
- const reactJsxRuntimeId = 'react/jsx-runtime'
344
- const reactJsxDevRuntimeId = 'react/jsx-dev-runtime'
345
- const viteReactJsx : Plugin = {
346
- name : 'vite:react-jsx' ,
347
- enforce : 'pre' ,
348
- config ( ) {
349
- return {
350
- optimizeDeps : {
351
- // We can't add `react-dom` because the dependency is `react-dom/client`
352
- // for React 18 while it's `react-dom` for React 17. We'd need to detect
353
- // what React version the user has installed.
354
- include : [ reactJsxRuntimeId , reactJsxDevRuntimeId , 'react' ] ,
355
- } ,
356
- }
357
- } ,
358
- }
359
-
360
- return [ viteBabel , viteReactRefresh , useAutomaticRuntime && viteReactJsx ]
349
+ return [ viteBabel , viteReactRefresh ]
361
350
}
362
351
363
352
viteReact . preambleCode = preambleCode
0 commit comments