diff --git a/src/wranglerjs/bundle.rs b/src/wranglerjs/bundle.rs index c49a89a84..a04aafc45 100644 --- a/src/wranglerjs/bundle.rs +++ b/src/wranglerjs/bundle.rs @@ -42,6 +42,22 @@ impl Bundle { wasm_file.write_all(&wasm)?; } + script_file.write_all( + format!( + r#" + WebAssembly.instantiateStreaming = + async function instantiateStreaming(req, importObject) {{ + const module = {}; + return {{ + module, + instance: new WebAssembly.Instance(module, importObject) + }} + }}; + "#, + self.get_wasm_binding() + ) + .as_bytes(), + )?; script_file.write_all(wranglerjs_output.script.as_bytes())?; Ok(()) @@ -56,7 +72,7 @@ impl Bundle { } pub fn get_wasm_binding(&self) -> String { - "wasm".to_string() + "WASM_MODULE".to_string() } pub fn script_path(&self) -> PathBuf { diff --git a/wranglerjs/index.js b/wranglerjs/index.js index 690070368..2e8fa887f 100644 --- a/wranglerjs/index.js +++ b/wranglerjs/index.js @@ -95,29 +95,6 @@ function filterByExtension(ext) { const compiler = webpack(config); const fullConfig = compiler.options; - // Override the {FetchCompileWasmTemplatePlugin} and inject our new runtime. - const [ - fetchCompileWasmTemplatePlugin - ] = compiler.hooks.thisCompilation.taps.filter( - tap => tap.name === "FetchCompileWasmTemplatePlugin" - ); - fetchCompileWasmTemplatePlugin.fn = function(compilation) { - const mainTemplate = compilation.mainTemplate; - const generateLoadBinaryCode = () => ` - // Fake fetch response - Promise.resolve({ - arrayBuffer() { return Promise.resolve(${args["wasm-binding"]}); } - }); - `; - - const plugin = new WasmMainTemplatePlugin({ - generateLoadBinaryCode, - mangleImports: false, - supportsStreaming: false - }); - plugin.apply(mainTemplate); - }; - let lastHash = ""; const compilerCallback = (err, stats) => { if (err) {