1. Add filename option in worker-loader package require. Without this option, since version 3.0.0, it tell webpack to generate a worker file named pdf.worker.worker.js instead of the expected pdf.worker.js.

2. Update README of webpack example to mention that a version 3.0.0 or higher of the `worker-loader` package is now required.
This commit is contained in:
fabien 2021-01-07 14:15:47 +01:00
parent ed3758f84d
commit 35b15cc0b5
2 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ the worker code, and the `workerSrc` path shall be set to the latter file.
If you are getting the `Setting up fake worker` warning, make sure you are
importing `pdfjs-dist/webpack` which is the zero-configuration method for
Webpack users. You will need to install
[worker-loader](https://github.com/webpack-contrib/worker-loader) as a
[worker-loader](https://github.com/webpack-contrib/worker-loader) (version 3.0.0 or higher is required), as a
dependency in your project in order to use `pdfjs-dist/webpack` (configuring
`worker-loader` is not necessary; just installing it is sufficient).

View File

@ -16,7 +16,7 @@
"use strict";
var pdfjs = require("./build/pdf.js");
var PdfjsWorker = require("worker-loader?esModule=false!./build/pdf.worker.js");
var PdfjsWorker = require("worker-loader?esModule=false&filename=[name].js!./build/pdf.worker.js");
if (typeof window !== "undefined" && "Worker" in window) {
pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker();