module = "blah" - The `wasm-bindgen` Guide

## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# `module = "blah"`

The `module` attributes configures the module from which items are imported. For example,

    #![allow(unused)]
    fn main() {
    #[wasm_bindgen(module = "wu/tang/clan")]
    extern "C" {
        type ThirtySixChambers;
    }
    }

generates JavaScript import glue like:

    import { ThirtySixChambers } from "wu/tang/clan";

If a `module` attribute is not present, then the global scope is used instead. For example,

    #![allow(unused)]
    fn main() {
    #[wasm_bindgen]
    extern "C" {
        fn illmatic() -> u32;
    }
    }

generates JavaScript import glue like:

    let illmatic = this.illmatic;

Note that if the string specified with `module` starts with `./`, `../`, or `/` then it's interpreted as a path to a local JS snippet. If this doesn't work for your use case you might be interested in the `raw_module` attribute