mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 15:01:23 +00:00
Removing self from no-modules target (#1995)
This commit is contained in:
@ -197,8 +197,9 @@ impl<'a> Context<'a> {
|
|||||||
) -> Result<(String, String), Error> {
|
) -> Result<(String, String), Error> {
|
||||||
let mut ts = self.typescript.clone();
|
let mut ts = self.typescript.clone();
|
||||||
let mut js = String::new();
|
let mut js = String::new();
|
||||||
if self.config.mode.no_modules() {
|
|
||||||
js.push_str("(function() {\n");
|
if let OutputMode::NoModules { global } = &self.config.mode {
|
||||||
|
js.push_str(&format!("let {};\n(function() {{\n", global));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Depending on the output mode, generate necessary glue to actually
|
// Depending on the output mode, generate necessary glue to actually
|
||||||
@ -215,7 +216,7 @@ impl<'a> Context<'a> {
|
|||||||
js.push_str("let wasm;\n");
|
js.push_str("let wasm;\n");
|
||||||
init = self.gen_init(needs_manual_start, None)?;
|
init = self.gen_init(needs_manual_start, None)?;
|
||||||
footer.push_str(&format!(
|
footer.push_str(&format!(
|
||||||
"self.{} = Object.assign(init, __exports);\n",
|
"{} = Object.assign(init, __exports);\n",
|
||||||
global
|
global
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -441,10 +442,10 @@ impl<'a> Context<'a> {
|
|||||||
"\
|
"\
|
||||||
if (typeof module === 'undefined') {
|
if (typeof module === 'undefined') {
|
||||||
let src;
|
let src;
|
||||||
if (self.document === undefined) {
|
if (document === undefined) {
|
||||||
src = self.location.href;
|
src = location.href;
|
||||||
} else {
|
} else {
|
||||||
src = self.document.currentScript.src;
|
src = document.currentScript.src;
|
||||||
}
|
}
|
||||||
module = src.replace(/\\.js$/, '_bg.wasm');
|
module = src.replace(/\\.js$/, '_bg.wasm');
|
||||||
}"
|
}"
|
||||||
|
Reference in New Issue
Block a user