Skip to content

Commit

Permalink
Fixing Webpack require warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauan authored and josephlr committed Apr 27, 2020
1 parent 54b4c8d commit f1c264d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/wasm32_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn getrandom_init() -> Result<RngSource, Error> {
return Ok(RngSource::Browser(crypto));
}

return Ok(RngSource::Node(node_require("crypto")));
return Ok(RngSource::Node(MODULE.require("crypto")));
}

#[wasm_bindgen]
Expand All @@ -102,12 +102,17 @@ extern "C" {
#[wasm_bindgen(method, js_name = getRandomValues, structural)]
fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]);

#[wasm_bindgen(js_name = require)]
fn node_require(s: &str) -> NodeCrypto;

#[derive(Clone, Debug)]
type NodeCrypto;

#[wasm_bindgen(method, js_name = randomFillSync, structural)]
fn random_fill_sync(me: &NodeCrypto, buf: &mut [u8]);

type NodeModule;

#[wasm_bindgen(js_name = module)]
static MODULE: NodeModule;

#[wasm_bindgen(method)]
fn require(this: &NodeModule, s: &str) -> NodeCrypto;
}

0 comments on commit f1c264d

Please sign in to comment.