Skip to content

Commit bc4a627

Browse files
authored
fix: add react to optimizeDeps (#9056)
1 parent eec3886 commit bc4a627

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/plugin-react/src/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,10 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
406406
config() {
407407
return {
408408
optimizeDeps: {
409-
include: [reactJsxRuntimeId, reactJsxDevRuntimeId]
409+
// We can't add `react-dom` because the dependency is `react-dom/client`
410+
// for React 18 while it's `react-dom` for React 17. We'd need to detect
411+
// what React version the user has installed.
412+
include: [reactJsxRuntimeId, reactJsxDevRuntimeId, 'react']
410413
}
411414
}
412415
},

0 commit comments

Comments
 (0)