wasm-bindgen
wasm-bindgen copied to clipboard
Uncaught (in promise) LinkError: import object field '__wbg_error_09919627ac0992f5' is not a Function + JsValue(undefined) instead of objects
that happens when I import a package generated by wasm-pack
https://github.com/nshen/vite-plugin-wasm-pack this partially solved it
now the problem is that despite me passing an object into a function, what goes into wasm is read as null.
invalid type: null, expected struct ScheduleImportConfigV2 at line 1 column 4
yeah so I've triple checked it with console.log(myInput) on javascript side just beforre passing that into a wasm function
console.log(myInput) // {a: 1, b: 2}
myWasmPackage.handle_my_input(myInput)
and in rust it's
#[wasm_bindgen(skip_typescript)]
pub fn handle_my_input(my_data: JsValue) -> JsResult<JsValue> {
console_log!(
"handle_my_input :: {:#?}",
my_data
);
// ...
}
and it prints
handle_my_input :: JsValue(undefined)
https://github.com/Niedzwiedzw/vite-wasm-pack-error-showcase here's a repository showcasing this problem
I'm attempting to reproduce it but encountered an error building your Rust code:
Could you please test it using my plugin https://www.npmjs.com/package/vite-plugin-wasm and the bundler target?