我正在尝试加载带有 VSCode 网络扩展的 wasm 模块。
我从the "lsp-web-extension-sample"开始.
在服务器目录中,我使用 wasm-bindgen
创建了一个简单的 rust 库,它使用 wasm-pack
成功编译。当我从 rust pkg 输出调用 init
函数时,它基本上是这样做的:
input = new URL("my-ext.wasm", import.meta.url)
fetch(input)
我收到以下错误:"TypeError: failed to fetch"
,没有更多解释。
使用 @vscode/test-web
以及使用 vsce package
版本进行测试时会发生此错误。
知道要做什么吗?是否有 vscode 的 wasm 网络扩展示例?
最佳答案
我能够通过内联加载 wasm 来完成工作。
webpack.config.js
module: {
rules: [
// ...,
{
test: /\.wasm$/,
type: "asset/inline",
},
],
},
关于visual-studio-code - 在 VSCode Web 扩展中加载 wasm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72600840/