You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace the global loader-cache flush in deregisterVFS with a
scope-purge that only drops entries owned by the unmounting VFS.
Per-layer ownership is determined two ways:
- For CJS-style filename-keyed caches (Module._cache,
Module._pathCache, the CJS stat cache, the helpers.js realpath
cache, and the package.json caches) entries are filtered with
`vfs.shouldHandle(filename)`. __filename stays a clean absolute
path so user code that does `path.dirname(__filename)` or similar
is unaffected.
- For the ESM cascaded loader's loadCache, entries are tagged at
resolve time: when finalizeResolution() detects the resolved
path is VFS-owned (via the new loaderGetLayerForPath hook), it
appends `?vfs-layer=<id>` to the URL. The tag surfaces in
`import.meta.url`, matching the cache-busting pattern used by
HMR tooling. On deregister, entries whose URL carries the tag
for the unmounting layer are deleted.
Multi-mount setups no longer pay the cross-VFS cache-warmup
penalty when a single VFS unmounts, and ESM modules loaded from a
VFS become reachable for purge instead of leaking forever in the
cascaded loader.
New helpers exposed for VFS:
- cjs/loader.js: clearStatCacheForVFS
- helpers.js: purgeRealpathCacheForVFS, loaderGetLayerForPath
- package_json_reader.js: purgePackageJSONCacheForVFS
Adds test-vfs-scoped-cache-purge covering both the multi-mount
isolation and the import.meta.url tag visibility.
Refs: #63653
Signed-off-by: Matteo Collina <hello@matteocollina.com>
0 commit comments