Unverified Commit e34e5e09 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Revert #14580 (#16757)

parent 808d6b94
...@@ -56,12 +56,6 @@ const relPreloadStyle = 'fetch' ...@@ -56,12 +56,6 @@ const relPreloadStyle = 'fetch'
const hasNoModule = 'noModule' in document.createElement('script') const hasNoModule = 'noModule' in document.createElement('script')
const requestIdleCallback: (fn: () => void) => void =
(window as any).requestIdleCallback ||
function (cb: () => void) {
return setTimeout(cb, 1)
}
function normalizeRoute(route: string) { function normalizeRoute(route: string) {
if (route[0] !== '/') { if (route[0] !== '/') {
throw new Error(`Route name should start with a "/", got "${route}"`) throw new Error(`Route name should start with a "/", got "${route}"`)
...@@ -281,8 +275,7 @@ export default class PageLoader { ...@@ -281,8 +275,7 @@ export default class PageLoader {
const { pathname: hrefPathname } = parseRelativeUrl(href) const { pathname: hrefPathname } = parseRelativeUrl(href)
const route = normalizeRoute(hrefPathname) const route = normalizeRoute(hrefPathname)
return this.promisedSsgManifest!.then( return this.promisedSsgManifest!.then(
(s: ClientSsgManifest, _dataHref?: string) => { (s: ClientSsgManifest, _dataHref?: string) =>
requestIdleCallback(() => {
// Check if the route requires a data file // Check if the route requires a data file
s.has(route) && s.has(route) &&
// Try to generate data href, noop when falsy // Try to generate data href, noop when falsy
...@@ -292,9 +285,9 @@ export default class PageLoader { ...@@ -292,9 +285,9 @@ export default class PageLoader {
`link[rel="${relPrefetch}"][href^="${_dataHref}"]` `link[rel="${relPrefetch}"][href^="${_dataHref}"]`
) && ) &&
// Inject the `<link rel=prefetch>` tag for above computed `href`. // Inject the `<link rel=prefetch>` tag for above computed `href`.
appendLink(_dataHref, relPrefetch, 'fetch') appendLink(_dataHref, relPrefetch, 'fetch').catch(() => {
/* ignore prefetch error */
}) })
}
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment