Repository navigation
[vitest-plugin] Fix cached cloudflare:test imports across runs - #16249
Merged
edmundhung merged 2 commits intoOct 14, 2026
Merged
edmundhung merged 2 commits into
edmundhung merged 2 commits into
Conversation
|
workers-devprod
requested review from
a team and
edmundhung
and removed request for
a team
October 13, 2026 19:04
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
Contributor
|
LGTM |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
mattjohnsonpint
force-pushed
the
mjp/fix-vitest-fs-module-cache
branch
from
October 13, 2026 19:16
4e61b81 to
df8fd09
Compare
Vitest filesystem caches retain transformed imports of cloudflare:test, but randomly generated virtual module IDs change between sessions and leave cached imports pointing at unavailable modules. Derive stable IDs from the resolved project root and name while preserving project-specific main dependencies for watch-mode reruns. Remap legacy UUID-based IDs to the current project ID so Vitest can invalidate stale cached importers without requiring users to clear their caches. Extend both module-registry cache regressions to exercise cloudflare:test bindings. Cover main and SELF isolation across cached multi-project runs, and migration from legacy IDs without changing the configuration source or clearing cached files. Validation: filesystem-cache regressions passed with Vitest 5.0.4, legacy-cache migration passed with Vitest 5.0.3, and watch/module-registry compatibility checks passed with Vitest 4.1.0. Build, typechecking, type-aware lint, and formatting passed.
Exercise V8 and Istanbul coverage with fsModuleCache enabled rather than relying on version-dependent defaults. Validation: both coverage tests passed with Vitest 5.0.3; with Vitest 5.0.4, Istanbul passed and V8 still failed due to the separate coverage teardown incompatibility. Build, type-aware lint, and formatting passed.
mattjohnsonpint
force-pushed
the
mjp/fix-vitest-fs-module-cache
branch
from
October 13, 2026 19:20
df8fd09 to
b90d5b5
Compare
2 of 5 tasks
edmundhung
merged commit Oct 14, 2026
b90d5b5
into
edmundhung/fix-vitest-fs-module-cache
57 of 61 checks passed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #16163, targeting its branch. (Thus, no changeset required, since it's in the base PR.)
The filesystem-cache adapter fixes loading transformed modules into workerd, but subsequent runs can still fail when cached tests import
cloudflare:test.The plugin generates a random virtual module ID each session. Cached imports retain the previous ID, which the next session no longer recognizes, causing the virtual module to fall through to filesystem loading.
Derive stable IDs from the resolved project root and name, preserving project isolation and main dependencies for watch-mode reruns. Remap legacy UUID-based IDs so Vitest can invalidate stale cached importers without requiring users to clear their caches.
Regression coverage:
cloudflare:testand read bindings with both module registries.Merge order
edmundhung/fix-vitest-fs-module-cache(PR [vitest-plugin] Fix filesystem module caching #16163).main. It fixes the separate V8 coverage teardown incompatibility introduced by Vitest 5.0.4.edmundhung/fix-vitest-fs-module-cacheonto the updatedmain. Resolve the coverage-fixture conflicts in favor offsModuleCache: true, retaining the V8 teardown fix and expanded regression tests from [vitest-plugin] Fix V8 coverage teardown with Vitest 5.0.4 #16248.main.The explicit
fsModuleCache: truesettings here intentionally conflict with #16248’s temporaryfalseoverrides so those overrides are removed when the fixes are combined.Validation