-
-
Notifications
You must be signed in to change notification settings - Fork 908
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
"regeneratorRuntime is not defined" for pdf.worker.js #711
Comments
Is there any chance you could share your repo with me, preferably stripped down to just the config and your React-PDF usage? I'll try and look for the differences that could have lead to this error. |
Unfortunately I'm unable to share the repo. I'm not even sure where to start attacking this. I feel like this is a config problem on my end, but I have no idea whatsoever what it could be at this point. I've tried all solutions that I've been able to search up (typically these all revolve around |
Then would it be possible to share your Babel and Webpack config? |
Sure, I've put both files in gists here In other news, I was able to get the pdf to load with the following (based on this comment), but it doesn't work when importing from the entry directly: import React, { useEffect } from 'react';
// Note that this method does *not* work when importing from react-pdf/dist/esm/entry.webpack
import { Document, Page, pdfjs } from 'react-pdf';
// Importing directly from pdfjs-dist instead of through file-loader does *not* work.
import PDFJSWorker from '!!file-loader!pdfjs-dist/build/pdf.worker.min.js';
const PDFPage = () => {
useEffect(() => {
pdfjs.GlobalWorkerOptions.workerSrc = PDFJSWorker;
});
return (
<Document file="https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf">
<Page pageNumber={1} />
</Document>
);
};
export default PDFPage; I kind of wonder if this is another special case like CRA. |
I think I can close this. I'm pretty sure this is just a weird special case. I was able to get rid of the inline loader via some webpacker config, left here for anyone that shows up here in the future: environment.loaders.append('pdfjs-worker', {
test: /pdf\.worker(\.min)?\.js$/,
loader: 'file-loader'
}); |
Before you start - checklist
Description
When I try to load a page that renders a PDF, I see this error in my console, and the PDF does not render.
Steps to reproduce
Steps to reproduce the behavior:
Even this most basic of examples causes the issue.
Expected behavior
The document renders on the page.
Additional information
I originally had this error from react-pdf itself, which was resolved by explicitly importing
core-js/stable
andregenerator-runtime/runtime
in the app root file. Now it's coming from the worker, but I don't see how to resolve it.I've already gone down the large babel / plugin-transform-runtime / polyfill / etc. rabbit hole with no luck.
Environment
The text was updated successfully, but these errors were encountered: