diff --git a/.eslintrc b/.eslintrc
index 73ba6c034d3f01..79d4136e2c6816 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,6 +1,6 @@
{
"parserOptions": {
- "ecmaVersion": 8,
+ "ecmaVersion": 2020,
"sourceType": "module",
},
@@ -17,13 +17,12 @@
"env": {
"browser": true,
- "es6": true,
+ "es2020": true,
"worker": true,
"amd": true,
},
"globals": {
- "globalThis": false,
"PDFJSDev": false,
"exports": false,
"SystemJS": false,
diff --git a/external/builder/preprocessor2.js b/external/builder/preprocessor2.js
index 9be29c8b3b8e0c..425559c486ef58 100644
--- a/external/builder/preprocessor2.js
+++ b/external/builder/preprocessor2.js
@@ -322,7 +322,7 @@ function preprocessPDFJSCode(ctx, code) {
},
};
var parseOptions = {
- ecmaVersion: 8,
+ ecmaVersion: 2020,
locations: true,
sourceFile: ctx.sourceFile,
sourceType: "module",
diff --git a/package-lock.json b/package-lock.json
index c176b941cc2e0c..fe2adc7d84387f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3726,6 +3726,12 @@
}
}
},
+ "es-module-shims": {
+ "version": "0.4.6",
+ "resolved": "https://registry.npmjs.org/es-module-shims/-/es-module-shims-0.4.6.tgz",
+ "integrity": "sha512-EzVhnLyA/zvmGrAy2RU8m9xpxX7u2yb2by1GZH80SHF6lakG21YAm3Vo56KsLIXaIjT9QabqjYpQU1S5FkM8+Q==",
+ "dev": true
+ },
"es-to-primitive": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
diff --git a/package.json b/package.json
index addb412367f2cc..38feb30f6e9f2d 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
"eslint-plugin-no-unsanitized": "^3.1.1",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-unicorn": "^20.0.0",
+ "es-module-shims": "^0.4.6",
"fancy-log": "^1.3.3",
"globals": "^11.12.0",
"gulp": "^4.0.2",
diff --git a/src/core/.eslintrc b/src/core/.eslintrc
new file mode 100644
index 00000000000000..c1831d3880daf2
--- /dev/null
+++ b/src/core/.eslintrc
@@ -0,0 +1,13 @@
+{
+ "parserOptions": {
+ "ecmaVersion": 2017,
+ },
+
+ "extends": [
+ "../../.eslintrc"
+ ],
+
+ "env": {
+ "es2017": true,
+ },
+}
diff --git a/src/display/api.js b/src/display/api.js
index d3d6b0b894136d..5170c5209d50b6 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -1650,7 +1650,9 @@ const PDFWorker = (function PDFWorkerClosure() {
}
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
if (typeof SystemJS !== "object") {
- throw new Error("SystemJS must be used to load fake worker.");
+ // Manually load SystemJS, since it's only necessary for fake workers.
+ await loadScript("../node_modules/systemjs/dist/system.js");
+ await loadScript("../systemjs.config.js");
}
const worker = await SystemJS.import("pdfjs/core/worker.js");
return worker.WorkerMessageHandler;
diff --git a/src/pdf.js b/src/pdf.js
index 82834dc1d71c03..0f6a65c23290a5 100644
--- a/src/pdf.js
+++ b/src/pdf.js
@@ -77,8 +77,8 @@ const pdfjsDisplayAPICompatibility = require("./display/api_compatibility.js");
>>>>>>> Re-factor `setPDFNetworkStreamFactory`, in src/display/api.js, to also accept an asynchronous function
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
const streamsPromise = Promise.all([
- SystemJS.import("pdfjs/display/network.js"),
- SystemJS.import("pdfjs/display/fetch_stream.js"),
+ import("pdfjs/display/network.js"),
+ import("pdfjs/display/fetch_stream.js"),
]);
<<<<<<< HEAD
setPDFNetworkStreamFactory(params => {
diff --git a/web/app.js b/web/app.js
index 354121b72db0c8..f4956dd65b6fa2 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1833,7 +1833,9 @@ async function loadFakeWorker() {
}
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
if (typeof SystemJS !== "object") {
- throw new Error("SystemJS must be used to load fake worker.");
+ // Manually load SystemJS, since it's only necessary for fake workers.
+ await loadScript("../node_modules/systemjs/dist/system.js");
+ await loadScript("../systemjs.config.js");
}
window.pdfjsWorker = await SystemJS.import("pdfjs/core/worker.js");
return undefined;
diff --git a/web/viewer.html b/web/viewer.html
index 1f50702de1435a..75beacd30b87dc 100644
--- a/web/viewer.html
+++ b/web/viewer.html
@@ -45,8 +45,18 @@
-
-
+
+
+
+
@@ -54,7 +64,7 @@
-
+
diff --git a/web/viewer.js b/web/viewer.js
index a59f08ec76f27f..f51cdd44e1d7dc 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -189,11 +189,11 @@ function webViewerLoad() {
const config = getViewerConfiguration();
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
Promise.all([
- SystemJS.import("pdfjs-web/app.js"),
- SystemJS.import("pdfjs-web/app_options.js"),
- SystemJS.import("pdfjs-web/genericcom.js"),
- SystemJS.import("pdfjs-web/pdf_print_service.js"),
- ]).then(function ([app, appOptions, ...otherModules]) {
+ import("pdfjs-web/app.js"),
+ import("pdfjs-web/app_options.js"),
+ import("pdfjs-web/genericcom.js"),
+ import("pdfjs-web/pdf_print_service.js"),
+ ]).then(function ([app, appOptions, genericCom, pdfPrintService]) {
window.PDFViewerApplication = app.PDFViewerApplication;
window.PDFViewerApplicationOptions = appOptions.AppOptions;
app.PDFViewerApplication.run(config);