[api-minor] Use new Worker() syntax in webpack entrypoint
This requires Webpack 5 and will break for anyone using Webpack 4. worker-loader no longer needs to be installed.
This commit is contained in:
parent
493bb65005
commit
1c2d200918
@ -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
|
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
|
importing `pdfjs-dist/webpack` which is the zero-configuration method for
|
||||||
Webpack users. You will need to install
|
Webpack users. Installing `worker-loader` is no longer necessary.
|
||||||
[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).
|
|
||||||
|
|
||||||
import * as pdfjsLib from 'pdfjs-dist/webpack';
|
import * as pdfjsLib from 'pdfjs-dist/webpack';
|
||||||
|
|
||||||
|
5
external/dist/webpack.js
vendored
5
external/dist/webpack.js
vendored
@ -16,10 +16,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const pdfjs = require("./build/pdf.js");
|
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) {
|
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;
|
module.exports = pdfjs;
|
||||||
|
@ -2171,14 +2171,6 @@ function packageJson() {
|
|||||||
dommatrix: "^1.0.3",
|
dommatrix: "^1.0.3",
|
||||||
"web-streams-polyfill": "^3.2.1",
|
"web-streams-polyfill": "^3.2.1",
|
||||||
},
|
},
|
||||||
peerDependencies: {
|
|
||||||
"worker-loader": "^3.0.8", // Used in `external/dist/webpack.js`.
|
|
||||||
},
|
|
||||||
peerDependenciesMeta: {
|
|
||||||
"worker-loader": {
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
browser: {
|
browser: {
|
||||||
canvas: false,
|
canvas: false,
|
||||||
fs: false,
|
fs: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user