assemblyscript
assemblyscript copied to clipboard
Raw bindings get undefined "exports" var
Bug description
Expected exports to contain wasm exports, instead getting undefined value.
Steps to reproduce
Run asc with --bindings raw. In build/release.js line 24 now contains:
const { exports } = await WebAssembly.instantiate(module, adaptedImports);
I think this should instead be
const { instance } = await WebAssembly.instantiate(module, adaptedImports);
const { exports } = instance.exports;
I haven't done a PR before, so I'll describe the proposed change:
In src/bindings/js.ts line 646:
replace sb.push("const { exports } = await WebAssembly.instantiate(module"); with sb.push("const { instance } = await WebAssembly.instantiate(module");
then at line 652 insert:
indent(sb, this.indentLevel); sb.push("const { exports } = instance.exports;\n");
AssemblyScript version
v0.27.36
It should work if you pass in a WebAssembly.Module instance instead of an ArrayBuffer. Confusingly, WebAssembly.instantiate has two different return types, depending on the type of the argument.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!