From e61251aca4432392e4af6cafda5a15b73cf44c4d Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Wed, 11 Dec 2024 22:20:14 +0000 Subject: [PATCH] Remove unused polyfills and adjust support for Intl.getCanonicalLocales --- .../babel-plugins/custom-polyfill-plugin.js | 55 ++++--------------- package.json | 2 - src/resources/polyfills/element-append.ts | 25 --------- yarn.lock | 16 ------ 4 files changed, 11 insertions(+), 87 deletions(-) delete mode 100644 src/resources/polyfills/element-append.ts diff --git a/build-scripts/babel-plugins/custom-polyfill-plugin.js b/build-scripts/babel-plugins/custom-polyfill-plugin.js index b16c15104750..709f3b87e001 100644 --- a/build-scripts/babel-plugins/custom-polyfill-plugin.js +++ b/build-scripts/babel-plugins/custom-polyfill-plugin.js @@ -5,7 +5,7 @@ import paths from "../paths.cjs"; const POLYFILL_DIR = join(paths.polymer_dir, "src/resources/polyfills"); // List of polyfill keys with supported browser targets for the functionality -const PolyfillSupport = { +const polyfillSupport = { // Note states and shadowRoot properties should be supported. "element-internals": { android: 90, @@ -18,17 +18,6 @@ const PolyfillSupport = { safari: 17.4, samsung: 15.0, }, - "element-append": { - android: 54, - chrome: 54, - edge: 17, - firefox: 49, - ios: 10.0, - opera: 41, - opera_mobile: 41, - safari: 10.0, - samsung: 6.0, - }, "element-getattributenames": { android: 61, chrome: 61, @@ -51,27 +40,18 @@ const PolyfillSupport = { safari: 12.0, samsung: 10.0, }, - fetch: { - android: 42, - chrome: 42, - edge: 14, - firefox: 39, - ios: 10.3, - opera: 29, - opera_mobile: 29, - safari: 10.1, - samsung: 4.0, - }, + // FormatJS polyfill detects fix for https://bugs.chromium.org/p/v8/issues/detail?id=10682, + // so adjusted to several months after that was marked fixed "intl-getcanonicallocales": { - android: 54, - chrome: 54, - edge: 16, + android: 90, + chrome: 90, + edge: 90, firefox: 48, ios: 10.3, - opera: 41, - opera_mobile: 41, + opera: 76, + opera_mobile: 64, safari: 10.1, - samsung: 6.0, + samsung: 15.0, }, "intl-locale": { android: 74, @@ -87,17 +67,6 @@ const PolyfillSupport = { "intl-other": { // Not specified (i.e. always try polyfill) since compatibility depends on supported locales }, - proxy: { - android: 49, - chrome: 49, - edge: 12, - firefox: 18, - ios: 10.0, - opera: 36, - opera_mobile: 36, - safari: 10.0, - samsung: 5.0, - }, "resize-observer": { android: 64, chrome: 64, @@ -115,8 +84,6 @@ const PolyfillSupport = { // corresponding polyfill key and actual module to import const polyfillMap = { global: { - fetch: { key: "fetch", module: "unfetch/polyfill" }, - Proxy: { key: "proxy", module: "proxy-polyfill" }, ResizeObserver: { key: "resize-observer", module: join(POLYFILL_DIR, "resize-observer.ts"), @@ -128,7 +95,7 @@ const polyfillMap = { module: "element-internals-polyfill", }, ...Object.fromEntries( - ["append", "getAttributeNames", "toggleAttribute"].map((prop) => { + ["getAttributeNames", "toggleAttribute"].map((prop) => { const key = `element-${prop.toLowerCase()}`; return [prop, { key, module: join(POLYFILL_DIR, `${key}.ts`) }]; }) @@ -168,7 +135,7 @@ export default defineProvider( const resolvePolyfill = createMetaResolver(polyfillMap); return { name: "custom-polyfill", - polyfills: PolyfillSupport, + polyfills: polyfillSupport, usageGlobal(meta, utils) { const polyfill = resolvePolyfill(meta); if (polyfill && shouldInjectPolyfill(polyfill.desc.key)) { diff --git a/package.json b/package.json index 5fae641fdeac..eac740ce8a07 100644 --- a/package.json +++ b/package.json @@ -127,7 +127,6 @@ "marked": "15.0.3", "memoize-one": "6.0.0", "node-vibrant": "3.2.1-alpha.1", - "proxy-polyfill": "0.3.2", "punycode": "2.3.1", "qr-scanner": "1.4.2", "qrcode": "1.5.4", @@ -140,7 +139,6 @@ "tsparticles-engine": "2.12.0", "tsparticles-preset-links": "2.12.0", "ua-parser-js": "1.0.39", - "unfetch": "5.0.0", "vis-data": "7.1.9", "vis-network": "9.1.9", "vue": "2.7.16", diff --git a/src/resources/polyfills/element-append.ts b/src/resources/polyfills/element-append.ts deleted file mode 100644 index 2ab4fbb8936b..000000000000 --- a/src/resources/polyfills/element-append.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md -(function (arr) { - arr.forEach((item) => { - if (Object.prototype.hasOwnProperty.call(item, "append")) { - return; - } - Object.defineProperty(item, "append", { - configurable: true, - enumerable: true, - writable: true, - value: function append(...argArr) { - const docFrag = document.createDocumentFragment(); - - argArr.forEach((argItem) => { - const isNode = argItem instanceof Node; - docFrag.appendChild( - isNode ? argItem : document.createTextNode(String(argItem)) - ); - }); - - this.appendChild(docFrag); - }, - }); - }); -})([Element.prototype, Document.prototype, DocumentFragment.prototype]); diff --git a/yarn.lock b/yarn.lock index 903fb48b23fb..404e035900a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9286,7 +9286,6 @@ __metadata: open: "npm:10.1.0" pinst: "npm:3.0.0" prettier: "npm:3.4.2" - proxy-polyfill: "npm:0.3.2" punycode: "npm:2.3.1" qr-scanner: "npm:1.4.2" qrcode: "npm:1.5.4" @@ -9307,7 +9306,6 @@ __metadata: tsparticles-preset-links: "npm:2.12.0" typescript: "npm:5.7.2" ua-parser-js: "npm:1.0.39" - unfetch: "npm:5.0.0" vis-data: "npm:7.1.9" vis-network: "npm:9.1.9" vitest: "npm:2.1.8" @@ -12290,13 +12288,6 @@ __metadata: languageName: node linkType: hard -"proxy-polyfill@npm:0.3.2": - version: 0.3.2 - resolution: "proxy-polyfill@npm:0.3.2" - checksum: 10/0e43c8ba9cc14d3ce12d029f5647b8c03120fb0b912a176bcb8fb2c560f8fb94e49f89707b6e2df0443e3514d0bb63cc1960d671b39904b479bb09e4ae7e09a4 - languageName: node - linkType: hard - "punycode@npm:2.3.1, punycode@npm:^2.1.0, punycode@npm:^2.3.1": version: 2.3.1 resolution: "punycode@npm:2.3.1" @@ -14503,13 +14494,6 @@ __metadata: languageName: node linkType: hard -"unfetch@npm:5.0.0": - version: 5.0.0 - resolution: "unfetch@npm:5.0.0" - checksum: 10/8a59f9d910f179ef588aa30885849de7b4c895a85b3679ab4da7305be3751b85a4811d9164d87960fef1a388b9a7afdc23ab2154f517db040b27171578fa9e8b - languageName: node - linkType: hard - "unicode-canonical-property-names-ecmascript@npm:^2.0.0": version: 2.0.1 resolution: "unicode-canonical-property-names-ecmascript@npm:2.0.1"