mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-29 13:06:06 +03:00
Simplified the preamble
This commit is contained in:
parent
aa6487b6f1
commit
ffdb8a6a32
@ -231,9 +231,9 @@ impl<'a> Context<'a> {
|
||||
format!("var wasm;")
|
||||
} else if self.config.no_modules {
|
||||
format!("
|
||||
return fetch('{module}_bg.wasm')
|
||||
window.{module} = fetch('{module}_bg.wasm')
|
||||
.then(response => response.arrayBuffer())
|
||||
.then(buffer => WebAssembly.instantiate(buffer, __js_exports))
|
||||
.then(buffer => WebAssembly.instantiate(buffer, {{ './{module}': __exports }}))
|
||||
.then(({{instance}}) => {{
|
||||
wasm = instance.exports;
|
||||
return wasm;
|
||||
@ -249,22 +249,11 @@ impl<'a> Context<'a> {
|
||||
|
||||
let js = if self.config.no_modules {
|
||||
format!("
|
||||
(function (root, factory) {{
|
||||
if (typeof define === 'function' && define.amd) {{
|
||||
define([], factory);
|
||||
}} else {{
|
||||
root.{module} = factory();
|
||||
}}
|
||||
}}(typeof self !== 'undefined' ? self : this, function() {{
|
||||
let wasm;
|
||||
const __js_exports = {{}};
|
||||
const __exports = {{}};
|
||||
{globals}
|
||||
__js_exports['./{module}'] = __exports;
|
||||
{import_wasm}
|
||||
}}))
|
||||
let wasm;
|
||||
const __exports = {{}};
|
||||
{globals}
|
||||
{import_wasm}
|
||||
",
|
||||
module = module_name,
|
||||
globals = self.globals,
|
||||
import_wasm = import_wasm,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user