Skip to content

Commit

Permalink
fix(vitest): fix "optimizeDeps.disabled" warning on Vite 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Feb 16, 2024
1 parent 7d9b1fb commit 9c01760
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/vitest/src/node/plugins/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function resolveOptimizerConfig(_testOptions: DepsOptimizationOptions | u
if (!allowed && testOptions?.enabled === true)
console.warn(`Vitest: "deps.optimizer" is only available in Vite >= 4.3.2, current Vite version: ${viteVersion}`)
else
// enable by default
// disabled by default
testOptions.enabled ??= false
if (!allowed || testOptions?.enabled !== true) {
newConfig.cacheDir = undefined
Expand Down Expand Up @@ -50,6 +50,17 @@ export function resolveOptimizerConfig(_testOptions: DepsOptimizationOptions | u
include,
}
}

// `optimizeDeps.disabled` is deprecated since v5.1.0-beta.1
// https://github.com/vitejs/vite/pull/15184
if (major >= 5 && minor >= 1) {
if (newConfig.optimizeDeps.disabled) {
newConfig.optimizeDeps.noDiscovery = true
newConfig.optimizeDeps.include = []
}
delete newConfig.optimizeDeps.disabled
}

return newConfig
}

Expand Down

0 comments on commit 9c01760

Please sign in to comment.