Skip to content

Commit

Permalink
fix: add react-dom in optimizeOps to handle CJS script. (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiger3018 authored Oct 16, 2024
1 parent 7a7e339 commit e8a923f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,12 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
},
}

// We can't add `react-dom` because the dependency is `react-dom/client`
// for React 18 while it's `react-dom` for React 17. We'd need to detect
// what React version the user has installed.
const dependencies = ['react', jsxImportDevRuntime, jsxImportRuntime]
const dependencies = [
'react',
'react-dom',
jsxImportDevRuntime,
jsxImportRuntime,
]
const staticBabelPlugins =
typeof opts.babel === 'object' ? opts.babel?.plugins ?? [] : []
const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins)
Expand Down

0 comments on commit e8a923f

Please sign in to comment.