mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-24 10:11:34 +00:00
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:
@ -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 {
|
||||
|
@ -21,6 +21,7 @@ pub struct Bindgen {
|
||||
nodejs: bool,
|
||||
browser: bool,
|
||||
no_modules: bool,
|
||||
no_modules_global: Option<String>,
|
||||
debug: bool,
|
||||
typescript: bool,
|
||||
demangle: bool,
|
||||
@ -42,6 +43,7 @@ impl Bindgen {
|
||||
nodejs: false,
|
||||
browser: false,
|
||||
no_modules: false,
|
||||
no_modules_global: None,
|
||||
debug: false,
|
||||
typescript: false,
|
||||
demangle: true,
|
||||
@ -68,6 +70,11 @@ impl Bindgen {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn no_modules_global(&mut self, name: &str) -> &mut Bindgen {
|
||||
self.no_modules_global = Some(name.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn debug(&mut self, debug: bool) -> &mut Bindgen {
|
||||
self.debug = debug;
|
||||
self
|
||||
|
Reference in New Issue
Block a user