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 717b5cc commit 4850f43
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions custom/wasm-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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 @@ -100,12 +100,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 4850f43

Please sign in to comment.