Module code was compiled as eval code, so every expression statement
stored its value as the completion value. A module never reads that value,
and the stored value stayed reachable until the module finished, so a large
temporary result counted against the heap limit for the rest of the module.
Module code now pops the value, as function code does. Script and eval code
keep their completion values, including through finally blocks.
- A read or write that reaches a module namespace through a prototype
chain checks the export's temporal dead zone and refuses the write;
for-in over a namespace lists its keys without reading the exports.
- `delete this.x` and a delete inside `with` remove only the property,
so a later `let x` is still a SyntaxError.
- An arrow function's `length` is configurable.
- `let [` cannot start the body of if, else, while, for or a label.
- A specifier with an unpaired surrogate parses; the loader refuses it
before reading any file.
- Each module's code counts against the heap from when it loads, and
export lookups use an index instead of copying export lists.
- A module reached again through another path is not read or counted
against the 32 MiB source limit again, its relative imports are read
from the folder the file is in, and on Windows two files whose names
differ only in case in a case-sensitive folder stay two modules.
- `$.evalFile` in a module reads beside that module.
- `script.run` takes `module`, and a `.mjs` file picked on the web runs
as a module.
- Without `es2015`, the compiler does not collect the block scopes that
only Annex B block functions read.
- The test262 runner grades negative module tests by their phase and
counts panics on their own.
script.run, File > Scripts and Other Script... run a file ending in .mjs as a
module: strict code with import and export declarations at its top level.
parse_module reads the module grammar and its early errors, and
Realm::start_module and Realm::run_module load the module graph through the
host, link every import before any module runs, and run each module once,
after the modules it imports. Imports read the exporting binding each time;
a read before initialization is a ReferenceError and an assignment is a
TypeError. import * as ns gives a namespace object that is not extensible,
and Object.isSealed and Object.isFrozen on it throw a ReferenceError for an
export its module has not initialized.
Specifiers are ./ and ../ paths to .mjs and .js files, resolved against the
importing file and read only through the script's file scope, so a module
can import only from the script's folder and the folders below it. Bare
names, URLs and absolute paths are a SyntaxError that names the specifier.
Module files count against the #include limits: 64 files besides the
script, 16 imports deep. import and export stay syntax errors in .js and
.jsx scripts; import() is not read. script.listInstalled lists .mjs files.
The test262 runner also runs the module tests under language/module-code,
import and export, reading the fixture files they import from the suite.