我得到了一个使用 emscripten 编译的 webassembly 模块。现在我正在尝试使用 expressjs 在网页中提供它。
我已经尝试按照这个要点来通过 webpack 包含 webassembly,包括我发现的一个修改,因为这个要点有点旧。
webpack 看起来像这样:
const path = require('path');
module.exports = {
optimization: {
mangleWasmImports: false
},
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './dist/'),
filename: 'dynamic-graph.bundle.js'
},
target: "web",
module: {
rules: [
// Emscripten JS files define a global. With `exports-loader` we can
// load these files correctly (provided the global’s name is the same
// as the file name).
{
test: /fourd\.js$/,
loader: "exports-loader"
},
// wasm files …Run Code Online (Sandbox Code Playgroud)