Skip to main content

Module module

Module module 

Source
Expand description

ECMAScript modules.

A module record is an internal record (tag Module) whose slots hold the module’s environment (the scope its root function captures: one cell per binding), its root function, its namespace, its evaluation error and its top-level promise capability; the rest is ModuleData. Every record stays in the registry for the runtime’s life (QuickJS keeps its modules too), so the records name each other by ObjectId.

An import binding is the exporter’s cell, installed in the importer’s environment while linking: a live binding is a shared cell, read by the loop’s LoadCaptured with no new opcode. Linking and evaluation are the specification’s (Link, InnerModuleLinking, Evaluate, InnerModuleEvaluation and the asynchronous-module machinery for top-level await). Modules load synchronously through the host’s ModuleHost when they are first requested.

Structs§

JsonText
A JSON module’s text: UTF-16 units, and the units that stand for bytes of invalid UTF-8 in the file, which QuickJS’s byte-level parser rejects with Bad UTF-8 sequence where a token reads them (not in a comment).
ModuleData
A module record’s non-value state.
ModuleExport
ModuleHost
The embedder’s module loader.
ModuleImport
One import: from request request, the export name (None for the namespace), into binding binding.
ModuleInitializer
A hoisted declaration initialized while linking: undefined, or a function from child child of the root unit (named default for an anonymous default export).
ModuleRequest
One requested module.
ModuleTables
The tables of a compiled module.

Enums§

ExportTarget
Where an exported name comes from.
ModuleBinding
What one binding of a module’s root function is.
ModulePhase
The step of running a module that threw.
ModuleSource
A loaded module: its root function (instantiated in the Compiler) and its tables, or the text of a JSON module.

Type Aliases§

LoadModuleFn
Loads and compiles the module named name.
NormalizeFn
Resolves specifier against the module or script named referrer.