-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm-bindgen: imported JS function that was not marked as catch
threw an error: Cannot read property 'width' of undefined
#1017
Comments
after a lot of brainstorming, I found out where the problem was, the "wasm-pack" is generating the javascript with error on this line: "wasm_bindgen = Object.assign(init, __exports);" so to solve the problem I replace this line, so: //wasm_bindgen = Object.assign(init, __exports);
wasm_bindgen = init;
/**
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
* @param obj1
* @param obj2
* @returns obj3 a new object based on obj1 and obj2
*/
function merge_options(obj1, obj2) {
var obj3 = {};
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
return obj3;
}
and this line "return wasm;" that is why //return wasm;
return merge_options(wasm, __exports); this should ideally be fixed in a patch release. |
Hi, I tried your code, can get the width example: https://github.com/lencx/learn-wasm
website: https://wasm.nofwl.com/#/rsw/issues/teste use vite to quickly start a wasm project: #1016 |
@lencx my code on github is already with the correction that I informed here. I don't use npm , webpack, react or anything like that. My web frontend projects are done with AngularDart or pure javascript, both my personal projects and my projects in the company where I work. |
Sorry, because just looking at the code example you gave, I don’t know if you don’t use npm, webpack, etc. |
🐛 Bug description
I can't access a property of an HtmlCanvasElement with rust, I'm having trouble using the "photon_rs" library with javascript, because of this bug, so I thought it was a bug with the "photon_rs" lib, so I decided to clone the lib code "photon_rs" and analyze it to find the error, that's when I came across this problem and decided to create a small simple project "hello world", then I could determine that the problem is not in the lib "photon_rs", it seems that the problem is in the "wasm-pack"
🤔 Expected Behavior
access all properties of HTML elements
👟 Steps to reproduce
lib.rs
Cargo.toml
index.html
generated index.js with: wasm-pack build --target no-modules --debug
🌍 Your environment
Windows 10
wasm-pack version: wasm-pack 0.9.1
rustc version: rustc 1.53.0 (53cb7b09b 2021-06-17)
https://github.com/insinfo/photon-test
silvia-odwyer/photon#99
The text was updated successfully, but these errors were encountered: