Merge pull request #12470 from Snuffleupagus/webpack-5

Upgrade `webpack` to version 5
This commit is contained in:
Tim van der Meij 2020-10-11 14:50:32 +02:00 committed by GitHub
commit 49791f55b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 923 additions and 291 deletions

View File

@ -217,18 +217,6 @@ function createWebpackConfig(defines, output) {
options: { options: {
presets: skipBabel ? undefined : ["@babel/preset-env"], presets: skipBabel ? undefined : ["@babel/preset-env"],
plugins: [ plugins: [
[
"@babel/plugin-proposal-nullish-coalescing-operator",
{
loose: true,
},
],
[
"@babel/plugin-proposal-optional-chaining",
{
loose: true,
},
],
"@babel/plugin-transform-modules-commonjs", "@babel/plugin-transform-modules-commonjs",
[ [
"@babel/plugin-transform-runtime", "@babel/plugin-transform-runtime",

1169
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,6 @@
"version": "2.0.0", "version": "2.0.0",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.11.6", "@babel/core": "^7.11.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
"@babel/plugin-transform-modules-commonjs": "^7.10.4", "@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.11.5", "@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5", "@babel/preset-env": "^7.11.5",
@ -58,7 +56,7 @@
"vinyl": "^2.2.1", "vinyl": "^2.2.1",
"vinyl-fs": "^3.0.3", "vinyl-fs": "^3.0.3",
"web-streams-polyfill": "^3.0.0", "web-streams-polyfill": "^3.0.0",
"webpack": "^4.44.2", "webpack": "^5.0.0",
"webpack-stream": "~6.1.0", "webpack-stream": "~6.1.0",
"wintersmith": "^2.5.0", "wintersmith": "^2.5.0",
"yargs": "^11.1.1" "yargs": "^11.1.1"

View File

@ -13,7 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
"use strict"; import { AppOptions } from "./app_options.js";
import { PDFViewerApplication } from "./app.js";
/* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */
const pdfjsVersion = const pdfjsVersion =
@ -22,6 +23,9 @@ const pdfjsVersion =
const pdfjsBuild = const pdfjsBuild =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0; typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
window.PDFViewerApplication = PDFViewerApplication;
window.PDFViewerApplicationOptions = AppOptions;
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
var defaultUrl; // eslint-disable-line no-var var defaultUrl; // eslint-disable-line no-var
@ -42,12 +46,6 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
})(); })();
} }
let pdfjsWebApp, pdfjsWebAppOptions;
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("PRODUCTION")) {
pdfjsWebApp = require("./app.js");
pdfjsWebAppOptions = require("./app_options.js");
}
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
require("./firefoxcom.js"); require("./firefoxcom.js");
require("./firefox_print_service.js"); require("./firefox_print_service.js");
@ -198,23 +196,16 @@ function webViewerLoad() {
const config = getViewerConfiguration(); const config = getViewerConfiguration();
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
Promise.all([ Promise.all([
import("pdfjs-web/app.js"),
import("pdfjs-web/app_options.js"),
import("pdfjs-web/genericcom.js"), import("pdfjs-web/genericcom.js"),
import("pdfjs-web/pdf_print_service.js"), import("pdfjs-web/pdf_print_service.js"),
]).then(function ([app, appOptions, genericCom, pdfPrintService]) { ]).then(function ([genericCom, pdfPrintService]) {
window.PDFViewerApplication = app.PDFViewerApplication; PDFViewerApplication.run(config);
window.PDFViewerApplicationOptions = appOptions.AppOptions;
app.PDFViewerApplication.run(config);
}); });
} else { } else {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
pdfjsWebAppOptions.AppOptions.set("defaultUrl", defaultUrl); AppOptions.set("defaultUrl", defaultUrl);
} }
window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
// Give custom implementations of the default viewer a simpler way to // Give custom implementations of the default viewer a simpler way to
// set various `AppOptions`, by dispatching an event once all viewer // set various `AppOptions`, by dispatching an event once all viewer
@ -236,7 +227,7 @@ function webViewerLoad() {
} }
} }
pdfjsWebApp.PDFViewerApplication.run(config); PDFViewerApplication.run(config);
} }
} }
@ -248,3 +239,5 @@ if (
} else { } else {
document.addEventListener("DOMContentLoaded", webViewerLoad, true); document.addEventListener("DOMContentLoaded", webViewerLoad, true);
} }
export { PDFViewerApplication, AppOptions as PDFViewerApplicationOptions };