Repository navigation
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
hi-ogawa
requested changes
Sep 15, 2026
Comment on lines
+294
to
+301
| const importedModules = await Promise.all(cachedModule.importedUrls.map(async (url) => { | ||
| return environment.moduleGraph.ensureEntryFromUrl(url).catch(() => null) | ||
| })) | ||
| if (importedModules.some(moduleNode => moduleNode?.file && !existsSync(moduleNode.file))) { | ||
| debugFs?.(`cached module ${moduleGraphModule.id} has a missing dependency, re-transforming`) | ||
| moduleGraphModule.transformResult = null | ||
| return undefined | ||
| } |
Collaborator
There was a problem hiding this comment.
The idea looks close but Vite defines moduleNode.file for any modules including virtual module, so this fs bail out should be excluded for those modules. Otherwise the module that imports virtual modules become not cacheable, which is likely going too far and such virtual module plugin can opt-out the strategy on their own.
The reasonable limiting condition would be likely of this form:
vitest/packages/vitest/src/node/environments/fetchModule.ts
Lines 222 to 236 in 0598229
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Written by Codex on behalf of @GTUTETTY, who reviewed this contribution and approved submission. GPT-5.6 Luna assisted with implementation and testing.
The filesystem module cache stores resolved import URLs. If an extensionless dependency changes from
b.tstob.tsxwhile its importer stays unchanged, the cached transform still imports the removed file.This checks cached filesystem dependency nodes before Vitest restores a transform. If a resolved file no longer exists, Vitest discards that cache entry and lets Vite resolve the import again. Virtual and non-filesystem entries keep their current behavior.
The regression test runs the same project twice. It warms the cache with
b.ts, renames the file tob.tsx, then confirms the unchanged importer runs on the second pass.Resolves #11246
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:cipnpm buildpnpm typecheckpnpm --dir test/e2e test fs-module-cache-resiliency.test.tspnpm --dir test/e2e test caching.test.tsCI=true pnpm lintDocumentation
Changesets
fix(cache): revalidate cached imports.