Skip to content

Commit

Permalink
Polyfill is still needed in chrome
Browse files Browse the repository at this point in the history
WE2-789

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Nov 15, 2023
1 parent 577ee3b commit 6699b43
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"rollup-plugin-license": "^2.6.0",
"rollup-plugin-polyfill": "^3.0.0",
"ts-jest": "^27.1.1",
"webextension-polyfill": "^0.8.0",
"typescript": "^4.5.2"
},
"dependencies": {}
Expand Down
19 changes: 10 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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);

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" }),
Expand All @@ -24,7 +25,7 @@ const pluginsConf = [
license({
banner: {
content: {
file: path.join(projectRootDir, "LICENSE"),
file: path.join(projectRootDir, "LICENSE"),
encoding: "utf-8",
},
},
Expand All @@ -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,
Expand Down

0 comments on commit 6699b43

Please sign in to comment.