Skip to main content

Module modules

Module modules 

Source
Expand description

How a realm finds the modules a program imports.

Three sources, consulted in order: the ModuleRegistry of native modules (the standard library plus whatever extensions serve), any resolver/loader pairs the host chained in, and finally files on disk under a ModulePolicy. The same registry backs require(), so the CommonJS and ES forms of a native module cannot drift.

Re-exports§

pub use file::FileLoader;
pub use file::FileResolver;
pub use file::ModulePolicy;
pub use registry::DeclareFn;
pub use registry::ModuleRegistry;
pub use registry::NamespaceFn;
pub use registry::NativeLoader;
pub use registry::NativeModule;
pub use registry::NativeResolver;
pub use require::RequireHook;

Modules§

file
Module loading from disk, under a policy.
registry
The native modules a realm serves, and the one table they come from.
require
globalThis.require, for the native specifiers only.

Structs§

LoaderChain
A chain of host-supplied loaders, tried in order.
ResolverChain
A chain of host-supplied resolvers, tried in order.

Type Aliases§

BoxLoader
A loader a host supplies at runtime.
BoxResolver
A resolver a host supplies at runtime, erased so the builder can hold any number of them.