File tree 1 file changed +20
-15
lines changed
1 file changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -231,28 +231,33 @@ impl<'a> Context<'a> {
231
231
format ! ( "var wasm;" )
232
232
} else if self . config . no_modules {
233
233
format ! ( "
234
- window.{module} = fetch('{module}_bg.wasm')
235
- .then(response => response.arrayBuffer())
236
- .then(buffer => WebAssembly.instantiate(buffer, {{ './{module}': __exports }}))
237
- .then(({{instance}}) => {{
238
- wasm = instance.exports;
239
- return wasm;
240
- }})
241
- .catch(error => {{
242
- console.log('Error loading wasm module `{module}`:', error);
243
- throw error;
244
- }});
234
+ window.wasm_bindgen.init = function(__wasm_path) {{
235
+ return fetch(__wasm_path)
236
+ .then(response => response.arrayBuffer())
237
+ .then(buffer => WebAssembly.instantiate(buffer, {{ './{module}': __exports }}))
238
+ .then(({{instance}}) => {{
239
+ wasm = instance.exports;
240
+ return;
241
+ }})
242
+ .catch(error => {{
243
+ console.log('Error loading wasm module `{module}`:', error);
244
+ throw error;
245
+ }});
246
+ }};
245
247
" , module = module_name)
246
248
} else {
247
249
format ! ( "import * as wasm from './{}_bg';" , module_name)
248
250
} ;
249
251
250
252
let js = if self . config . no_modules {
251
253
format ! ( "
252
- let wasm;
253
- const __exports = {{}};
254
- {globals}
255
- {import_wasm}
254
+ (function() {{
255
+ let wasm;
256
+ const __exports = {{}};
257
+ {globals}
258
+ window.wasm_bindgen = Object.assign({{}}, __exports);
259
+ {import_wasm}
260
+ }})();
256
261
" ,
257
262
globals = self . globals,
258
263
import_wasm = import_wasm,
You can’t perform that action at this time.
0 commit comments