wasm-pack icon indicating copy to clipboard operation
wasm-pack copied to clipboard

Critical dependency: the request of a dependency is an expression

Open weihualiu opened this issue 3 years ago • 2 comments

🐛 Bug description

i write below code:

#[wasm_bindgen]
pub fn test() {
    let tmp =  client_random(28);
}

pub fn client_random(len: usize) -> Vec<u8> {
    let mut data: Vec<u8> = vec![0; len];
    let mut rng = rand::thread_rng();
    for i in 0..len {
        let n = match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
            Ok(n) => n.as_millis(),
            Err(_) => 100,
        };
        let ir = rng.gen_range(0..n as usize);
        data[i] = ((n + ir as u128) % 256) as u8;
    }
    data
}

and use

🤔 Expected Behavior

👟 Steps to reproduce

npm run found error:

Critical dependency: the request of a dependency is an expression

🌍 Your environment

Include the relevant details of your environment. wasm-pack version: 0.10.0 rustc version: 1.53.0 (53cb7b09b 2021-06-17)

weihualiu avatar Aug 03 '21 06:08 weihualiu

@weihualiu Hi, have you ever resolved this?

fuho avatar Nov 26 '21 16:11 fuho

This repo is for Rust->WASM Perhaps you meant to file this for wasm-bindgen which is WASM->JS

https://github.com/rustwasm/wasm-bindgen/issues/2706

SebastienGllmt avatar Jan 13 '22 16:01 SebastienGllmt