AbstractModuleSource

An AbstractModuleSource object represents the raw module source code accessible 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 common superclass of all module source subclasses, providing a common interface of utility methods for all module source subclasses. 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.

js
import source modSource from "./module.wasm";

new (Object.getPrototypeOf(modSource.constructor))();
// TypeError: Abstract class AbstractModuleSource not directly constructable

You rarely need to construct an AbstractModuleSource object directly, since the module source objects are created by the JavaScript engine when you use import source or import.source().

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.constructor is the hidden AbstractModuleSource constructor function, but each module source subclass also defines its own constructor property.

AbstractModuleSource.prototype[Symbol.toStringTag]

The initial value of the AbstractModuleSource.prototype[Symbol.toStringTag] property is a getter that returns the same string as the module source constructor's name. It returns undefined if the this value is not one of the module source subclasses. This property is used in Object.prototype.toString().

Specifications

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

Browser compatibility

See also