Expand description
Boa’s implementation of the ECMAScript’s module system.
This module contains the Module type, which represents an Abstract Module Record,
a ModuleLoader trait for custom module loader implementations, and SimpleModuleLoader,
the default ModuleLoader for Context 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.
The ModuleLoader trait allows customizing the “load” step on the lifecycle
of 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 thread
on loads.
More information:
Modules§
- embedded
- Embedded module loader. Creates a
ModuleLoaderinstance that contains files 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’s Abstract 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’s Synthetic 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 path is within a base. If the base is empty, that last verification will be skipped.