大网数据广告活动
Web 标准与前端开发

AbstractModuleSource

· 52CE 我爱测

An **_AbstractModuleSource_** object represents the compiled source of a module obtained with `import source` or `import.source()`. There is no directly visible `AbstractModuleSource` constructor.

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.

  • Object/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 a string based on the constructor's identity, such as "WebAssembly.Module" or "ModuleSource". It returns undefined if the this value is not an instance of one of the module source subclasses. This property is used in Object.prototype.toString().

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。