Add a --no-modules-global flag

This can be used to configure the name of the global that's initialized so it's
not unconditionally `wasm_bindgen`.

Closes #145
This commit is contained in:
Alex Crichton
2018-04-19 13:33:58 -07:00
parent 212703671a
commit 0ade4b8cac
4 changed files with 19 additions and 2 deletions

View File

@ -295,11 +295,15 @@ impl<'a> Context<'a> {
return;
}});
}};
self.wasm_bindgen = Object.assign(init, __exports);
self.{global_name} = Object.assign(init, __exports);
}})();
",
globals = self.globals,
module = module_name,
global_name = self.config.no_modules_global
.as_ref()
.map(|s| &**s)
.unwrap_or("wasm_bindgen"),
)
} else {
let import_wasm = if self.config.nodejs {