Skip to content

Commit eb285ea

Browse files
authoredJun 1, 2023
fix(optimizer): always respect optimizeDeps even if include/exclude is overridden (#3488)
1 parent ab3e085 commit eb285ea

File tree

1 file changed

+13
-2
lines changed
  • packages/vitest/src/node/plugins

1 file changed

+13
-2
lines changed
 

‎packages/vitest/src/node/plugins/index.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,25 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t
152152
else {
153153
const cacheDir = preOptions.cache !== false ? preOptions.cache?.dir : null
154154
optimizeConfig.cacheDir = cacheDir ?? 'node_modules/.vitest'
155+
const exclude = [
156+
'vitest',
157+
...builtinModules,
158+
...optimizer.exclude || [],
159+
...viteConfig.optimizeDeps?.exclude || [],
160+
]
161+
const include = [
162+
...optimizer.include || [],
163+
...viteConfig.optimizeDeps?.include || [],
164+
].filter((n: string) => !exclude.includes(n))
165+
155166
optimizeConfig.optimizeDeps = {
156167
...viteConfig.optimizeDeps,
157168
...optimizer,
158169
noDiscovery: true,
159170
disabled: false,
160171
entries: [],
161-
exclude: ['vitest', ...builtinModules, ...(optimizer.exclude || viteConfig.optimizeDeps?.exclude || [])],
162-
include: (optimizer.include || viteConfig.optimizeDeps?.include || []).filter((n: string) => n !== 'vitest'),
172+
exclude,
173+
include,
163174
}
164175
}
165176
Object.assign(config, optimizeConfig)

0 commit comments

Comments
 (0)
Please sign in to comment.