diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.65k stars 1.16k forks source link

Project not building after using PDFDownloadLink Component #2286

Closed dpena-nts closed 1 year ago

dpena-nts commented 1 year ago

Describe the bug It doesnt show any error, it just get stuck "Creating an optimized production build" and never finishes This happens when I'm using PDFDownloadLink

marfb commented 1 year ago

Having the same problem, even without PDFDownloadLink.

Next.js version: 12.3.1 React vesrion: 17.0.1 react-pdf/renderer: 3.1.9

Tried to prevent the page that uses the components from being taken into account during next.js compile time in two ways:

In either case, running yarn build in the terminal does not complete the process.

An important observation is that if I do not import the component that uses the library, the compilation does not take more than 30 seconds.

dpena-nts commented 1 year ago

I'm also using Next.js and React and as @marfb said it does happen even without using PDFDownloadLink, tried another approach without it and still happened

allanviictor commented 1 year ago

i have same problem !!

marfb commented 1 year ago

I've manage to find a "solution" or at least a possible workaround.

Like I said the project i'm working on is using next.js v 12.3.1. Apparently there is a bug in a dependency for that nexjs version.

The proper solution i think it would be to update your next.js version to the latest.

If that is not possible (like in my case) I found this issue response that gave me the idea and it worked.

In your next.config.js file, update the swcMinify to false

const nextConfig = {
  /* all your config */
  swcMinify: false,
}

@allanviictor @dpena-nts ☝️

allanviictor commented 1 year ago

i think that this solution is not recommended. change swc to false will cause problems of performance in build time

dpena-nts commented 1 year ago

@marfb the "swcMinify: false" worked, I'll see if its possible to update to the latest version of next or just go with the work around