You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next 14.2.12 with react-pdf and pdfjs-dist | Build fails with webpack error: TypeError: Promise.withResolvers is not a function | Passes Vercel build with swcMinify: false
#70239
Observe build error: "Build failed because of webpack errors" (log error code exceeds 4 MB, so I didn't include a screenshot here)
Current vs. Expected behavior
Context
I'm building a Next app leveraging react-pdf (9.1.1) and pdfjs-dist: (4.4.168) to load and display PDFs from a source URL (Azure Blob). The minimal reproduction provided is a single page with a component that loads in and renders a PDF.
Current Behavior
The page does not compile at all when the PDF.js worker is defined in the page (server) component. The page compiles and the PDF renders properly from the source URL when PDF.js worker is placed in client component, but logs the following webpack error:
When I run a local build with swcMinify disabled, I get the following error:
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Promise.withResolvers is not a function
When I run my main project with swcMinify disabled, my code passes local build and Vercel build validation.
When I run a local build with swcMinify truthy, I get a large webpack error (larger than 4 MB)
When I run my main project with swcMinify truthy, my code fails local and Vercel build validation:
Expected Behavior
The PDF renders and displays correctly in local development, so I would expect a successful build without a webpack error and without disabling swcMinify.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 16075
Available CPU cores: 8
Binaries:
Node: 20.17.0
npm: 10.8.3
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.2.12 // Latest available version is detected (14.2.12).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: N/A
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
SWC, Webpack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), Vercel (Deployed)
Additional context
I tried to run this minimal reproduction with canary but couldn't resolve dependencies for react-pdf 9.1.1. I also tried adding a polyfill for Promise.withResolvers but this did not work either.
My main project actually passes build validation when preview deployed to Vercel, but only when swcMinify is set to false in my next.config.mjs file. The build logs inform me that I will be unable to disable swcMinify in future versions of Next. I want to ensure my build won't break when updating Next. My main project faces the same webpack issue in local development, however.
I also noticed there was another issue submitted 2 years ago (#40803) concerning react-pdf/renderer failing to work with swcMinify set truthy. I figured I would provide the link for reference. Thank you!
The text was updated successfully, but these errors were encountered:
Link to the code that reproduces this issue
https://github.com/algoleaf/pdf-test
To Reproduce
Current vs. Expected behavior
Context
I'm building a Next app leveraging react-pdf (9.1.1) and pdfjs-dist: (4.4.168) to load and display PDFs from a source URL (Azure Blob). The minimal reproduction provided is a single page with a component that loads in and renders a PDF.
Per the react-pdf npm doc (https://www.npmjs.com/package/react-pdf?activeTab=readme), I've included the suggested webpack config addition to my next.config.mjs file.
Current Behavior
The page does not compile at all when the PDF.js worker is defined in the page (server) component. The page compiles and the PDF renders properly from the source URL when PDF.js worker is placed in client component, but logs the following webpack error:
When I run a local build with swcMinify disabled, I get the following error:
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Promise.withResolvers is not a function
When I run my main project with swcMinify disabled, my code passes local build and Vercel build validation.
When I run a local build with swcMinify truthy, I get a large webpack error (larger than 4 MB)
When I run my main project with swcMinify truthy, my code fails local and Vercel build validation:
Expected Behavior
The PDF renders and displays correctly in local development, so I would expect a successful build without a webpack error and without disabling swcMinify.
Provide environment information
Which area(s) are affected? (Select all that apply)
SWC, Webpack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), Vercel (Deployed)
Additional context
I tried to run this minimal reproduction with canary but couldn't resolve dependencies for react-pdf 9.1.1. I also tried adding a polyfill for Promise.withResolvers but this did not work either.
My main project actually passes build validation when preview deployed to Vercel, but only when swcMinify is set to false in my next.config.mjs file. The build logs inform me that I will be unable to disable swcMinify in future versions of Next. I want to ensure my build won't break when updating Next. My main project faces the same webpack issue in local development, however.
I also noticed there was another issue submitted 2 years ago (#40803) concerning react-pdf/renderer failing to work with swcMinify set truthy. I figured I would provide the link for reference. Thank you!
The text was updated successfully, but these errors were encountered: