You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wasm-pack build "<path>" --release --out-name index
My Cargo.toml:
[package]
name = "..."version = "0.0.0"authors = ["..."]
edition = "2018"
[lib]
name = "life"path = "src/lib.rs"crate-type = ["cdylib", "rlib"]
[dependencies]
wasm-bindgen = "0.2.59"getrandom = { version="0.1.14", features = ["wasm-bindgen"]}
# The `console_error_panic_hook` crate provides better debugging of panics by# logging them with `console.error`. This is great for development, but requires# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for# code size when deploying.console_error_panic_hook = "0.1.6"# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size# compared to the default allocator's ~10K. It is slower than the default# allocator, however.wee_alloc = "0.4.5"
[profile.release]
lto = trueopt-level = "s"
Rust file:
use wasm_bindgen::prelude::*;use getrandom::Error;#[wasm_bindgen]pubfnrandom_bool(limit:f32) -> bool{matchrandom(){Ok(val) => val > limit,Err(_) => false,}}pubfnrandom() -> Result<f32,Error>{letmut buf = [0u8;1];
getrandom::getrandom(&mut buf)?;Ok(buf[0]asf32 / 255.0)}
The issue is somewhere related to getrandom as it works (e.g. the dynamic require disappears) when I remove the dependency / related code.
馃實 Your environment
Include the relevant details of your environment.
wasm-pack version: wasm-pack 0.9.1
rustc version: rustc 1.41.0 (5e1a79984 2020-01-27)
The text was updated successfully, but these errors were encountered:
There aren't any great solutions: you can use the browser field in package.json to disable the crypto module, or maybe getrandom can be changed so that it uses inline_js to do the require call (though that has some other issues of its own).
Or maybe getrandom could use this solution, which actually seems like the most viable option.
馃悰 Bug description
I'm getting the following warning from webpack:
The problem is this line:
馃 Expected Behavior
There should be no warning I guess.
馃憻 Steps to reproduce
Command I used to build my crate:
My
Cargo.toml
:Rust file:
The issue is somewhere related to getrandom as it works (e.g. the dynamic require disappears) when I remove the dependency / related code.
馃實 Your environment
Include the relevant details of your environment.
wasm-pack version:
wasm-pack 0.9.1
rustc version:
rustc 1.41.0 (5e1a79984 2020-01-27)
The text was updated successfully, but these errors were encountered: