Skip to content
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

Cannot set properties of undefined (setting 'workerSrc') #1579

Closed
3 of 4 tasks
stauersbol opened this issue Aug 1, 2023 · 4 comments
Closed
3 of 4 tasks

Cannot set properties of undefined (setting 'workerSrc') #1579

stauersbol opened this issue Aug 1, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@stauersbol
Copy link

stauersbol commented Aug 1, 2023

Before 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 PDF.js demo

Description

The bug I'm encountered now is one that appeared after the ESM module compat and the latest release.

- error Error [TypeError]: Cannot set properties of undefined (setting 'workerSrc')
    at file:///home/stauersbol/Projects/dws-drawing-viewer/node_modules/react-pdf/dist/esm/index.js:11:37
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  digest: undefined
}

Steps to reproduce

  1. Setup a basic Next project and implement the recommended way of setting up react-pdf (In this case I'm using the unpkg.com for this, but I have same issue using the new URL way)
  2. Run next dev
  3. See the error when you load the site in your console

Expected behavior

Site loads properly and the PDF loads in.

Actual behavior

Next shows the error page with the error message.

Additional information

image
This image should show the issue I'm facing.

image
Same error in Browser Console.

Extra info:
I'm using Next to run this. This is for a niche use case, due to the API.

How I setup workerSrc reference to the part where I mention unpkg:
pdfjs.GlobalWorkerOptions.workerSrc = //unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js``

Environment

  • Browser (if applicable): Opera
  • React-PDF version: 7.3.2
  • React version: 18.2.0
  • Webpack version (if applicable):
@stauersbol stauersbol added the bug Something isn't working label Aug 1, 2023
@wojtekmaj wojtekmaj self-assigned this Aug 1, 2023
@wojtekmaj
Copy link
Owner

I just love dual ESM/CJS packages 🫠

Try v7.3.3, works for me!

@stauersbol
Copy link
Author

I will give it a try tomorrow when I get it at work!
Thank you for fixing it so fast @wojtekmaj!

@stauersbol
Copy link
Author

Hey @wojtekmaj
It is working as expected now, thank you for the quick fix!

@wojtekmaj
Copy link
Owner

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants