From 4b1afcd3634f49a1f2100ac803ee3124797ff47c Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 15 Nov 2023 14:08:40 +0200 Subject: [PATCH] Polyfill is still needed in chrome WE2-789 Signed-off-by: Raul Metsma --- package-lock.json | 15 ++++++++++++++- package.json | 1 + rollup.config.js | 19 ++++++++++--------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index f2e7590..f2f23d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,8 @@ "rollup-plugin-license": "^2.6.0", "rollup-plugin-polyfill": "^3.0.0", "ts-jest": "^27.1.1", - "typescript": "^4.5.2" + "typescript": "^4.5.2", + "webextension-polyfill": "^0.10.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -5773,6 +5774,12 @@ "makeerror": "1.0.12" } }, + "node_modules/webextension-polyfill": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz", + "integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g==", + "dev": true + }, "node_modules/webidl-conversions": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", @@ -10340,6 +10347,12 @@ "makeerror": "1.0.12" } }, + "webextension-polyfill": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz", + "integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g==", + "dev": true + }, "webidl-conversions": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", diff --git a/package.json b/package.json index c05c569..28b7536 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "rollup-plugin-license": "^2.6.0", "rollup-plugin-polyfill": "^3.0.0", "ts-jest": "^27.1.1", + "webextension-polyfill": "^0.10.0", "typescript": "^4.5.2" }, "dependencies": {} diff --git a/rollup.config.js b/rollup.config.js index 6645ccb..7fa5719 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,6 +4,7 @@ import alias from "@rollup/plugin-alias"; import cleanup from "rollup-plugin-cleanup"; import injectProcessEnv from "rollup-plugin-inject-process-env"; import license from "rollup-plugin-license"; +import polyfill from "rollup-plugin-polyfill"; import resolve from "@rollup/plugin-node-resolve"; const projectRootDir = path.resolve(__dirname); @@ -11,8 +12,8 @@ const projectRootDir = path.resolve(__dirname); const pluginsConf = [ alias({ entries: [{ - find: "@web-eid.js", - replacement: path.resolve(projectRootDir, "dist/lib/web-eid.js/src") + find: "@web-eid.js", + replacement: path.resolve(projectRootDir, "dist/lib/web-eid.js/src"), }], }), resolve({ rootDir: "./dist" }), @@ -24,7 +25,7 @@ const pluginsConf = [ license({ banner: { content: { - file: path.join(projectRootDir, "LICENSE"), + file: path.join(projectRootDir, "LICENSE"), encoding: "utf-8", }, }, @@ -37,24 +38,24 @@ const browsers = ["chrome", "firefox", "safari"]; // Use flatMap() to create a configuration for each browser and each of the "content" and "background" scripts. const browserConfigs = browsers.flatMap((browser) => ["content", "background"].map((name) => ({ - input: `./dist/${browser}/${name}/${name}.js`, + input: `./dist/${browser}/${name}/${name}.js`, output: [ { - file: `dist/${browser}/${name}.js`, - format: "iife", + file: `dist/${browser}/${name}.js`, + format: "iife", sourcemap: name === "background", }, ], - plugins: pluginsConf, + plugins: [...pluginsConf, polyfill(["webextension-polyfill"])], context: "window", })) ); // Define the configuration for the TokenSigning compatibility page script for Chrome and Firefox. const tokenSigningPageConfig = { - input: "./dist/firefox/resources/token-signing-page-script.js", + input: "./dist/firefox/resources/token-signing-page-script.js", output: ["chrome", "firefox"].map((browser) => ({ - file: `dist/${browser}/token-signing-page-script.js`, + file: `dist/${browser}/token-signing-page-script.js`, format: "iife", })), plugins: pluginsConf,