import source

The import source statement behaves like regular import statements, but it can only import a module using the default import syntax, and results in an object representing the module's unevaluated source code. The module can be imperatively evaluated later using a method provided by the source code object.

To use import source, the target module has to support source phase imports. Currently, only WebAssembly modules support source phase imports, which result in WebAssembly.Module objects. JavaScript module source objects will be added by the ECMAScript Module Phase Imports proposal.

Syntax

js
import source x from "module-name";
x

Name that will refer to the module source object. Must be a valid JavaScript identifier.

module-name

The module to import from. Handled the same way as the module-name in regular import statements.

Import attributes are also supported in import source statements, and are handled the same way as in regular import statements.

Description

Examples

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also