Bug description
If asc is used to compile multiple files, and one of those files is resolved via --path, then memory set in that file is not persisted. If --path is not used, the memory persists.
Steps to reproduce
index.html
<!DOCTYPE html>
<html>
<body>
<script type="module">
import { printThing, adjustThing } from "./main.js";
printThing();
adjustThing();
printThing();
</script>
</body>
</html>
main.ts
import { thing } from "utils/module";
export function printThing(): void {
console.log(`Thing value is ${thing.value}`);
}
lib/utils/types.ts
export class Thing {
value: i32 = 0;
}
lib/utils/module.ts
import { Thing } from "./types";
export const thing = new Thing();
thing.value = 123;
export function adjustThing(): void {
thing.value = 456;
}
Compile with
asc main.ts lib/utils/module.ts -o main.wasm --bindings esm --path lib
Run npx http-server
Open http://localhost:8080 and open the debug console.
The output should be:
Thing value is 123
Thing value is 123
This shows that the memory is not being set correctly.
Now to prove it is a --path issue, we will use relative imports, instead of path imports. Change main.ts to:
import { thing } from "./lib/utils/module";
export function printThing(): void {
console.log(`Thing value is ${thing.value}`);
}
Compile with
asc main.ts lib/utils/module.ts -o main.wasm --bindings esm
Visit in the browser (you may need to hard refresh). The output will be
Thing value is 123
Thing value is 456
This shows that the memory is being set correctly.
AssemblyScript version
0.27.31
Bug description
If
ascis used to compile multiple files, and one of those files is resolved via--path, then memory set in that file is not persisted. If--pathis not used, the memory persists.Steps to reproduce
index.html
main.ts
lib/utils/types.ts
lib/utils/module.ts
Compile with
asc main.ts lib/utils/module.ts -o main.wasm --bindings esm --path libRun
npx http-serverOpen
http://localhost:8080and open the debug console.The output should be:
This shows that the memory is not being set correctly.
Now to prove it is a
--pathissue, we will use relative imports, instead of path imports. Change main.ts to:Compile with
asc main.ts lib/utils/module.ts -o main.wasm --bindings esmVisit in the browser (you may need to hard refresh). The output will be
This shows that the memory is being set correctly.
AssemblyScript version
0.27.31