在VSCODE WEB扩展中加载WASM
我正在尝试使用VSCODE Web扩展名加载WASM模块。
我从 - 样本“ 。 在服务器目录中,我使用wasm-bindgen
创建了一个简单的Rust Lib,它使用wasm-pack
成功编译。当我从Rust PKG输出中调用init
函数时,它基本上会这样做:
input = new URL("my-ext.wasm", import.meta.url)
fetch(input)
我会收到以下错误: “ typeError:typeError:dobine for fet fide”
,没有更多解释。 当使用@vscode/test-web
进行测试以及使用VSCE软件包
版本测试时,会发生此错误。
知道该怎么办? VSCODE的WASM Web扩展程序是否有任何示例?
I'm trying to load a wasm module with a VSCode web extension.
I started from the "lsp-web-extension-sample".
Within the server directory, I created a simple rust lib with wasm-bindgen
, it successfully compiles with wasm-pack
. When I call the init
function from the rust pkg output, it basically does this:
input = new URL("my-ext.wasm", import.meta.url)
fetch(input)
I get the following error: "TypeError: failed to fetch"
, without more explanations.
This error happens when testing with @vscode/test-web
as well as when testing with the vsce package
version.
Any idea what to do? Is there any example out there of a wasm web extension for vscode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我能够通过加载WASM内联完成工作。
webpack.config.js
I was able to get the work done by loading wasm inline.
webpack.config.js
接受的解决方案对我不起作用(WASM由
WASM-PACK
),但这确实:https://github.com/sonoflilit/vscode-web-wasm-rust
它涉及编写
webpack
webpack wasm loader plugin(和修补webpack
要使之成为可能,提交)使用此加载程序:以及
webpack_public_path __
inactivate> activate
之前,请先尝试导入wasm:Accepted solution didn't work for me (WASM generated by
wasm-pack
), but this did:https://github.com/SonOfLilit/vscode-web-wasm-rust
It involved writing a
webpack
WASM Loader plugin (and patchingwebpack
to make that possible, PR submitted) to use this loader:as well as setting
__webpack_public_path__
inactivate
before trying to import the WASM:我也花了很长时间才弄清楚这一点(正如您在下面的评论中看到的)。这是我在
激活
方法中最终提出的代码。It took me quite a while to figure this out too (as you can see in my comments below). This is the code I ended up with in my
activate
method.