2018-01-28 01:31:26 +01:00
|
|
|
import {
|
2022-11-25 00:24:29 +01:00
|
|
|
importDynamicViewportUnitsPolyfill,
|
2021-03-16 03:46:58 +01:00
|
|
|
importIntlListFormat,
|
|
|
|
importIntlLocale, importIntlPluralRules, importIntlRelativeTimeFormat,
|
|
|
|
importRequestIdleCallback
|
2021-07-05 05:19:04 +02:00
|
|
|
} from './asyncPolyfills.js'
|
|
|
|
import { mark, stop } from '../marks.js'
|
2018-01-28 01:31:26 +01:00
|
|
|
|
2021-03-16 03:46:58 +01: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()
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
2021-06-19 18:29:32 +02:00
|
|
|
export async function loadPolyfills () {
|
|
|
|
mark('loadPolyfills')
|
|
|
|
await Promise.all([
|
2021-02-16 00:07:19 +01:00
|
|
|
typeof requestIdleCallback !== 'function' && importRequestIdleCallback(),
|
2022-11-25 00:24:29 +01:00
|
|
|
loadIntlPolyfillsIfNecessary(),
|
|
|
|
!CSS.supports('height: 1dvh') && importDynamicViewportUnitsPolyfill()
|
2018-01-28 01:31:26 +01:00
|
|
|
])
|
2021-06-19 18:29:32 +02:00
|
|
|
stop('loadPolyfills')
|
2018-02-09 07:29:29 +01:00
|
|
|
}
|