Update javascript polyfills (#1083)

This commit is contained in:
InfiniteTF
2021-01-29 23:16:28 +01:00
committed by GitHub
parent 89fcd6d775
commit 23d2668b38
5 changed files with 77 additions and 7 deletions

30
ui/v2.5/src/polyfills.ts Normal file
View File

@@ -0,0 +1,30 @@
import replaceAll from "string.prototype.replaceall";
import { shouldPolyfill as shouldPolyfillCanonicalLocales } from "@formatjs/intl-getcanonicallocales/should-polyfill";
import { shouldPolyfill as shouldPolyfillLocale } from "@formatjs/intl-locale/should-polyfill";
import { shouldPolyfill as shouldPolyfillNumberformat } from "@formatjs/intl-numberformat/should-polyfill";
import { shouldPolyfill as shouldPolyfillPluralRules } from "@formatjs/intl-pluralrules/should-polyfill";
// Required for browsers older than August 2020ish. Can be removed at some point.
replaceAll.shim();
async function checkPolyfills() {
if (shouldPolyfillCanonicalLocales()) {
await import("@formatjs/intl-getcanonicallocales/polyfill");
}
if (shouldPolyfillLocale()) {
await import("@formatjs/intl-locale/polyfill");
}
if (shouldPolyfillNumberformat()) {
await import("@formatjs/intl-numberformat/polyfill");
await import("@formatjs/intl-numberformat/locale-data/en");
await import("@formatjs/intl-numberformat/locale-data/en-GB");
}
if (shouldPolyfillPluralRules()) {
await import("@formatjs/intl-pluralrules/polyfill");
await import("@formatjs/intl-pluralrules/locale-data/en");
}
}
export const initPolyfills = async () => {
await checkPolyfills();
};