Skip to content

Commit

Permalink
fix rustwasm#3307: do nothing when calling init multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanvivien committed Feb 17, 2023
1 parent 1aee7e8 commit 1436eb4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl<'a> Context<'a> {
script_src = new URL(document.currentScript.src, location.href).toString();
}\n",
);
js.push_str("let wasm;\n");
js.push_str("let wasm = undefined;\n");
init = self.gen_init(needs_manual_start, None)?;
footer.push_str(&format!(
"{} = Object.assign(init, {{ initSync }}, __exports);\n",
Expand Down Expand Up @@ -866,6 +866,8 @@ impl<'a> Context<'a> {
}}
async function init(input{init_memory_arg}) {{
if (wasm !== undefined) return wasm;
{default_module_path}
const imports = getImports();
Expand Down

0 comments on commit 1436eb4

Please sign in to comment.