From 354f21178edbe9e49b0aa30f4da11d7c4f979808 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 9 Nov 2021 10:21:52 -0500 Subject: [PATCH 1/5] Attempt to fix polyfills --- client/package.json | 3 ++- client/src/polyfills.js | 3 ++- client/yarn.lock | 18 +++++------------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/client/package.json b/client/package.json index 87074c85933..d5102c97d60 100644 --- a/client/package.json +++ b/client/package.json @@ -15,7 +15,6 @@ "**/ua-parser-js": "0.7.30" }, "dependencies": { - "@babel/polyfill": "^7.10.1", "@fortawesome/fontawesome-free": "^5.15.4", "@fortawesome/fontawesome-svg-core": "^1.2.36", "@fortawesome/free-brands-svg-icons": "^5.15.4", @@ -32,6 +31,7 @@ "bootstrap": "4.5.0", "bootstrap-vue": "^2.21.2", "citation-js": "^0.5.1", + "core-js": "^3.19.1", "d3": "3", "date-fns": "^2.24.0", "decode-uri-component": "^0.2.0", @@ -70,6 +70,7 @@ "pretty-bytes": "^5.6.0", "proper-skip-list": "^4.0.2", "pyre-to-regexp": "^0.0.5", + "regenerator-runtime": "^0.13.9", "regression": "^2.0.1", "requirejs": "2.3.6", "rxjs": "^7.4.0", diff --git a/client/src/polyfills.js b/client/src/polyfills.js index 81518d46b1e..1550f23a2ea 100644 --- a/client/src/polyfills.js +++ b/client/src/polyfills.js @@ -3,7 +3,8 @@ and polyfill for non-standard features. */ -import "@babel/polyfill"; +import "core-js/stable"; +import "regenerator-runtime/runtime"; import _ from "underscore"; (() => { diff --git a/client/yarn.lock b/client/yarn.lock index 982338145c7..9d62093ed6d 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -791,14 +791,6 @@ "@babel/helper-create-regexp-features-plugin" "^7.14.5" "@babel/helper-plugin-utils" "^7.14.5" -"@babel/polyfill@^7.10.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" - integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.4" - "@babel/preset-env@^7.15.8": version "7.15.8" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.15.8.tgz#f527ce5bcb121cd199f6b502bf23e420b3ff8dba" @@ -3839,10 +3831,10 @@ core-js-pure@^3.0.0: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.18.3.tgz#7eed77dcce1445ab68fd68715856633e2fb3b90c" integrity sha512-qfskyO/KjtbYn09bn1IPkuhHl5PlJ6IzJ9s9sraJ1EqcuGyLGKzhSM1cY0zgyL9hx42eulQLZ6WaeK5ycJCkqw== -core-js@^2.6.5: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== +core-js@^3.19.1: + version "3.19.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.19.1.tgz#f6f173cae23e73a7d88fa23b6e9da329276c6641" + integrity sha512-Tnc7E9iKd/b/ff7GFbhwPVzJzPztGrChB8X8GLqoYGdEOG8IpLnK1xPyo3ZoO3HsK6TodJS58VGPOxA+hLHQMg== core-js@^3.6.0, core-js@^3.8.3: version "3.18.3" @@ -10744,7 +10736,7 @@ regenerate@^1.4.0, regenerate@^1.4.2: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== -regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7: +regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7, regenerator-runtime@^0.13.9: version "0.13.9" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== From 4055e90fb47ecc7cedc82c129ee31629f70f4d7b Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 9 Nov 2021 10:39:44 -0500 Subject: [PATCH 2/5] Drop older custom polyfills in favor of corejs standard --- client/src/polyfills.js | 86 +---------------------------------------- 1 file changed, 1 insertion(+), 85 deletions(-) diff --git a/client/src/polyfills.js b/client/src/polyfills.js index 1550f23a2ea..582c5e59515 100644 --- a/client/src/polyfills.js +++ b/client/src/polyfills.js @@ -4,88 +4,4 @@ */ import "core-js/stable"; -import "regenerator-runtime/runtime"; -import _ from "underscore"; - -(() => { - /* TODO: move to modernizr or something besides us doing this... - * These are across all of our apps (reports, tool shed), but: - * these should be configurable via options because they all need different things. - * So, analysis-polyfills.js, reports-polyfills.js (or analysis/polyfills) - */ - "use strict"; - - // ------------------------------------------------------------------ polyfills - // console protection needed in some versions of IE (at this point (IE>=9), shouldn't be needed) - window.console = window.console || { - log: function () {}, - debug: function () {}, - info: function () {}, - warn: function () {}, - error: function () {}, - assert: function () {}, - }; - - console.debug("Polyfills are running"); - - // phantomjs: does not have the native extend fn assign - Object.assign = Object.assign || _.extend; - - // requestAnimationFrame polyfill - var lastTime = 0; - var vendors = ["ms", "moz", "webkit", "o"]; - for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[`${vendors[x]}RequestAnimationFrame`]; - window.cancelRequestAnimationFrame = window[`${vendors[x]}CancelRequestAnimationFrame`]; - } - - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = (callback, element) => { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(() => { - callback(currTime + timeToCall); - }, timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - } - - if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = (id) => { - window.clearTimeout(id); - }; - } - - // ------------------------------------------------------------------ can't/won't polyfill - var features = [ - { - name: "canvas", - compatible: function () { - return window.CanvasRenderingContext2D; - }, - }, - { - name: "sessionStorage", - compatible: function () { - try { - return window.sessionStorage.length >= 0; - } catch (err) { - console.debug(err); - } - return false; - }, - }, - ]; - // build a list of feature names for features that were not found - var incompatibilities = features.filter((feature) => !feature.compatible()).map((feature) => feature.name); - - // if there are needed features missing, follow the index link to the static incompat warning - if (incompatibilities.length) { - var root = document.querySelectorAll('link[rel="index"]').item(0); - if (root) { - window.location = `${root.href}static/incompatible-browser.html`; - } - console.log(`incompatible browser:\n${incompatibilities.join("\n")}`); - } -})(); +import "regenerator-runtime/runtime"; \ No newline at end of file From 0473a3ee4b7b0c10008246341523e26efdd38559 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 9 Nov 2021 11:36:35 -0500 Subject: [PATCH 3/5] Format. --- client/src/polyfills.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/polyfills.js b/client/src/polyfills.js index 582c5e59515..4aa4d1e1fb8 100644 --- a/client/src/polyfills.js +++ b/client/src/polyfills.js @@ -4,4 +4,4 @@ */ import "core-js/stable"; -import "regenerator-runtime/runtime"; \ No newline at end of file +import "regenerator-runtime/runtime"; From 84fff02788052f6fbcd620728316240873e614fa Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 9 Nov 2021 14:08:13 -0500 Subject: [PATCH 4/5] Fix polyfills for old qunit tests --- client/tests/karma/karma.config.qunit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/tests/karma/karma.config.qunit.js b/client/tests/karma/karma.config.qunit.js index 72b5869def7..2ad9bac073d 100644 --- a/client/tests/karma/karma.config.qunit.js +++ b/client/tests/karma/karma.config.qunit.js @@ -10,7 +10,7 @@ */ const baseKarmaConfig = require("./karma.config.base"); -const testFiles = ["../node_modules/@babel/polyfill/dist/polyfill.js", "../tests/qunit/testBundle.js"]; +const testFiles = ["polyfills.js", "../tests/qunit/testBundle.js"]; const preprocessors = testFiles.reduce((result, path) => { result[path] = ["webpack"]; return result; From 811da5af198032813dd4b636abb87b80072bd3cf Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 9 Nov 2021 14:09:16 -0500 Subject: [PATCH 5/5] Rename client unit tests job since this does more than jest --- .github/workflows/jest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jest.yaml b/.github/workflows/jest.yaml index ec76d5c3ab9..65bfd466843 100644 --- a/.github/workflows/jest.yaml +++ b/.github/workflows/jest.yaml @@ -10,7 +10,7 @@ concurrency: group: client-${{ github.ref }} cancel-in-progress: true jobs: - jest: + client-unit-test: runs-on: ubuntu-latest strategy: matrix: