Skip to content

Commit 0700d04

Browse files
committed
fix: add react-dom in optimizeOps to handle CJS script.
1 parent 63b2e38 commit 0700d04

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/plugin-react/src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,12 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
268268
},
269269
}
270270

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

0 commit comments

Comments
 (0)