mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 02:07:10 +01:00
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.