pinafore/src/routes/_utils/loadPolyfills.js

23 lines
967 B
JavaScript
Raw Normal View History

2018-01-27 16:31:26 -08:00
import {
importArrayFlat,
importCustomElementsPolyfill,
importIndexedDBGetAllShim,
2018-01-27 16:31:26 -08:00
importIntersectionObserver,
importIntl,
importRequestIdleCallback,
importShadowDomPolyfill
} from './asyncPolyfills'
2018-01-27 16:31:26 -08:00
2018-02-08 22:29:29 -08:00
export function loadPolyfills () {
2018-01-27 16:31:26 -08:00
return Promise.all([
typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(),
// these legacy polyfills should be kept in sync with webpack/shared.config.js
process.env.LEGACY && !Array.prototype.flat && importArrayFlat(),
process.env.LEGACY && !IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim(),
process.env.LEGACY && typeof IntersectionObserver === 'undefined' && importIntersectionObserver(),
process.env.LEGACY && typeof Intl === 'undefined' && importIntl(),
process.env.LEGACY && typeof customElements === 'undefined' && importCustomElementsPolyfill(),
process.env.LEGACY && !HTMLElement.prototype.attachShadow && importShadowDomPolyfill()
2018-01-27 16:31:26 -08:00
])
2018-02-08 22:29:29 -08:00
}