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§
- Json
Text - 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 sequencewhere a token reads them (not in a comment). - Module
Data - A module record’s non-value state.
- Module
Export - Module
Host - The embedder’s module loader.
- Module
Import - One import: from request
request, the exportname(Nonefor the namespace), into bindingbinding. - Module
Initializer - A hoisted declaration initialized while linking:
undefined, or a function from childchildof the root unit (nameddefaultfor an anonymous default export). - Module
Request - One requested module.
- Module
Tables - The tables of a compiled module.
Enums§
- Export
Target - Where an exported name comes from.
- Module
Binding - What one binding of a module’s root function is.
- Module
Phase - The step of running a module that threw.
- Module
Source - A loaded module: its root function (instantiated in the
Compiler) and its tables, or the text of a JSON module.
Type Aliases§
- Load
Module Fn - Loads and compiles the module named
name. - Normalize
Fn - Resolves
specifieragainst the module or script namedreferrer.