Skip to content

Commit e8a923f

Browse files
authored
fix: add react-dom in optimizeOps to handle CJS script. (#375)
1 parent 7a7e339 commit e8a923f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/plugin-react/src/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,12 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
269269
},
270270
}
271271

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

0 commit comments

Comments
 (0)