@@ -274,8 +274,8 @@ impl<'a> Context<'a> {
274
274
shim. push_str (
275
275
"
276
276
const wasmModule = new WebAssembly.Module(bytes);
277
- const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
278
- wasm = wasmInstance .exports;
277
+ instance = new WebAssembly.Instance(wasmModule, imports);
278
+ wasm = instance .exports;
279
279
module.exports.__wasm = wasm;
280
280
" ,
281
281
) ;
@@ -345,8 +345,8 @@ impl<'a> Context<'a> {
345
345
throw new Error(`Unsupported protocol: ${{wasm_url.protocol}}`);
346
346
}}
347
347
348
- const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
349
- const wasm = wasmInstance .exports;" ,
348
+ const instance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
349
+ const wasm = instance .exports;" ,
350
350
module_name = module_name
351
351
)
352
352
}
@@ -385,6 +385,7 @@ impl<'a> Context<'a> {
385
385
script_src = new URL(document.currentScript.src, location.href).toString();
386
386
}\n " ,
387
387
) ;
388
+ js. push_str ( "let instance;\n " ) ;
388
389
js. push_str ( "let wasm;\n " ) ;
389
390
init = self . gen_init ( needs_manual_start, None ) ?;
390
391
footer. push_str ( & format ! (
@@ -400,6 +401,7 @@ impl<'a> Context<'a> {
400
401
} => {
401
402
js. push_str ( & self . generate_node_imports ( ) ) ;
402
403
404
+ js. push_str ( "let instance;\n " ) ;
403
405
js. push_str ( "let wasm;\n " ) ;
404
406
405
407
for ( id, js) in crate :: sorted_iter ( & self . wasm_import_definitions ) {
@@ -464,6 +466,7 @@ impl<'a> Context<'a> {
464
466
465
467
self . imports_post . push_str (
466
468
"\
469
+ let instance;
467
470
let wasm;
468
471
export function __wbg_set_wasm(val) {
469
472
wasm = val;
@@ -481,6 +484,7 @@ impl<'a> Context<'a> {
481
484
// expose the same initialization function as `--target no-modules`
482
485
// as the default export of the module.
483
486
OutputMode :: Web => {
487
+ self . imports_post . push_str ( "let instance;\n " ) ;
484
488
self . imports_post . push_str ( "let wasm;\n " ) ;
485
489
init = self . gen_init ( needs_manual_start, Some ( & mut imports) ) ?;
486
490
footer. push_str ( "export { initSync }\n " ) ;
@@ -860,7 +864,7 @@ impl<'a> Context<'a> {
860
864
module = new WebAssembly.Module(module);
861
865
}}
862
866
863
- const instance = new WebAssembly.Instance(module, imports);
867
+ instance = new WebAssembly.Instance(module, imports);
864
868
865
869
return finalizeInit(instance, module);
866
870
}}
@@ -3498,6 +3502,11 @@ impl<'a> Context<'a> {
3498
3502
format ! ( "init.__wbindgen_wasm_module" )
3499
3503
}
3500
3504
3505
+ Intrinsic :: Instance => {
3506
+ assert_eq ! ( args. len( ) , 0 ) ;
3507
+ "wasm" . to_string ( )
3508
+ }
3509
+
3501
3510
Intrinsic :: Memory => {
3502
3511
assert_eq ! ( args. len( ) , 0 ) ;
3503
3512
let mut memories = self . module . memories . iter ( ) ;
0 commit comments