Open philip-peterson opened 4 years ago
I believe this should work with js_name = default
, does that work for you?
Sorry, what would that look like syntactically? I tried this but it led to a syntax error:
#[wasm_bindgen(module = "pi")]
extern "C" {
#[wasm_bindgen(js_name = "default")]
pi: f64;
}
Have you tried using static pi: f64
perhaps?
Same problem here, also when trying to import a class (via type
).
Okay, got this working for a class by adding js_class
:
#[wasm_bindgen(module = "/mymodule.esm.js")]
extern "C" {
type MyClass;
#[wasm_bindgen(constructor, js_class = "default")]
fn new() -> MyClass;
}
Motivation
It would be nice if there was a syntax for doing default import of modules. Many npm modules are distributed with the only export being the default export.
Proposed Solution
Alternatives
There may be another way to import a library such as
pi
, but I am new to wasm-bindgen and couldn't find anything in the docs that provides instructions.