Skip to content

Commit 9962c70

Browse files
committed
Update Module::require internal comments
Signed-off-by: Joe Richey <[email protected]>
1 parent e0c93b1 commit 9962c70

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/js.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ extern "C" {
122122
#[wasm_bindgen(method, js_name = randomFillSync, catch)]
123123
fn random_fill_sync(this: &NodeCrypto, buf: &mut [u8]) -> Result<(), JsValue>;
124124

125-
// We use a "module" object here instead of just annotating require() with
126-
// js_name = "module.require", so that Webpack doesn't give a warning. See:
125+
// Ideally, we would just use `fn require(s: &str)` here. However, doing
126+
// this causes a Webpack warning. So we instead return the function itself
127+
// and manually invoke it using call1. This also lets us to check that the
128+
// function actually exists, allowing for better error messages. See:
127129
// https://github.com/rust-random/getrandom/issues/224
130+
// https://github.com/rust-random/getrandom/issues/256
128131
type Module;
129132
#[wasm_bindgen(getter, static_method_of = Module, js_class = module, js_name = require, catch)]
130133
fn require_fn() -> Result<JsValue, JsValue>;

0 commit comments

Comments
 (0)