From 9f8b0309dda424f22cb89a04d45d7a327429d2f1 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 17 Oct 2024 10:22:42 +0100 Subject: [PATCH] fix --- .babelrc | 1 + .../{ssr-es-check.yml => es-check.yml} | 6 ------ package.json | 1 + pnpm-lock.yaml | 18 ++++++++++++++++++ rollup.config.js | 11 +++++++++-- src/storage.ts | 13 ++++++++----- 6 files changed, 37 insertions(+), 13 deletions(-) rename .github/workflows/{ssr-es-check.yml => es-check.yml} (66%) diff --git a/.babelrc b/.babelrc index 48f19b72b..7fe9a63a1 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,7 @@ { "presets": ["@babel/env", ["@babel/typescript", { "jsxPragma": "h" }]], "plugins": [ + "@babel/plugin-transform-nullish-coalescing-operator", [ "@babel/transform-react-jsx", { diff --git a/.github/workflows/ssr-es-check.yml b/.github/workflows/es-check.yml similarity index 66% rename from .github/workflows/ssr-es-check.yml rename to .github/workflows/es-check.yml index 21e751cc9..8f64a924f 100644 --- a/.github/workflows/ssr-es-check.yml +++ b/.github/workflows/es-check.yml @@ -21,9 +21,3 @@ jobs: - name: Run es-check to check if our ie11 bundle is ES5 compatible run: npx es-check@7.2.1 es5 dist/array.full.ie11.js - - - name: Run es-check to check if our array bundle is ES6 compatible - run: npx es-check@7.2.1 es6 dist/array.js - - - name: Run es-check to check if our main bundle is ES6 compatible - run: npx es-check@7.2.1 es6 dist/main.js diff --git a/package.json b/package.json index ec334c71e..af8fe056e 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "devDependencies": { "@babel/core": "7.18.9", "@babel/plugin-syntax-decorators": "^7.23.3", + "@babel/plugin-transform-nullish-coalescing-operator": "^7.25.8", "@babel/plugin-transform-react-jsx": "^7.23.4", "@babel/preset-env": "7.18.9", "@babel/preset-typescript": "^7.18.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa87c0579..80781d321 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,6 +30,9 @@ devDependencies: '@babel/plugin-syntax-decorators': specifier: ^7.23.3 version: 7.23.3(@babel/core@7.18.9) + '@babel/plugin-transform-nullish-coalescing-operator': + specifier: ^7.25.8 + version: 7.25.8(@babel/core@7.18.9) '@babel/plugin-transform-react-jsx': specifier: ^7.23.4 version: 7.23.4(@babel/core@7.18.9) @@ -468,6 +471,11 @@ packages: engines: {node: '>=6.9.0'} dev: true + /@babel/helper-plugin-utils@7.25.7: + resolution: {integrity: sha512-eaPZai0PiqCi09pPs3pAFfl/zYgGaE6IdXtYvmf0qlcDTd3WCtO7JWCcRd64e0EQrcYgiHibEZnOGsSY4QSgaw==} + engines: {node: '>=6.9.0'} + dev: true + /@babel/helper-remap-async-to-generator@7.18.9(@babel/core@7.18.9): resolution: {integrity: sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA==} engines: {node: '>=6.9.0'} @@ -1277,6 +1285,16 @@ packages: '@babel/helper-plugin-utils': 7.22.5 dev: true + /@babel/plugin-transform-nullish-coalescing-operator@7.25.8(@babel/core@7.18.9): + resolution: {integrity: sha512-Z7WJJWdQc8yCWgAmjI3hyC+5PXIubH9yRKzkl9ZEG647O9szl9zvmKLzpbItlijBnVhTUf1cpyWBsZ3+2wjWPQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.18.9 + '@babel/helper-plugin-utils': 7.25.7 + dev: true + /@babel/plugin-transform-object-super@7.18.6(@babel/core@7.18.9): resolution: {integrity: sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA==} engines: {node: '>=6.9.0'} diff --git a/rollup.config.js b/rollup.config.js index f0ecf6fe0..a77b0cc0d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -15,6 +15,7 @@ const plugins = (supportIE11) => [ babel({ extensions: ['.js', '.jsx', '.ts', '.tsx'], babelHelpers: 'bundled', + plugins: ['@babel/plugin-transform-nullish-coalescing-operator'], presets: [ [ '@babel/preset-env', @@ -23,12 +24,18 @@ const plugins = (supportIE11) => [ ? '>0.5%, last 2 versions, Firefox ESR, not dead, IE 11' : '>0.5%, last 2 versions, Firefox ESR, not dead', useBuiltIns: supportIE11 ? 'usage' : false, - corejs: '3.38', + corejs: supportIE11 ? '3.38' : undefined, }, ], ], }), - terser({ toplevel: true }), + terser({ + toplevel: true, + compress: { + // 5 is the default if unspecified + ecma: supportIE11 ? 5 : 6, + }, + }), ] const entrypoints = fs.readdirSync('./src/entrypoints') diff --git a/src/storage.ts b/src/storage.ts index 9f67f19f3..aecefe79f 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -110,7 +110,9 @@ export const cookieStore: PersistentStore = { return decodeURIComponent(c.substring(nameEQ.length, c.length)) } } - } catch {} + } catch { + // noop + } return null }, @@ -159,9 +161,8 @@ export const cookieStore: PersistentStore = { } document.cookie = new_cookie_val - return new_cookie_val } catch { - return + // no-op } }, @@ -169,7 +170,7 @@ export const cookieStore: PersistentStore = { try { cookieStore.set(name, '', -1, cross_subdomain) } catch { - return + // no-op } }, } @@ -258,7 +259,9 @@ export const localPlusCookieStore: PersistentStore = { try { // See if there's a cookie stored with data. cookieProperties = cookieStore.parse(name) || {} - } catch {} + } catch { + // noop + } const value = extend(cookieProperties, JSON.parse(localStore.get(name) || '{}')) localStore.set(name, value) return value