-
-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NextJS] React-pdf 7.5.0 - Vercel deployment no longer works #1630
Comments
What was the last version that worked for you? |
7.3.3 |
I just realized that I also upgraded the version of nextJS, so I have just conducted the following deployment tests:
|
Well, that sounds like a Next.js problem to me then! |
I think the two are related no? Maybe NextJs changed something that needs to be reflected in React-Pdf? Because if I remove react-pdf from my dependencies everything works correctly again. |
Clearly something used to work and stopped working. That's a bug/regression by my standards. I'll be happy to assist Vercel should they pick it up. |
Also getting the same error, it looks like the issue is on the latest version of Vercel NextJS: 13.5.4, as if I downgrade to NextJS: 13.5.3 I can deploy without any issues. |
I just ran into this as well verifying everything built locally. The only thing that I could find that was "worker" related in 13.5.4 was vercel/next.js#55257 but not sure if that would cause any issues. 🤷🏼♂️ |
I faced this issue, and found another closed issue with similar problem, one comment suggested using the worker from cdn url and it works. I will stick with it for now. |
I also got this problem before, i don't know if this is a good way or not, but the problem is solved. I am using next.js version 13.5.4 and react-pdf version 7.5.0 // next.config.js
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
const pdfjsDistDir = path.dirname(require.resolve("pdfjs-dist/package.json"));
const cMapsDir = path.join(pdfjsDistDir, "cmaps");
const standardFontsDir = path.join(pdfjsDistDir, "standard_fonts");
const pdfWorkerPath = path.join(pdfjsDistDir, "build", "pdf.worker.min.js");
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverActions: true,
},
webpack: (config) => {
config.resolve.alias.canvas = false;
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{ from: cMapsDir, to: "static/chunks/pdfjs/cmaps/" },
],
})
);
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: standardFontsDir,
to: "static/chunks/pdfjs/standard_fonts/",
},
],
})
);
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: pdfWorkerPath,
to: "static/chunks/pdfjs/build/pdf.worker.min.js",
},
],
})
);
return config;
},
};
module.exports = nextConfig; // in my pdf component
...
pdfjs.GlobalWorkerOptions.workerSrc =
"/_next/static/chunks/pdfjs/build/pdf.worker.min.js";
const documentOptions = {
cMapUrl: "/_next/static/chunks/pdfjs/cmaps/",
standardFontDataUrl: "/_next/static/chunks/pdfjs/standard_fonts/",
};
... |
Thanks @yadh75, I tried your solution and so far it works well. Btw what does the problem if we combine 3 pushes into one? I'm not really good at webpack:
|
there's no problem with that, in fact it's actually better that way |
Hey all, Vercel confirmed it's a bug on their side. I suggest following vercel/next.js#56676 for updates. There's nothing we can or should do on our side, so I'm closing this issue. |
Before you start - checklist
Description
I just upgraded the version of react-pdf to version 7.5.0 and since then my deployments on Vercel are no longer working.
Steps to reproduce
My next.config.com
My Component :
Expected behavior
Deployment completed :)
I want to reiterate that before upgrading the version, my deployments were working correctly.
Actual behavior
Vercel deployment error :
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: