Skip to content

Commit bb9ee38

Browse files
committed
ignore all subpaths of dependencies
1 parent 6ca880e commit bb9ee38

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

vite.config.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ function generateEntries(...indexDirs: string[]) {
3030
function generateExternalDependencies(
3131
...dependencies: Array<Record<string, string> | undefined>
3232
) {
33-
return dependencies.reduce((keys, dependencies) => {
34-
keys.push(...Object.keys(dependencies || {}))
33+
return dependencies.reduce(
34+
(keys, dependencies) => {
35+
for (const dependency of Object.keys(dependencies || {})) {
36+
// Add the dependency (e.g. "react")
37+
keys.push(dependency)
38+
// Add all subpaths of the dependency (e.g. "react/jsx-runtime")
39+
// eslint-disable-next-line no-useless-escape
40+
keys.push(new RegExp(`^${dependency}\/.*`))
41+
}
3542

36-
return keys
37-
}, [] as string[])
43+
return keys
44+
},
45+
[] as Array<string | RegExp>,
46+
)
3847
}
3948

4049
const viteConfig = defineConfig({
@@ -122,15 +131,6 @@ const viteConfig = defineConfig({
122131
...builtinModules.map(m => `node:${m}`),
123132
...builtinModules,
124133
"../../../dist/server/entry-server.js",
125-
"react/jsx-runtime",
126-
"react-dom/client",
127-
"react-dom/server",
128-
"@emotion/server/create-instance",
129-
"@reduxjs/toolkit/query",
130-
"@reduxjs/toolkit/query/react",
131-
"dayjs/locale/en-gb",
132-
"@mui/x-date-pickers/AdapterDayjs",
133-
"@mui/material/OverridableComponent",
134134
],
135135
},
136136
// Vite will output both your built .js file and a corresponding .js.map

0 commit comments

Comments
 (0)