Skip to main content

Module module

Module module 

Source
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:

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 ModuleLoader instance that contains files embedded in the binary at build time.

Structs§

IdleModuleLoader
A module loader that throws when trying to load any modules.
MapModuleLoader
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.
ModuleNamespace
Module namespace exotic object.
SimpleModuleLoader
A simple module loader that loads modules relative to a root path.
SyntheticModule
ECMAScript’s Synthetic Module Records.
SyntheticModuleInitializer
The initializing steps of a SyntheticModule.

Enums§

Referrer
The referrer from which a load request of a module originates.

Traits§

IntoJsModule
A trait to convert a type into a JS module.
ModuleLoader
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.