Debian Codegraph @

.cargo/vendor/wasm-bindgen/guide/src/reference/attributes/on-js-imports/module.md

raw
1 # `module = "blah"`
2
3 The `module` attributes configures the module from which items are imported. For
4 example,
5
6 ```rust
7 #[wasm_bindgen(module = "wu/tang/clan")]
8 extern "C" {
9 type ThirtySixChambers;
10 }
11 ```
12
13 generates JavaScript import glue like:
14
15 ```js
16 import { ThirtySixChambers } from "wu/tang/clan";
17 ```
18
19 If a `module` attribute is not present, then the global scope is used
20 instead. For example,
21
22 ```rust
23 #[wasm_bindgen]
24 extern "C" {
25 fn illmatic() -> u32;
26 }
27 ```
28
29 generates JavaScript import glue like:
30
31 ```js
32 let illmatic = this.illmatic;
33 ```
34
35 Note that if the string specified with `module` starts with `./`, `../`, or `/`
36 then it's interpreted as a path to a [local JS snippet](../../js-snippets.html).
37 If this doesn't work for your use case you might be interested in the
38 [`raw_module` attribute](raw_module.html)