Files
stash/ui/v2.5/src/polyfills.ts
DingDongSoLong4 a1851b3713 Update dependencies (#3123)
* Update localforage, remove query-string
* Update fontawesome and flag-icons
* Update formatjs
* Update axios and videojs
* Update apollo client and graphql
* Update bootstrap and react
* Update polyfills
* Update vite
* Update ESLint
* Update stylelint
* Update configs
* Rebuild yarn.lock
2023-02-16 14:06:44 +11:00

37 lines
1.4 KiB
TypeScript

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";
import "intersection-observer";
// 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");
}
if (!("ResizeObserver" in window)) {
const ResizeObserver = await import("resize-observer-polyfill");
window.ResizeObserver = ResizeObserver.default;
}
}
export const initPolyfills = async () => {
await checkPolyfills();
};