Expand description
Boa’s implementation of the ECMAScript’s module system.
This module contains theModule type, which represents anAbstract Module Record,aModuleLoader trait for custom module loader implementations, andSimpleModuleLoader,the defaultModuleLoader forContext which can be used for most simple usecases.
Every module roughly follows the same lifecycle:
- Parse using
Module::parse. - Load all its dependencies using
Module::load. - Link its dependencies together using
Module::link. - Evaluate the module and its dependencies using
Module::evaluate.
TheModuleLoader trait allows customizing the “load” step on the lifecycleof a module, which allows doing things like fetching modules from urls, having multiple“modpaths” from where to import modules, or using Rust futures to avoid blocking the main threadon loads.
More information:
Modules§
- embedded
- Embedded module loader. Creates a
ModuleLoaderinstance that containsfiles embedded in the binary at build time.
Structs§
- Idle
Module Loader - A module loader that throws when trying to load any modules.
- MapModule
Loader - A module loader that uses a map of specifier -> Module to resolve.If the module was not registered, it will not be resolved.
- Module
- ECMAScript’sAbstract module record.
- Module
Namespace - Module namespace exotic object.
- Simple
Module Loader - A simple module loader that loads modules relative to a root path.
- Synthetic
Module - ECMAScript’sSynthetic Module Records.
- Synthetic
Module Initializer - The initializing steps of a
SyntheticModule.
Enums§
- Referrer
- The referrer from which a load request of a module originates.
Traits§
- Into
JsModule - A trait to convert a type into a JS module.
- Module
Loader - Module loading related host hooks.
Functions§
- resolve_
module_ specifier - Resolves paths from the referrer and the specifier, normalize the paths and ensure the pathis within a base. If the base is empty, that last verification will be skipped.