Next.js Discord

Discord Forum

Wasm loading path mismatch on server

Unanswered
Schneider’s Smooth-fronted Caima… posted this in #help-forum
Open in Discord
Avatar
Schneider’s Smooth-fronted CaimanOP
I'm trying to call a wasm function in a GET handler in a route.ts file (app router, next 15.0.1). See how the code is structured below.

The challenge is that during rendering next tries to load .next/server/static/wasm/035b69681caed5d9.wasm But that file doesn't exist - the file that does exist is .next/server/chunks/static/wasm/035b69681caed5d9.wasm
For some reason the chunks thingie has been added by next. I've tried to update the wasm paths in webpack but that didn't fix it.

Any idea how to fix or a pointer to a similar example that does work would be appreciated.

[...}

export async function GET() {
    //@ts-ignore
    return import('path/to/mywasm.wasm').then(async (wasm) => {
        const instance = await WebAssembly.instantiate(wasm.default, importObject);
        [...]

0 Replies