Description
The @kreuzberg/wasm package can't be used in a Next.js app (v16, Turbopack or webpack) because the main entry point (dist/index.js) statically imports Node.js-only modules that don't exist in browser environments.
Errors
With Turbopack (Next.js 16 default):
NftJsonAsset: cannot handle filepath worker_threads
With webpack (next build --webpack):
Module not found: Can't resolve 'fs/promises'
Module not found: Can't resolve 'worker_threads'
Module not found: Can't resolve 'node:module'
Import trace:
node:module
→ @kreuzberg/wasm/dist/pdfium.js
→ @kreuzberg/wasm/dist/index.js
Steps to reproduce
npx create-next-app@latest test-app
cd test-app
npm install @kreuzberg/wasm
Add to any client component:
const { initWasm, extractBytes } = await import("@kreuzberg/wasm");
Run npm run build → build fails.
Relevant files and configuration
- `@kreuzberg/wasm` version: latest
- Next.js 16.1.6
- Node.js 22
- macOS
Description
The
@kreuzberg/wasmpackage can't be used in a Next.js app (v16, Turbopack or webpack) because the main entry point (dist/index.js) statically imports Node.js-only modules that don't exist in browser environments.Errors
With Turbopack (Next.js 16 default):
With webpack (
next build --webpack):Import trace:
Steps to reproduce
npx create-next-app@latest test-app cd test-app npm install @kreuzberg/wasmAdd to any client component:
Run
npm run build→ build fails.Relevant files and configuration