File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -359,12 +359,16 @@ console.log(value); // 42
359359myVfs .unmount ();
360360```
361361
362- Module identity follows the path: ` __filename ` and ` module.filename `
363- are the plain absolute path of the module under the mount point, and
364- ` import.meta.url ` is the corresponding ` file: ` URL, with no synthetic
365- decorations. Importing the same virtual path repeatedly, including
366- through ` import.meta.resolve() ` , yields the same module instance,
367- exactly as for real files.
362+ CommonJS modules loaded from a mounted VFS are identified by their VFS paths
363+ that start with the mount point. This is reflected in, for example, ` __filename ` and
364+ ` __dirname ` in the module, or the errors stack traces involving functions from
365+ the VFS modules. ES modules in the VFS are similarly identified by the ` file: ` URL of
366+ their VFS paths and this is reflected in e.g. ` import.meta.url ` .
367+
368+ Like modules loaded from the real file system, modules loaded from the VFS are
369+ cached on the first load. When ` require() ` or ` import() ` is used to load an absolute
370+ path or URL that falls under the mounted VFS multiple times, the module is only loaded
371+ once and subsequent calls return the same instance.
368372
369373Calling [ ` vfs.unmount() ` ] [ ] invalidates the modules that were loaded
370374from the mount point: a subsequent ` require() ` or ` import ` of a path
You can’t perform that action at this time.
0 commit comments