【发布时间】:2020-04-06 17:47:40
【问题描述】:
我使用create-react-app 和带有wasm 的库,它被称为sax-wasm。
稍微修改一下网页的示例代码我得到了这个:
import { SaxEventType, SAXParser } from 'sax-wasm';
async function loadAndPrepareWasm() {
const saxWasmResponse = await import('sax-wasm/lib/sax-wasm.wasm');
const saxWasmbuffer = await saxWasmResponse.arrayBuffer();
const parser = new SAXParser(SaxEventType.Attribute | SaxEventType.OpenTag, {
highWaterMark: 64 * 1024,
});
const ready = await parser.prepareWasm(new Uint8Array(saxWasmbuffer));
if (ready) {
return parser;
}
}
loadAndPrepareWasm().then(console.log);
当我运行yarn start 命令时,我的构建失败了:
Failed to compile.
./node_modules/sax-wasm/lib/sax-wasm.wasm
Module parse failed: magic header not detected
File was processed with these loaders:
* ./node_modules/file-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
Error: magic header not detected
【问题讨论】:
-
我假设this is the appropriate upstream issue 跟踪/投票。
标签: webpack create-react-app webassembly