close
Skip to content

feat: promote fsModuleCache to a top-level option - #10734

Merged
sheremet-va merged 2 commits into
mainfrom
feat/fs-module-cache
Jul 20, 2026
Merged

feat: promote fsModuleCache to a top-level option#10734
sheremet-va merged 2 commits into
mainfrom
feat/fs-module-cache

Conversation

@sheremet-va

Copy link
Copy Markdown
Member

Move fsModuleCache and fsModuleCachePath out of experimental (fsModuleCache defaults to off). The cache is a single workspace-root node_modules/.vitest-cache directory shared by every project. The old experimental.* options are migrated with a deprecation warning.

Fixes #10701

@netlify

netlify Bot commented Jul 7, 2026

Copy link
Copy Markdown

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit d6d6637
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a5dd5a4584091000803b3c1
😎 Deploy Preview https://deploy-preview-10734--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sheremet-va
sheremet-va force-pushed the feat/fs-module-cache branch from c6f19ee to 7283040 Compare July 7, 2026 16:38
Move `fsModuleCache` and `fsModuleCachePath` out of `experimental`
(`fsModuleCache` defaults to off) and stabilize the plugin API: the
`defineCacheKeyGenerator` hook and the `api.vitest.ignoreFsModuleCache`
opt-out. `fsModuleCachePath` can be set per project, falling back to the
root's cache directory (`node_modules/.vitest-cache` by default), while the
lockfile metadata stays shared across the workspace. The deprecated
`experimental.*` options, `experimental_defineCacheKeyGenerator` and
`api.vitest.experimental.ignoreFsModuleCache` keep working with a deprecation
notice.

Fixes #10701
@sheremet-va
sheremet-va force-pushed the feat/fs-module-cache branch from 7283040 to df25a89 Compare July 7, 2026 16:39
@sheremet-va

Copy link
Copy Markdown
Member Author

Should we enable it by default only in non-CI environments? There is usually a performance hit for the first (cold) run and in CI there is usually no caching anyway

hi-ogawa
hi-ogawa previously approved these changes Jul 15, 2026

@hi-ogawa hi-ogawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment on lines +66 to +77
On the other hand, if your plugin should not affect the cache key, you can opt out by setting `api.vitest.ignoreFsModuleCache` to `true`:

```js [vitest.config.js]
import { defineConfig } from 'vitest/config'

export default defineConfig({
plugins: [
{
name: 'vitest-cache',
api: {
vitest: {
ignoreFsModuleCache: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember the use case of per plugin ignoreFsModuleCache. From what I can imagine, this only basically plugin's existence to not affect cache key, so it's like adding/removing the plugin conditionally for different test run:

plugins: [
  process.env.SOME_CONDITION && {
    ...some logic...
    api: { vitest: { ignoreFsModuleCache: true }}
  }
]

Is this the right use case? The option name ignoreFsModuleCache and documentation here doesn't seem to give much intuition. Not mean to bike-shed now and no blocking though.

@sheremet-va sheremet-va Jul 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, kind of. It will be ignored when generating a cache key. This is mostly useful for library authors or when calling vitest programmatically (we even pass down this flag ourselves in a fee places). For config it doesn’t make much sense because config content (its file content - the string) affects the cache key.

This is for plugins that don’t affect transformation. If you move the order, it also won’t affect it for example.

@sheremet-va
sheremet-va merged commit 78ed73a into main Jul 20, 2026
20 of 26 checks passed
@sheremet-va
sheremet-va deleted the feat/fs-module-cache branch July 20, 2026 08:04
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stabilize fsModuleCache

2 participants