【发布时间】:2021-09-16 15:53:00
【问题描述】:
我正在尝试在我的 gatsby 项目中使用 rust webassembly 书中的 rust 模块。当我尝试像这样导入模块时:
import { <rust-struct> } from 'rust_wasm_npm_package';
我收到以下错误:
The module seem to be a WebAssembly module, but module is not flagged as WebAssembly module for
webpack.
BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental
feature.
You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based
on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated).
For files that transpile to WebAssembly, make sure to set the module type in the 'module.rules'
section of the config (e. g. 'type: "webassembly/async"').
(Source code omitted for this binary file)
我无法将实验选项添加到 gatsby 配置文件,所以我不确定将 wasm-pack rust 模块导入 gatsby 的最佳方法是什么。
【问题讨论】:
标签: rust gatsby webassembly