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
Route loader fs and package.json operations through toggleable
wrappers so the VFS can resolve and load modules from mounted paths.
When no VFS is mounted, the wrappers take a null-check fast path with
zero overhead.
Hooks:
- loaderStat / loaderReadFile / toRealPath / loaderLegacyMainResolve /
loaderGetFormatOfExtensionlessFile in
lib/internal/modules/helpers.js, consumed by cjs/loader.js,
esm/resolve.js, esm/load.js and esm/get_format.js.
- loaderReadPackageJSON / loaderGetNearestParentPackageJSON /
loaderGetPackageScopeConfig / loaderGetPackageType, consumed by
package_json_reader.js.
- setLoaderFsOverrides / setLoaderPackageOverrides install / clear
all hooks; clearRealpathCache exposes the helpers.js realpath
cache so deregister can flush it.
lib/internal/vfs/setup.js installs the overrides on first
registerVFS and clears every JS-side loader cache (CJS _pathCache,
CJS stat cache, realpath cache, package.json cache) on every
deregister. The overrides themselves are uninstalled when the last
VFS is removed so the fast path is fully restored.
legacyMainResolve / extensionless-format behavior matches the C++
binding; package.json validation matches src/node_modules.cc
(silently omit non-string main, throw on non-string name/type, etc).
The "DO NOT depend on patchability" warnings in esm/load.js and
esm/resolve.js are preserved and now point at node:vfs and
module.registerHooks() as the formal hook mechanisms.
Tests cover require / import / module-hooks / package.json / cache
invalidation / cleanup-cycle scenarios under --experimental-vfs.
Signed-off-by: Matteo Collina <hello@matteocollina.com>
0 commit comments