Skip to content

Commit da5a88b

Browse files
committed
fix react deps optimization
1 parent 56f9268 commit da5a88b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

code/lib/react-dom-shim/src/preset.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,20 @@ export const webpackFinal = async (config: any, options: Options) => {
5050

5151
export const viteFinal = async (config: any, options: Options) => {
5252
const isReactVersion18 = await getIsReactVersion18or19(options);
53+
54+
const optimizeDeps = {
55+
...(config?.optimizeDeps ?? {}),
56+
include: [
57+
...(config.optimizeDeps?.include || []),
58+
...(isReactVersion18 ? ['react-dom/client'] : []),
59+
],
60+
};
61+
5362
if (isReactVersion18) {
54-
return config;
63+
return {
64+
...config,
65+
optimizeDeps,
66+
};
5567
}
5668

5769
const alias = Array.isArray(config.resolve?.alias)
@@ -66,13 +78,7 @@ export const viteFinal = async (config: any, options: Options) => {
6678

6779
return {
6880
...config,
69-
optimizeDeps: {
70-
...(config?.optimizeDeps ?? {}),
71-
include: [
72-
...(config.optimizeDeps?.include || []),
73-
...(isReactVersion18 ? ['react-dom/client'] : []),
74-
],
75-
},
81+
optimizeDeps,
7682
resolve: {
7783
...config.resolve,
7884
alias,

0 commit comments

Comments
 (0)