-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the Bug
After scaffolding a project using https://github.com/rustwasm/wasm-pack-template , I am encountering the follow error when attempting to invoke the stdweb::web::window function (stdweb version 0.4.18), using the npm start command of wasm-pack-template, which uses the webpack WasmPackPlugin:
lib.rs:
use wasm_bindgen::prelude::*;
use web_sys::console;
use stdweb::{web::window};
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[wasm_bindgen(start)]
pub fn main_js() -> Result<(), JsValue> {
#[cfg(debug_assertions)]
console_error_panic_hook::set_once();
let w = window();
Ok(())
}Steps to Reproduce
npm init rust-webpack bug && cd bug(ensure you have at least NPM 6)- Include
stdweb = "0.4.18"as a dependency in yourCargo.toml - Edit
./src/lib.rsto be what's in the description. npm start- A webpage should open up with the error in the console.
If applicable, add a link to a test case (as a zip file or link to a repository we can clone).
Expected Behavior
let win = window();executes without error
Actual Behavior
Attached error is thrown. Exact line below
const __wbg_cargowebsnippet1c30acb32a1994a07c75e804ae9855b43f191d63_74dac66dda56bf23 = function(arg0) {
try {
const ret = Object(_snippets_stdweb_fdcd3965c5b71088_inline370_js__WEBPACK_IMPORTED_MODULE_5__["__cargo_web_snippet_1c30acb32a1994a07c75e804ae9855b43f191d63"])(takeObject(arg0));
_assertNum(ret); // <-----!!! ERROR HERE!!!!!!
return ret;
} catch (e) {
logError(e)
}
};
Additional Context
Thank you to everyone who contributed to this project as well as stdweb. It is a beautiful thing to see collaboration such as koute/stdweb#318 taking place in the open source community. It's truly amazing what can be done when brilliant people from all over the world put their minds together.
