Wasm 模块


¥Wasm modules

稳定性: 1 - 实验性的

¥Stability: 1 - Experimental

--experimental-wasm-modules 标志下,支持导入 WebAssembly 模块实例和 WebAssembly 源阶段导入。

¥Importing both WebAssembly module instances and WebAssembly source phase imports are supported under the --experimental-wasm-modules flag.

这两种集成方式都符合 WebAssembly 的 ES 模块集成提案 规范。

¥Both of these integrations are in line with the ES Module Integration Proposal for WebAssembly.

实例导入允许将任何 .wasm 文件作为普通模块导入,并支持其模块导入。

¥Instance imports allow any .wasm files to be imported as normal modules, supporting their module imports in turn.

例如,index.js 包含:

¥For example, an index.js containing:

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

在以下条件下执行:

¥executed under:

node --experimental-wasm-modules index.mjs 

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

¥would provide the exports interface for the instantiation of library.wasm.