2018-01-27 16:31:26 -08:00
|
|
|
import {
|
2021-03-15 19:46:58 -07:00
|
|
|
importIntlListFormat,
|
|
|
|
importIntlLocale, importIntlPluralRules, importIntlRelativeTimeFormat,
|
|
|
|
importRequestIdleCallback
|
2018-12-15 17:13:46 -08:00
|
|
|
} from './asyncPolyfills'
|
2018-01-27 16:31:26 -08:00
|
|
|
|
2021-03-15 19:46:58 -07:00
|
|
|
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()
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
2018-02-08 22:29:29 -08:00
|
|
|
export function loadPolyfills () {
|
2018-01-27 16:31:26 -08:00
|
|
|
return Promise.all([
|
2021-02-15 15:07:19 -08:00
|
|
|
typeof requestIdleCallback !== 'function' && importRequestIdleCallback(),
|
2021-03-15 19:46:58 -07:00
|
|
|
loadIntlPolyfillsIfNecessary()
|
2018-01-27 16:31:26 -08:00
|
|
|
])
|
2018-02-08 22:29:29 -08:00
|
|
|
}
|