Skip to content

Fails to load WASM file in Next.js app router #1

Open
@cbratschi

Description

@cbratschi

I am getting the following error while using blurhash-to-css in the Next.js app router:

- error Error: ENOENT: no such file or directory, open '/.../.next/server/app/[lang]/[[...slug]]/blurhash_to_css_bg.wasm'
    at Object.openSync (node:fs:592:3)
    at Object.readFileSync (node:fs:460:35)
    at eval (webpack-internal:///(rsc)/../../node_modules/blurhash-to-css/pkg/blurhash_to_css.js:181:65)
    at (rsc)/../../node_modules/blurhash-to-css/pkg/blurhash_to_css.js (/.../.next/server/app/[lang]/[[...slug]]/page.js:1808:1)
    at __webpack_require__ (/....next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/../../node_modules/blurhash-to-css/index.js:6:27)

Next.js tried to load blurhash_to_css_bg.wasm from the .next/server folder instead of the pkg folder of the module.

The blurhash-to-css code looks correct:

const path = require('path').join(__dirname, 'blurhash_to_css_bg.wasm');
const bytes = require('fs').readFileSync(path);

Therefore this looks like a Next.js Webpack bundling issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions