From d5ad14813fac3e86523fadbb1c10b0edae27ea91 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 18 Oct 2018 11:59:57 +0200 Subject: [PATCH] create Source with Buffers for WASM --- lib/wasm/WebAssemblyGenerator.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/wasm/WebAssemblyGenerator.js b/lib/wasm/WebAssemblyGenerator.js index c8262f0ff..26b3449bf 100644 --- a/lib/wasm/WebAssemblyGenerator.js +++ b/lib/wasm/WebAssemblyGenerator.js @@ -385,7 +385,8 @@ class WebAssemblyGenerator extends Generator { // TODO remove this casts when webpack-sources is fixed // source() should have return type (string | Buffer) const sourceAsAny = /** @type {TODO} */ (source); - let bin = /** @type {ArrayBuffer} */ (sourceAsAny); + const buf = /** @type {Buffer} */ (sourceAsAny); + const bin = buf.buffer; const usedExports = moduleGraph.getUsedExports(module); const initFuncId = t.identifier( @@ -456,7 +457,9 @@ class WebAssemblyGenerator extends Generator { const newBin = transform(bin); - return new RawSource(newBin); + const newBuf = Buffer.from(newBin); + + return new RawSource(/** @type {TODO} */ (newBuf)); } }