react-pdf-highlighter icon indicating copy to clipboard operation
react-pdf-highlighter copied to clipboard

pdf.js dependencies cannot be statically extracted

Open cdpwest opened this issue 4 years ago • 7 comments

When running the example I run into the following warning:

./node_modules/pdfjs-dist/build/pdf.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

cdpwest avatar Jun 23 '20 22:06 cdpwest

+1 I have the same issue.

mohammedri avatar Jun 26 '20 18:06 mohammedri

Which build tool are you using?

agentcooper avatar Jun 26 '20 18:06 agentcooper

@agentcooper I am using creat-react-app which uses webpack and babel

mohammedri avatar Jun 26 '20 19:06 mohammedri

Having the same issue on a project I'm working on, anyone got a fix for this yet?

vhbert avatar Jul 03 '20 14:07 vhbert

Hi I am using webpack and yarn to build.

cdpwest avatar Jul 07 '20 03:07 cdpwest

@mohammedri any overrides or customizations?

The example project works fine for me which uses create react app. It also works for me in the project I added this to. So I'm guessing this is either a version conflict or a configuration conflict.

If you are getting this error it would be super helpful if you paste your webpack config and output of npm ls in a pastebin or gist and link it here.

jsg2021 avatar Jul 26 '20 18:07 jsg2021

I found it. It comes from newer versions of react-scripts and using the default main export from pdfjs-dist. As in, doing this:

import {...} from 'pdfjs-dist';

its fixed by

import {...} from 'pdfjs-dist/lib/pdf.js';

jsg2021 avatar Jul 30 '20 04:07 jsg2021