-
-
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 12 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 |
---|---|---|
|
@@ -2,7 +2,6 @@ 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 { VitestCache } from '../cache' | ||
import { rootDir } from '../../paths' | ||
|
||
export function resolveOptimizerConfig(_testOptions: DepsOptimizationOptions | undefined, viteOptions: DepOptimizationOptions | undefined, testConfig: InlineConfig) { | ||
|
@@ -24,8 +23,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 +36,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 = testConfig.cache !== false ? testConfig.cache?.dir : 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', | ||
}, | ||
}, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ import { expect, test } from 'vitest' | |
import { importMetaUrl } from '@vitest/test-dep-url' | ||
|
||
test('import.meta.url', () => { | ||
expect(importMetaUrl).toContain('/node_modules/.vitest/deps/') | ||
expect(importMetaUrl).toContain('/node_modules/.vite/deps/') | ||
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 think this change means that Vite and Vitest are going to share the same folder for pre-bundling (aka Though Vitest side of pre-bundling is disabled by default since v1.3.0 #5156, would this mean that users will not be able to run 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. For example, in current main branch, running these two commands at the same time seems to work even with DEBUG=vite:deps pnpm -C examples/react-testing-lib dev
DEBUG=vite:deps pnpm -C examples/react-testing-lib test 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. Thanks for the question and example, I tried running 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 see. I just tried and it looks like it actually works, but it might be a bit coincidental. When running I think I need to dig into this further to see whether buggy behavior is reproducible. Actually I think Vitest already uses 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. @sheremet-va Do you know if it's safe to use a same directory 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 don't think it's safe, that's why this option was introduced in the first place 🤔 The main reason back then was that we were not sure if 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. It looks like Vite deletes only I agree we should avoid overlapping 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. Thanks for the suggestion, I'll update with |
||
}) |
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.
Maybe it would be better to add a handler that throws an error? I think CLI will still propagate the value even if it's not defined in a schema
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.
Yeah I noticed that, I'll update it later