From e15aeda2210db31f93d03c0827b2ceeaee973b35 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Tue, 13 Oct 2020 16:02:26 -0400 Subject: [PATCH] Switch to core-js for polyfills --- babel.config.json | 2 ++ config/rollup.config.legacy.js | 4 +++- modules/id.js | 11 ++++++----- package.json | 5 ++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/babel.config.json b/babel.config.json index 52fedc958..3be60f4ab 100644 --- a/babel.config.json +++ b/babel.config.json @@ -2,6 +2,8 @@ "presets": [ [ "@babel/preset-env", { + "useBuiltIns": "usage", + "corejs": 3, "modules": false } ] diff --git a/config/rollup.config.legacy.js b/config/rollup.config.legacy.js index 92c39fe78..8e9ad0df1 100644 --- a/config/rollup.config.legacy.js +++ b/config/rollup.config.legacy.js @@ -29,7 +29,9 @@ export default { commonjs(), json({ indent: '' }), babel({ - babelHelpers: 'bundled' + babelHelpers: 'bundled', + // avoid circular dependencies due to `useBuiltIns: usage` option + exclude: [/\/core-js\//] }) ] }; diff --git a/modules/id.js b/modules/id.js index f53265dfe..b34557a48 100644 --- a/modules/id.js +++ b/modules/id.js @@ -1,10 +1,12 @@ -import 'browser-polyfills'; -import 'es6-symbol/implement'; +// polyfills newer JS functionality for older browsers +import 'core-js/stable'; import 'regenerator-runtime/runtime'; -import 'string.fromcodepoint/auto'; + +// polyfill window.fetch and AbortController (not included in core-js) +import 'whatwg-fetch'; import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'; -// polyfill requestIdleCallback +// polyfill idle callback functions (not included in core-js) window.requestIdleCallback = window.requestIdleCallback || function(cb) { var start = Date.now(); @@ -17,7 +19,6 @@ window.requestIdleCallback = window.requestIdleCallback || }); }); }; - window.cancelIdleCallback = window.cancelIdleCallback || function(id) { window.cancelAnimationFrame(id); diff --git a/package.json b/package.json index c4d286305..3fc6337f4 100644 --- a/package.json +++ b/package.json @@ -50,9 +50,8 @@ "abortcontroller-polyfill": "^1.4.0", "aes-js": "^3.1.2", "alif-toolkit": "^1.2.9", - "browser-polyfills": "~1.5.0", + "core-js": "^3.6.5", "diacritics": "1.3.0", - "es6-symbol": "^3.1.3", "fast-deep-equal": "~3.1.1", "fast-json-stable-stringify": "2.1.0", "lodash-es": "~4.17.15", @@ -63,7 +62,7 @@ "pannellum": "2.5.6", "rbush": "3.0.1", "regenerator-runtime": "^0.13.7", - "string.fromcodepoint": "1.0.0", + "whatwg-fetch": "^3.4.1", "which-polygon": "2.2.0" }, "devDependencies": {