Wasm 模块


稳定性: 1 - 实验

--experimental-wasm-modules 标志下支持导入 Web Assembly 模块,允许将任何 .wasm 文件作为普通模块导入,同时还支持它们的模块导入。

此集成符合用于 Web Assembly 的 ES 模块集成提案

例如,index.mjs 包含:

import * as M from './module.wasm';
console.log(M);

在以下条件下执行:

node --experimental-wasm-modules index.mjs

将为 module.wasm 的实例化提供导出接口。

Stability: 1 - Experimental

Importing Web Assembly modules is supported under the --experimental-wasm-modules flag, allowing any .wasm files to be imported as normal modules while also supporting their module imports.

This integration is in line with the ES Module Integration Proposal for Web Assembly.

For example, an index.mjs containing:

import * as M from './module.wasm';
console.log(M);

executed under:

node --experimental-wasm-modules index.mjs

would provide the exports interface for the instantiation of module.wasm.