From 35e329ad49a4a50b113b453a02f2c2e7d26a312e Mon Sep 17 00:00:00 2001 From: Guilherme Ribeiro Date: Wed, 30 Oct 2024 13:50:59 +0100 Subject: [PATCH] Compiling modern bundle using es2020 (#2917) * using es2020 * Delete packages/lib/xxxx.browserslistrc * changeset * removing default es2022 value --- .changeset/old-fishes-battle.md | 5 +++++ packages/lib/config/rollup.dev.js | 2 +- packages/lib/config/rollup.plugins.js | 9 +++++++-- packages/lib/config/rollup.prod.js | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .changeset/old-fishes-battle.md diff --git a/.changeset/old-fishes-battle.md b/.changeset/old-fishes-battle.md new file mode 100644 index 0000000000..eefd777ace --- /dev/null +++ b/.changeset/old-fishes-battle.md @@ -0,0 +1,5 @@ +--- +'@adyen/adyen-web': patch +--- + +Lowered ECMAScript version to 2020 in order to support older iOS versions diff --git a/packages/lib/config/rollup.dev.js b/packages/lib/config/rollup.dev.js index d4eb0476c6..e603c1c808 100644 --- a/packages/lib/config/rollup.dev.js +++ b/packages/lib/config/rollup.dev.js @@ -18,7 +18,7 @@ export default () => { replaceValues({ bundleType: BUNDLE_TYPES.esm, buildType: 'development' }), convertJsonToESM(), compileCSS({}), - compileJavascript({ target: 'es2022' }) + compileJavascript({ target: 'es2020' }) ], output: [ { diff --git a/packages/lib/config/rollup.plugins.js b/packages/lib/config/rollup.plugins.js index af8a780679..ef90863d92 100644 --- a/packages/lib/config/rollup.plugins.js +++ b/packages/lib/config/rollup.plugins.js @@ -47,8 +47,12 @@ export const compileCSS = ({ extract = 'adyen.css' } = {}) => extract: extract }); -export const compileJavascript = ({ target = 'es2022', sourceMaps = false } = {}) => - swc( +export const compileJavascript = ({ target, sourceMaps = false } = {}) => { + if (!target) { + throw Error('Rollup plugins: compileJavascript task - "target" is missing'); + } + + return swc( defineRollupSwcOption({ tsconfig: '../tsconfig.json', jsc: { @@ -70,6 +74,7 @@ export const compileJavascript = ({ target = 'es2022', sourceMaps = false } = {} inlineSourcesContent: false }) ); +}; export const minify = ({ isESM } = { isESM: true }) => terser({ module: isESM }); diff --git a/packages/lib/config/rollup.prod.js b/packages/lib/config/rollup.prod.js index 2b41e97905..8e654ad647 100644 --- a/packages/lib/config/rollup.prod.js +++ b/packages/lib/config/rollup.prod.js @@ -34,7 +34,7 @@ export default () => { replaceValues({ bundleType: BUNDLE_TYPES.esm, buildType: 'production' }), convertJsonToESM(), compileCSS(), - compileJavascript({ target: 'es2022', sourceMaps: true }), + compileJavascript({ target: 'es2020', sourceMaps: true }), minify() ], output: [ @@ -99,7 +99,7 @@ export default () => { replaceValues({ bundleType: BUNDLE_TYPES.umd, buildType: 'production' }), convertJsonToESM(), compileCSS(), - compileJavascript({ sourceMaps: true }), + compileJavascript({ target: 'es2020', sourceMaps: true }), minify({ isESM: false }) ], output: {