Skip to content

Commit

Permalink
fix(optimizer): always respect optimizeDeps even if include/exclude i…
Browse files Browse the repository at this point in the history
…s overridden (#3488)
  • Loading branch information
sheremet-va authored Jun 1, 2023
1 parent ab3e085 commit eb285ea
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/vitest/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,25 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t
else {
const cacheDir = preOptions.cache !== false ? preOptions.cache?.dir : null
optimizeConfig.cacheDir = cacheDir ?? 'node_modules/.vitest'
const exclude = [
'vitest',
...builtinModules,
...optimizer.exclude || [],
...viteConfig.optimizeDeps?.exclude || [],
]
const include = [
...optimizer.include || [],
...viteConfig.optimizeDeps?.include || [],
].filter((n: string) => !exclude.includes(n))

optimizeConfig.optimizeDeps = {
...viteConfig.optimizeDeps,
...optimizer,
noDiscovery: true,
disabled: false,
entries: [],
exclude: ['vitest', ...builtinModules, ...(optimizer.exclude || viteConfig.optimizeDeps?.exclude || [])],
include: (optimizer.include || viteConfig.optimizeDeps?.include || []).filter((n: string) => n !== 'vitest'),
exclude,
include,
}
}
Object.assign(config, optimizeConfig)
Expand Down

0 comments on commit eb285ea

Please sign in to comment.