Closed w-aurelien closed 1 year ago
What was the last version that worked for you?
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 https://github.com/vercel/next.js/pull/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:
patterns: [
{ from: cMapsDir, to: 'static/chunks/pdfjs/cmaps/' },
{
from: standardFontsDir,
to: 'static/chunks/pdfjs/standard_fonts/',
},
{
from: pdfWorkerPath,
to: 'static/chunks/pdfjs/build/pdf.worker.min.js',
},
],
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:
patterns: [ { from: cMapsDir, to: 'static/chunks/pdfjs/cmaps/' }, { from: standardFontsDir, to: 'static/chunks/pdfjs/standard_fonts/', }, { from: pdfWorkerPath, to: 'static/chunks/pdfjs/build/pdf.worker.min.js', }, ],
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 https://github.com/vercel/next.js/issues/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