create Source with Buffers for WASM

This commit is contained in:
Tobias Koppers 2018-10-18 11:59:57 +02:00
parent 4947a5ac71
commit d5ad14813f
1 changed files with 5 additions and 2 deletions

View File

@ -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));
}
}