trouble with WebAssembly from swc and vite

448 views Asked by At

My application tries to load swc with a dynamic import:

const swcWasmWeb = await import("@swc/wasm-web");

await swcWasmWeb.default();

this works fine, if the WASM-file is copied manually to

..\node_modules\.vite\deps

How can i configure vite to copy the file automatically and treat it as a dependency?

I have tried to add an import like that (see https://vitejs.dev/guide/assets.html):

import _ from "@swc/wasm-web/wasm-web_bg.wasm?url";

also tried to add it to the vite.config.ts like:

assetsInclude: ["@swc/wasm-web/wasm-web_bg.wasm"],

So what is the right notation?

I'm using Vite 4.0.3 with React 18.2 and Typescript.

0

There are 0 answers