Unverified Commit 662dfd42 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Drop module.hot from production bundles (#5967)

parent 18cb2c03
...@@ -14,7 +14,6 @@ function supportsPreload (list) { ...@@ -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 { ...@@ -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`
......
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