moduleImpors(cases where @external or declare are used) together with the --importMemory flag, the glue code does not include the imports of the env module.
e.g. build assembly/index.ts with the following settings in asconfig.json.
@external("app", "add")
declare function add(a: i32, b: i32): i32;
export function run(): void {
add(1, 2);
}
Wasm expects imports for app.add and env.memory, but in the actual generated build/release.js, only the app module is imported, and the import for the env module is missing.
While changing app.add to env.add can circumvent this issue, the desired outcome is to control the size of the memory from outside Wasm.
So, the expectation is for code similar to the following to be generated.
error: Uncaught (in promise) TypeError: WebAssembly.instantiate(): Import #1 module="env": module is not an object or function
const { exports } = await WebAssembly.instantiate(module, adaptedImports);
^
Bug description
moduleImpors(cases where
@external
ordeclare
are used) together with the--importMemory
flag, the glue code does not include the imports of theenv
module.e.g. build
assembly/index.ts
with the following settings inasconfig.json
.Wasm expects imports for
app.add
andenv.memory
, but in the actual generatedbuild/release.js
, only theapp
module is imported, and the import for theenv
module is missing.While changing
app.add
toenv.add
can circumvent this issue, the desired outcome is to control the size of the memory from outside Wasm. So, the expectation is for code similar to the following to be generated.Steps to reproduce
asconfig.json
assembly/index.ts
index.js
AssemblyScript version
v0.27.24