Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load wasm in VSCode Web Extension

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?

like image 911
Cohars Avatar asked Oct 14 '25 20:10

Cohars


1 Answers

I was able to get the work done by loading wasm inline.

webpack.config.js

  module: {
    rules: [
      // ...,
      {
        test: /\.wasm$/,
        type: "asset/inline",
      },
    ],
  },
like image 74
Cohars Avatar answered Oct 17 '25 22:10

Cohars