-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): deprecate cache.dir
option
#5229
Changes from 6 commits
c77c545
bd44d67
b42c227
91f5d50
f156b7e
e3341fb
11456b8
30e122b
02b08a0
82c5c2a
b43a562
f831b7a
4a39b08
a7cd849
9cb6ec2
1aff021
147e6b9
f0bab3b
8af373b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { searchForWorkspaceRoot, version as viteVersion } from 'vite' | ||
import type { DepOptimizationOptions, ResolvedConfig, UserConfig as ViteConfig } from 'vite' | ||
import { dirname } from 'pathe' | ||
import type { DepsOptimizationOptions, InlineConfig } from '../../types' | ||
import type { DepsOptimizationOptions } from '../../types' | ||
import { VitestCache } from '../cache' | ||
import { rootDir } from '../../paths' | ||
|
||
export function resolveOptimizerConfig(_testOptions: DepsOptimizationOptions | undefined, viteOptions: DepOptimizationOptions | undefined, testConfig: InlineConfig) { | ||
export function resolveOptimizerConfig(_testOptions: DepsOptimizationOptions | undefined, viteOptions: DepOptimizationOptions | undefined, viteConfig: ViteConfig) { | ||
const testOptions = _testOptions || {} | ||
const newConfig: { cacheDir?: string; optimizeDeps: DepOptimizationOptions } = {} as any | ||
const [major, minor, fix] = viteVersion.split('.').map(Number) | ||
|
@@ -24,8 +24,6 @@ export function resolveOptimizerConfig(_testOptions: DepsOptimizationOptions | u | |
} | ||
} | ||
else { | ||
const root = testConfig.root ?? process.cwd() | ||
const cacheDir = testConfig.cache !== false ? testConfig.cache?.dir : undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need to handle it during the deprecation period There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated it. I'm new to the optimizer config, not sure if this is right change, could you please help to review again? Thank you so much! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect |
||
const currentInclude = (testOptions.include || viteOptions?.include || []) | ||
const exclude = [ | ||
'vitest', | ||
|
@@ -39,7 +37,7 @@ export function resolveOptimizerConfig(_testOptions: DepsOptimizationOptions | u | |
|
||
const include = (testOptions.include || viteOptions?.include || []).filter((n: string) => !exclude.includes(n)) | ||
|
||
newConfig.cacheDir = cacheDir ?? VitestCache.resolveCacheDir(root, cacheDir, testConfig.name) | ||
newConfig.cacheDir = viteConfig.test?.cache ? VitestCache.resolveCacheDir(viteConfig.cacheDir!, viteConfig.test?.name) : undefined | ||
newConfig.optimizeDeps = { | ||
...viteOptions, | ||
...testOptions, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
test: { | ||
cache: { | ||
dir: 'cache/.vitest-custom', | ||
}, | ||
}, | ||
cacheDir: 'cache/.vitest-custom', | ||
test: {}, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
cacheDir: 'cache/.vitest-base', | ||
test: { | ||
pool: 'forks', | ||
cache: { | ||
dir: 'cache/.vitest-base', | ||
}, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you need to manually pass
null
todir
subcommand instead of removing itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for letting me know, I've updated it.