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
pdfjsWorkerexists which is used bypdfjsas a fallback if noGlobalWorkerOptions.workerSrcis specified.pdfjs-distcontains a filewebpack.jswhich usesworker-loaderto setup a worker the worker correctly. A quick 'n dirty solution would be to replace the import insplit-render.tswithimport * 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-disttypes useunknownwhich is a rather new typescript feature. When typescript is updated the types are incompatible with react-dom types which transitively depend on@types/nodewhich in turn results in a naming conflict with that typescript version which would require us to update react-dom as well.