Warning: Setting up fake worker.
As already mentioned before pdfjs outputs the warning Warning: Setting up fake worker.
both in development and in production builds when the first exam is opened.
This issue is related to the fact that pdfjs
consists of two separate parts: The renderer and the parser.
- The renderer always has to run on the main "thread".
- The parser is a separate js file that can be executed in a worker to increase performance. As of now a build artifact called
pdfjsWorker
exists which is used bypdfjs
as a fallback if noGlobalWorkerOptions.workerSrc
is specified.pdfjs-dist
contains a filewebpack.js
which usesworker-loader
to setup a worker the worker correctly. A quick 'n dirty solution would be to replace the import insplit-render.ts
withimport * as pdfjs from "pdfjs-dist/webpack";
which however doesn't work as @types/pdfjs-dist doesn't specify types for the webpack module (a simple fix was to change the entry point of pdfjs-dist). Updating that module requires a new typescript version (3.0.0) as these newpdfjs-dist
types useunknown
which is a rather new typescript feature. When typescript is updated the types are incompatible with react-dom types which transitively depend on@types/node
which in turn results in a naming conflict with that typescript version which would require us to update react-dom as well.