Merge pull request #15430 from srmagura/webpack5

[api-minor] Use `new Worker()` syntax in webpack entrypoint
This commit is contained in:
Jonas Jenwald 2022-09-14 10:32:01 +02:00 committed by GitHub
commit c21d00ef44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 14 deletions

View File

@ -28,10 +28,7 @@ otherwise the build is not guaranteed to work correctly.
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) (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).
Webpack users. Installing `worker-loader` is no longer necessary.
import * as pdfjsLib from 'pdfjs-dist/webpack';

View File

@ -16,10 +16,11 @@
"use strict";
const pdfjs = require("./build/pdf.js");
const PdfjsWorker = require("worker-loader?esModule=false&filename=[name].[contenthash].js!./build/pdf.worker.js");
if (typeof window !== "undefined" && "Worker" in window) {
pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker();
pdfjs.GlobalWorkerOptions.workerPort = new Worker(
new URL("./build/pdf.worker.js", import.meta.url)
);
}
module.exports = pdfjs;

View File

@ -2171,14 +2171,6 @@ function packageJson() {
dommatrix: "^1.0.3",
"web-streams-polyfill": "^3.2.1",
},
peerDependencies: {
"worker-loader": "^3.0.8", // Used in `external/dist/webpack.js`.
},
peerDependenciesMeta: {
"worker-loader": {
optional: true,
},
},
browser: {
canvas: false,
fs: false,