Next.js Production Build Breaks wasm Package Path Resolution; Fix Requires Two Config Settings
A npm package that loads a wasm file fails at runtime in Next.js production builds, while working fine in development. The author's PDF generation service, which uses the subset-font package for HarfBuzz-based font subsetting, returned 502 errors in production due to a path type error. The cause is that Next.js bundling changes the module's physical location, which shifts the base for the package's relative wasm path resolution. The fix combines serverExternalPackages to skip bundling those packages with outputFileTracingIncludes to ensure the wasm and font files are included in the deployment, since neither setting works alone.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in