-
-
Notifications
You must be signed in to change notification settings - Fork 906
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
Vite entry error #1232
Comments
Related: #1148. Looks like it may be related to #1148 (comment)? |
@wojtekmaj for now, solved this issue by importing pdfjs from this library and using the workerSrc Thanks |
it works with vite3 + ts 4.6 + react 18.2 + react-pdf 6.2.2 |
Just a small note: if you're manually providing workerSrc, there's no point to keep using Vite-specific entry point which sole purpose is to provide workerSrc. :) |
Do you have a new solution for this, @flymyd? |
What versions of Vite and react-pdf are used in your project? |
This is a sample with [email protected] and [email protected] import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import 'react-pdf/dist/esm/Page/TextLayer.css';
import {FC, useState} from "react";
import {pdfjs, Document, Page} from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.js',
import.meta.url,
).toString();
const App: FC = () => {
const [numPages, setNumPages] = useState(null);
return (
<Document file="https://test.com/sample.pdf" onLoadSuccess={(e: any) => setNumPages(e.numPages)}>
{Array.from(new Array(numPages), (_el, index) => <Page key={`page_${index + 1}`} pageNumber={index + 1} width={980}/>)}
</Document>
)
}
export default App; |
Should be |
using pdfjs.GlobalWorkerOptions.workerSrc = new URL( locally works but on the production getting an error any solution to tackle this? here is my vite.comfig.ts |
Facing the same issue. |
For my solution, see #1377 (comment) |
I meet the same question, have you resolved it ? |
Before you start - checklist
Description
I am getting this error when using vite entry
Steps to reproduce
Code:
Expected behavior
Should render the pdf
Actual behavior
Webpage crashing
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: