I try to use pdfjs in a small typescript app with parceljs as bundler, but when I load the worker with:
pdfjsLib.GlobalWorkerOptions.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.min.js';
I get this error in the Firefox console:
pdf.worker.min.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type
and the worker is not loaded.
If I load the worker like this:
pdfjsLib.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${(pdfjsLib as any).version}/pdf.worker.min.js`;
everything works fine.
I have looked at the MDN description of the error and I sounds like some server side thing, so is it a limitation of the parcel server and is there a workaround?