Open paadam94 opened 3 years ago
Hey @paadam94 were you able to get this working? I'm stuck on the same thing.
I figured it out @jjant @paadam94
I had a very similar issue, and when I reorganized my code to be the same as paadam's, I got the exact same error.
It turns out that both paadam and I forgot to include the #[wasm_bindgen]
above the definition of the Universe
struct.
So:
pub struct Universe {
width: u32,
height: u32,
cells: Vec<Cell>,
}
needs to instead be
#[wasm_bindgen]
pub struct Universe {
width: u32,
height: u32,
cells: Vec<Cell>,
}
with this change the error went away
This is actually in the book, but its snuck in there and easy to miss (as we all apparently did)
This is definitely the same issue as #265
Linking them to "link all the things"
@apc518 omg i love you. this is one of those learning moments where ill run into something similar in the future and know how to handle it even though the error wasnt very clear!
I also have this issue. For some reason the frontend (www) can't refer to wasm properly. My workaround is to refer to the pkg
directly in my index.js
import { Universe, Cell } from "../pkg";
In foreword, I'm sorry if this is not the place for asking for help. I got this error, when I tried to build at the end of chapter 4.4 - rust implementation
lib.rs:
wasm-pack-build version - 0.9.1 rustc version - rustc 1.49.0 (e1884a8e3 2020-12-29)