arkokoley/pdfvuer

Deprecated API usage: No "GlobalWorkerOptions.workerSrc" specified.

muhammedkoca003 opened this issue · 2 comments

Hello, since I upgraded to 1.7.3 I get an error:

404 file 588.worker.js is not found (file number changes from time to time).

I tried adding this:

module: {
        rules: [
          {
            test: /\.worker\.js$/,
            use: {
              loader: 'worker-loader',
              options: {
                filename: '[name].worker.js'   // I also tried 588, but it also did not work
              }
            }
          }
        ]
      }

to the webpack config and installed a worker-loader, but the error stays the same.

If we change pdfvuer.umd.js

if (Object({"NODE_ENV":"production","BASE_URL":"/"}).VUE_ENV !== 'server') {
  if (typeof window !== 'undefined' && 'Worker' in window) {
    // pdfjsLib.GlobalWorkerOptions.workerPort = new PdfjsWorker(); // commenting this out and
    pdfjsLib.GlobalWorkerOptions.workerSrc = '/pdf.worker.min.js'  // adding this
  }
}

and add pdf.worker.min.js manually to src, it gets loaded and everything works, so if you don't find a solution, maybe you can add the possibility to pass an url as prop into the component. Would not be a cool solution, but it helps people using this library

  /* eslint-disable */
  var pdfwoker = require('worker-loader!pdfjs-dist/build/pdf.worker')
  /* eslint-enable */

Add this as well. This should work then.