@@ -27,8 +27,8 @@ export interface Options {
2727 jsxRuntime ?: 'classic' | 'automatic'
2828 /**
2929 * 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
3232 */
3333 jsxImportSource ?: string
3434 /**
@@ -314,6 +314,12 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
314314 name : 'vite:react-refresh' ,
315315 enforce : 'pre' ,
316316 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+ } ,
317323 resolve : {
318324 dedupe : [ 'react' , 'react-dom' ] ,
319325 } ,
@@ -340,24 +346,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
340346 } ,
341347 }
342348
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 ]
361350}
362351
363352viteReact . preambleCode = preambleCode
0 commit comments