AbstractModuleSource
An AbstractModuleSource object represents the compiled source of a module obtained with import source or import.source(). There is no directly visible AbstractModuleSource constructor.
Description
The AbstractModuleSource constructor (often referred to as %AbstractModuleSource% to indicate its "intrinsicness", since it does not correspond to any global exposed to a JavaScript program) serves as the superclass of all module source subclasses, providing a common interface of utility methods. This constructor is not directly exposed: there is no global AbstractModuleSource property. It is only accessible through Object.getPrototypeOf(moduleSourceObject.constructor) and similar.
AbstractModuleSource objects
JavaScript module source objects will be added by the ECMAScript Module Phase Imports proposal.
Constructor
This object cannot be instantiated directly — attempting to construct it with new throws a TypeError.
import source modSource from "./module.wasm";
new (Object.getPrototypeOf(modSource.constructor))();
// TypeError: Abstract class AbstractModuleSource not directly constructable
Instead, obtain a module source object using import source, import.source(), or a concrete module type's API, such as WebAssembly.Module(). These mechanisms do not call the abstract constructor.
Instance properties
These properties are defined on AbstractModuleSource.prototype and shared by all AbstractModuleSource subclass instances.
AbstractModuleSource.prototype.constructor-
The constructor function that created the instance object.
AbstractModuleSource.prototype.constructoris the hiddenAbstractModuleSourceconstructor function, but each module source subclass also defines its ownconstructorproperty. AbstractModuleSource.prototype[Symbol.toStringTag]-
The initial value of the
AbstractModuleSource.prototype[Symbol.toStringTag]property is a getter that returns a string based on the constructor's identity, such as"WebAssembly.Module"or"ModuleSource". It returnsundefinedif thethisvalue is not an instance of one of the module source subclasses. This property is used inObject.prototype.toString().
Specifications
| Specification |
|---|
| Source Phase Imports> # sec-module-source-objects> |