[Bug]: When using vite the pdfjs worker no longer correctly imports #19909
Unanswered
JoelBrenstrum
asked this question in
Q&A
Replies: 1 comment
-
The issue seems to be how you're specifying the pdfjsLib.GlobalWorkerOptions.workerSrc = await getLocalScriptSrc(workerSrc.href) into the following seems to make things work: pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc.href; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Attach (recommended) or Link to PDF file
pub1581_2310_lighting_products_brochure_web.pdf
Web browser and its version
Chrome 136
Operating system and its version
MacOS 15.3.1
PDF.js version
5.2.x
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
Repro here
https://stackblitz.com/edit/sb1-biwwjbyg
using pdfjs 5.2 will get an error when uploading a pdf
4.10 will work as expeted
What is the expected behavior?
The worker should load without the additional import
What went wrong?
In version 5+ the worker file can no longer be correctly bundled with vite.
import { injectQuery as __vite__injectQuery } from "/@vite/client" worker
is added to the worker code.
in version 4.10 no additional code is added to the worker
Link to a viewer
No response
Additional context
Similar issue described here
vitejs/vite#15650
Beta Was this translation helpful? Give feedback.
All reactions