diff --git a/packages/vitest/src/node/create.ts b/packages/vitest/src/node/create.ts index cf64cfaedd52..5019a08505ad 100644 --- a/packages/vitest/src/node/create.ts +++ b/packages/vitest/src/node/create.ts @@ -36,6 +36,7 @@ export async function createVitest( // this will make "mode": "test" | "benchmark" inside defineConfig mode: options.mode || mode, plugins: await VitestPlugin(options, ctx), + test: options, } const server = await createViteServer( diff --git a/packages/vitest/src/node/plugins/optimizer.ts b/packages/vitest/src/node/plugins/optimizer.ts index f75153887d88..6706c79d7ab9 100644 --- a/packages/vitest/src/node/plugins/optimizer.ts +++ b/packages/vitest/src/node/plugins/optimizer.ts @@ -11,16 +11,12 @@ export function VitestOptimizer(): Plugin { const webOptimizer = resolveOptimizerConfig( testConfig.deps?.optimizer?.web, viteConfig.optimizeDeps, - testConfig, ) const ssrOptimizer = resolveOptimizerConfig( testConfig.deps?.optimizer?.ssr, viteConfig.ssr?.optimizeDeps, - testConfig, ) - viteConfig.cacheDir - = webOptimizer.cacheDir || ssrOptimizer.cacheDir || viteConfig.cacheDir viteConfig.optimizeDeps = webOptimizer.optimizeDeps viteConfig.ssr ??= {} viteConfig.ssr.optimizeDeps = ssrOptimizer.optimizeDeps diff --git a/packages/vitest/src/node/plugins/utils.ts b/packages/vitest/src/node/plugins/utils.ts index a17458c6b64b..4fffed0d6a64 100644 --- a/packages/vitest/src/node/plugins/utils.ts +++ b/packages/vitest/src/node/plugins/utils.ts @@ -3,19 +3,17 @@ import type { ResolvedConfig, UserConfig as ViteConfig, } from 'vite' -import type { DepsOptimizationOptions, InlineConfig } from '../types/config' +import type { DepsOptimizationOptions } from '../types/config' import { dirname } from 'pathe' import { searchForWorkspaceRoot, version as viteVersion } from 'vite' import { rootDir } from '../../paths' -import { VitestCache } from '../cache' export function resolveOptimizerConfig( _testOptions: DepsOptimizationOptions | undefined, viteOptions: DepOptimizationOptions | undefined, - testConfig: InlineConfig, ) { const testOptions = _testOptions || {} - const newConfig: { cacheDir?: string; optimizeDeps: DepOptimizationOptions } + const newConfig: { optimizeDeps: DepOptimizationOptions } = {} as any const [major, minor, fix] = viteVersion.split('.').map(Number) const allowed @@ -32,7 +30,6 @@ export function resolveOptimizerConfig( testOptions.enabled ??= false } if (!allowed || testOptions?.enabled !== true) { - newConfig.cacheDir = undefined newConfig.optimizeDeps = { // experimental in Vite >2.9.2, entries remains to help with older versions disabled: true, @@ -40,9 +37,6 @@ export function resolveOptimizerConfig( } } else { - const root = testConfig.root ?? process.cwd() - const cacheDir - = testConfig.cache !== false ? testConfig.cache?.dir : undefined const currentInclude = testOptions.include || viteOptions?.include || [] const exclude = [ 'vitest', @@ -60,8 +54,6 @@ export function resolveOptimizerConfig( (n: string) => !exclude.includes(n), ) - newConfig.cacheDir - = cacheDir ?? VitestCache.resolveCacheDir(root, cacheDir, testConfig.name) newConfig.optimizeDeps = { ...viteOptions, ...testOptions,