The Problem
I am using SvelteKit and importing a WebAssembly module on the server side inside a +page.server.ts
file like this:
const WasmPromise = import('src/viz/wasmComp/geoscript_repl').then(
async (engine) => {
await engine.default(fetch('/geoscript_repl_bg.wasm'));
return engine;
}
);
It works when I run for local development, but it fails when running on my VPS in production. Some notes about my deployment environment:
- I’m Sveltekit’s
adapter-node
- I’m deploying the Sveltekit app inside Docker behind an NGINX reverse proxy
This Wasm module as built using wasm-bindgen
for Rust, and it needs the path to the Wasm to be explicitly provided since it’s running on the server side rather than the client.