So I have been learning Rust Wasm, and started this example: Wasm Game of Life.
I got it working, no issue there. However, I do not want to use a JS Bundler, and the example is using webpack.
So I build for web for importing as static file
wasm-pack build --release --target web
My code was built fine. However, I ran into two error.
First, I cannot init an object:
Uncaught TypeError: Cannot read properties of undefined (reading 'obj_new') at Obj.new
Pretty much what I did was:
import {Obj} from "./pkg/test_wasm.js";
const obj = Obj.new();
And it failed at:
static new() {
const ret = wasm.obj_new(); <-- crash here
return Obj.__wrap(ret);
}
Basically, it did not work, at the first line after import. Honestly I am lost. I can't event init the object.
Any help would be appreciated.
Second, I cannot import memory:
In the example with JS bundle, I can do something like:
import { memory } from "test_wasm/test_wasm_bg";
Did not really work. I tried to import memory from the typescript file:
import {memory} from "./pkg/test_wasm_bg.wasm.d.ts";
And I got:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "video/mp2t". Strict MIME type checking is enforced for module scripts per HTML spec.
So yeah, I ran into two big issues.
Anyhelp is appreciated. Thank you.