[英]magic header not detected File was processed with these loaders: * ./node_modules/wasm-loader/index.js
I have issue using webassembly wasm file in React with Typescript.我在 React 中使用 webassembly wasm 文件时遇到问题 Typescript。
I have install react-app-rewired
and wasm-loader
and my config-overrides.js:我已经安装了react-app-rewired
rewired 和wasm-loader
以及我的 config-overrides.js:
const path = require('path');
module.exports = function override(config, env) {
const wasmExtensionRegExp = /\.wasm$/;
config.resolve.extensions.push('.wasm');
config.module.rules.forEach(rule => {
(rule.oneOf || []).forEach(oneOf => {
if (oneOf.loader && oneOf.loader.indexOf('file-loader') >= 0) {
// make file-loader ignore WASM files
oneOf.exclude.push(wasmExtensionRegExp);
}
});
});
// add a dedicated loader for WASM
config.module.rules.push({
test: wasmExtensionRegExp,
include: path.resolve(__dirname, 'src'),
use: [{ loader: require.resolve('wasm-loader'), options: {} }]
});
return config;
};
in package json I change to use "start": "react-app-rewired start",
but still have the same error.在 package json 我改用"start": "react-app-rewired start",
但仍然有同样的错误。 How can solve this issue?如何解决这个问题? Thank you!谢谢!
"magic header not detected" indicates that your .wasm
file is not really a .wasm
file. “magic header not detected”表示您的.wasm
文件不是真正的.wasm
文件。 Can you verify that it is a valid file using wasm-objdump
?您可以使用wasm-objdump
验证它是一个有效文件吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.