"regeneratorRuntime is not defined" for pdf.worker.js
See original GitHub issueBefore you start - checklist
- I followed instructions in documentation written for my React-PDF version
- I have checked if this bug is not already reported
- I have checked if an issue is not listed in Known issues
- If I have a problem with PDF rendering, I checked if my PDF renders properly in Mozilla Firefox
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.
import React from 'react';
import { Document, Page } from 'react-pdf/dist/esm/entry.webpack';
const PDFPage = () => {
return (
<Document file="https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf">
<Page pageNumber={1} />
</Document>
);
};
export default PDFPage;
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
and regenerator-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
- Browser (if applicable) [e.g. Chrome 57, Firefox 59]: both Firefox 84.0.2 and Chrome 87.0.4280.88 have this issue.
- React-PDF version [e.g. 3.0.4]: 5.1.0
- React version [e.g. 16.3.0]: 17.0.1
- Webpack version (if applicable) [e.g. 4.16.2]: 4.44.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Uncaught ReferenceError: regeneratorRuntime is not defined
I had this issue as well when I updated a class's method to include async/await in my React app. The solution I found...
Read more >How to fix regeneratorRuntime is not defined?
I have ran into a problem, the error is regeneratorRuntime is not defined while working with React and Parcel bundler.
Read more >I can't load PDF.js lib in Lightning Web Component
Try uploading just the pdf js file in a separate static resource and pdf worker js in a separate static resource and load...
Read more >Migrate a non-CRA React project to Next.js - Estee's Tech Blog
In this tutorial, I will be demonstrating step by step how I migrated a React(JS) Single Page Application (SPA) project to Next.js. No...
Read more >regeneratorRuntime is not defined - WordPress.org
problem is with wp rocket Delay JavaScript execution, i add p-660ec1bb.js to exclud but not work i add /wp-content/plugins/presto-player/dist/components/web- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
Sure, I’ve put both files in gists here Note that this is a Rails app, so webpacker is sitting in front of webpack itself, and is configured via the yml file in the fist.
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:
I kind of wonder if this is another special case like CRA.