1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Drop module.hot from production bundles (#5967)

This commit is contained in:
Tim Neutkens 2018-12-31 19:06:36 +01:00 committed by GitHub
parent 18cb2c03df
commit 662dfd4271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,6 @@ function supportsPreload (list) {
} }
const hasPreload = supportsPreload(document.createElement('link').relList) const hasPreload = supportsPreload(document.createElement('link').relList)
const webpackModule = module
export default class PageLoader { export default class PageLoader {
constructor (buildId, assetPrefix) { constructor (buildId, assetPrefix) {
@ -107,23 +106,26 @@ export default class PageLoader {
} }
} }
if (process.env.NODE_ENV !== 'production') {
// Wait for webpack to become idle if it's not. // Wait for webpack to become idle if it's not.
// More info: https://github.com/zeit/next.js/pull/1511 // More info: https://github.com/zeit/next.js/pull/1511
if (webpackModule && webpackModule.hot && webpackModule.hot.status() !== 'idle') { if (module.hot && module.hot.status() !== 'idle') {
console.log(`Waiting for webpack to become "idle" to initialize the page: "${route}"`) console.log(`Waiting for webpack to become "idle" to initialize the page: "${route}"`)
const check = (status) => { const check = (status) => {
if (status === 'idle') { if (status === 'idle') {
webpackModule.hot.removeStatusHandler(check) module.hot.removeStatusHandler(check)
register() register()
} }
} }
webpackModule.hot.status(check) module.hot.status(check)
} else { return
register()
} }
} }
register()
}
async prefetch (route) { async prefetch (route) {
route = this.normalizeRoute(route) route = this.normalizeRoute(route)
const scriptRoute = route === '/' ? '/index.js' : `${route}.js` const scriptRoute = route === '/' ? '/index.js' : `${route}.js`