diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index 4ca9be4d622faa..6effdb8391be83 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -159,11 +159,25 @@ translators.set('wasm', async function(url) { } const imports = - WebAssembly.Module.imports(compiled).map(({ module }) => module); + WebAssembly.Module.imports(compiled).map(({ module }) => module).filter((module) => module != 'env'); const exports = WebAssembly.Module.exports(compiled).map(({ name }) => name); return createDynamicModule(imports, exports, url, (reflect) => { - const { exports } = new WebAssembly.Instance(compiled, reflect.imports); + const env = { + __memory_base: 0, + memory: new WebAssembly.Memory({ + initial: 512 + }), + __table_base: 0, + table: new WebAssembly.Table({ + initial: 0, + element: 'anyfunc' + }) + }; + const { exports } = new WebAssembly.Instance(compiled, { + ...reflect.imports, + env + }); for (const expt of Object.keys(exports)) reflect.exports[expt].set(exports[expt]); });