pinafore/src/routes/_utils/polyfills/loadPolyfills.js
Nolan Lawson 98815714ba
fix: fix name of webpack chunk for intl polyfill (#2001)
* fix: fix name of webpack chunk for intl polyfill

* fix: fix typo
2021-03-15 19:46:58 -07:00

28 lines
915 B
JavaScript

import {
importIntlListFormat,
importIntlLocale, importIntlPluralRules, importIntlRelativeTimeFormat,
importRequestIdleCallback
} from './asyncPolyfills'
async function loadIntlPolyfillsIfNecessary () {
// Have to chain these so that they load in the proper order.
// Luckily these requests aren't done in serial, because we're using the same Webpack
// chunk name for each one.
if (typeof Intl.Locale !== 'function') {
await importIntlLocale()
}
if (typeof Intl.PluralRules !== 'function') {
await importIntlPluralRules()
}
await Promise.all([
typeof Intl.RelativeTimeFormat !== 'function' && importIntlRelativeTimeFormat(),
typeof Intl.ListFormat !== 'function' && importIntlListFormat()
])
}
export function loadPolyfills () {
return Promise.all([
typeof requestIdleCallback !== 'function' && importRequestIdleCallback(),
loadIntlPolyfillsIfNecessary()
])
}