From d0d70c3434a7c59769a57915464bbb4d20c60ea7 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Mon, 27 Mar 2023 11:40:58 +0200 Subject: [PATCH] ESMify some modules for m-c (bug 1824610) --- ...ltPreferences.jsm => PdfJsDefaultPreferences.sys.mjs} | 4 +--- gulpfile.js | 4 ++-- src/pdf.sandbox.external.js | 9 +-------- 3 files changed, 4 insertions(+), 13 deletions(-) rename extensions/firefox/content/{PdfJsDefaultPreferences.jsm => PdfJsDefaultPreferences.sys.mjs} (87%) diff --git a/extensions/firefox/content/PdfJsDefaultPreferences.jsm b/extensions/firefox/content/PdfJsDefaultPreferences.sys.mjs similarity index 87% rename from extensions/firefox/content/PdfJsDefaultPreferences.jsm rename to extensions/firefox/content/PdfJsDefaultPreferences.sys.mjs index cc4b7b043d9ff6..50e8e4ef608af1 100644 --- a/extensions/firefox/content/PdfJsDefaultPreferences.jsm +++ b/extensions/firefox/content/PdfJsDefaultPreferences.sys.mjs @@ -15,8 +15,6 @@ "use strict"; -var EXPORTED_SYMBOLS = ["PdfJsDefaultPreferences"]; - -var PdfJsDefaultPreferences = Object.freeze( +export const PdfJsDefaultPreferences = Object.freeze( PDFJSDev.eval("DEFAULT_PREFERENCES") ); diff --git a/gulpfile.js b/gulpfile.js index 11894222fdbd4f..c127444b248517 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -438,7 +438,7 @@ function createSandboxExternal(defines) { transform("utf8", content => { content = preprocessor2.preprocessPDFJSCode(ctx, content); return `${licenseHeader}\n${content}`; - }) + }).pipe(rename("pdf.sandbox.external.sys.mjs")) ); } @@ -1381,7 +1381,7 @@ gulp.task( .pipe(gulp.dest(MOZCENTRAL_L10N_DIR)), gulp.src("LICENSE").pipe(gulp.dest(MOZCENTRAL_EXTENSION_DIR)), gulp - .src(FIREFOX_CONTENT_DIR + "PdfJsDefaultPreferences.jsm") + .src(FIREFOX_CONTENT_DIR + "PdfJsDefaultPreferences.sys.mjs") .pipe(transform("utf8", preprocessDefaultPreferences)) .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR)), ]); diff --git a/src/pdf.sandbox.external.js b/src/pdf.sandbox.external.js index 68bb48a2d56145..ce77db1c61b393 100644 --- a/src/pdf.sandbox.external.js +++ b/src/pdf.sandbox.external.js @@ -16,7 +16,7 @@ // In mozilla-central, this file is loaded as non-module script, // so it mustn't have any dependencies. -class SandboxSupportBase { +export class SandboxSupportBase { /** * @param {DOMWindow} - win */ @@ -181,10 +181,3 @@ class SandboxSupportBase { }; } } - -if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { - exports.SandboxSupportBase = SandboxSupportBase; -} else { - /* eslint-disable-next-line no-unused-vars, no-var */ - var EXPORTED_SYMBOLS = ["SandboxSupportBase"]; -}