DanielArnould / react-pdf-highlighter-extended

📄 Set of modern React components for PDF highlighting
https://danielarnould.github.io/react-pdf-highlighter-extended/example-app/
MIT License
31 stars 10 forks source link

Next.js support (use CSS modules) #6

Open fhs opened 4 months ago

fhs commented 4 months ago

This is an issue from the original library: https://github.com/agentcooper/react-pdf-highlighter/issues/156

I was hoping this forks fixes the issue, but apparently not. The workaround I'm using is to compile a non-nextjs app (like the example app in this repo) using npm run build and copy the compiled pdf-highlighter app into the public directory of my app and embed the pdf-highlighter app in an iframe. This is not ideal and I want to be able to use the pdf-highlighter component directly in my app.

fhs commented 4 months ago

This is the error I get when trying to include the component directly:

Failed to compile
./node_modules/.pnpm/pdfjs-dist@2.16.105/node_modules/pdfjs-dist/web/pdf_viewer.css
Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules/.pnpm/react-pdf-highlighter-extended@8.0.0_react-dom@18.2.0_react@18.2.0/node_modules/react-pdf-highlighter-extended/dist/esm/components/PdfHighlighter.js
This error occurred during the build process and can only be dismissed by fixing the error.