Importing dependencies into an app created with create-react-app that use require.ensure as a fallback option causes the following warning in the console;
./node_modules/pdfjs-dist/build/pdf.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
This seems to be because the webpack settings in create-react-app do not allow dependencies to use require.ensure, but it seems that some libraries need to include this as a conditional fallback.
One possible solution might be to remove { parser: { requireEnsure: false } } from the webpack configuration. I don't see much context or discussion about why that rule is important other than that it's not a standard language feature.
I can see the argument from both sides, both why create-react-app would want to warn about this, and why another package might want to include it as a fallback. I don't know the correct solution, but this causes noisy warnings in the console when starting an app that make it more difficult to focus on actionable warnings.
Maybe the correct solution is to allow the suppression of unwanted warnings in create-react-app, but that seems to be a settled issue.
I'm open to any other workarounds or solutions.
Importing dependencies into an app created with
create-react-appthat userequire.ensureas a fallback option causes the following warning in the console;This seems to be because the webpack settings in
create-react-appdo not allow dependencies to userequire.ensure, but it seems that some libraries need to include this as a conditional fallback.One possible solution might be to remove
{ parser: { requireEnsure: false } }from the webpack configuration. I don't see much context or discussion about why that rule is important other than that it's not a standard language feature.I can see the argument from both sides, both why
create-react-appwould want to warn about this, and why another package might want to include it as a fallback. I don't know the correct solution, but this causes noisy warnings in the console when starting an app that make it more difficult to focus on actionable warnings.Maybe the correct solution is to allow the suppression of unwanted warnings in
create-react-app, but that seems to be a settled issue.I'm open to any other workarounds or solutions.