refactor
This commit is contained in:
parent
c93141daed
commit
e21224067b
17
routes/_utils/loadPolyfills.js
Normal file
17
routes/_utils/loadPolyfills.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import {
|
||||||
|
importURLSearchParams,
|
||||||
|
importIntersectionObserver,
|
||||||
|
importRequestIdleCallback,
|
||||||
|
importIndexedDBGetAllShim,
|
||||||
|
importDialogPolyfill
|
||||||
|
} from './asyncModules'
|
||||||
|
|
||||||
|
export function loadPolyfills() {
|
||||||
|
return Promise.all([
|
||||||
|
typeof URLSearchParams === 'undefined' && importURLSearchParams(),
|
||||||
|
typeof IntersectionObserver === 'undefined' && importIntersectionObserver(),
|
||||||
|
typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(),
|
||||||
|
!IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim(),
|
||||||
|
typeof HTMLDialogElement === 'undefined' && importDialogPolyfill()
|
||||||
|
])
|
||||||
|
}
|
|
@ -1,23 +1,9 @@
|
||||||
import { init } from 'sapper/runtime.js'
|
import { init } from 'sapper/runtime.js'
|
||||||
import { offlineNotifiction } from '../routes/_utils/offlineNotification'
|
import { offlineNotifiction } from '../routes/_utils/offlineNotification'
|
||||||
import { serviceWorkerClient } from '../routes/_utils/serviceWorkerClient'
|
import { serviceWorkerClient } from '../routes/_utils/serviceWorkerClient'
|
||||||
|
import { loadPolyfills } from '../routes/_utils/loadPolyfills'
|
||||||
|
|
||||||
import {
|
loadPolyfills().then(() => {
|
||||||
importURLSearchParams,
|
|
||||||
importIntersectionObserver,
|
|
||||||
importRequestIdleCallback,
|
|
||||||
importIndexedDBGetAllShim,
|
|
||||||
importDialogPolyfill
|
|
||||||
} from '../routes/_utils/asyncModules'
|
|
||||||
|
|
||||||
// polyfills
|
|
||||||
Promise.all([
|
|
||||||
typeof URLSearchParams === 'undefined' && importURLSearchParams(),
|
|
||||||
typeof IntersectionObserver === 'undefined' && importIntersectionObserver(),
|
|
||||||
typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(),
|
|
||||||
!IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim(),
|
|
||||||
typeof HTMLDialogElement === 'undefined' && importDialogPolyfill()
|
|
||||||
]).then(() => {
|
|
||||||
// `routes` is an array of route objects injected by Sapper
|
// `routes` is an array of route objects injected by Sapper
|
||||||
init(document.querySelector('#sapper'), __routes__)
|
init(document.querySelector('#sapper'), __routes__)
|
||||||
})
|
})
|
Loading…
Reference in a new issue