From 662dfd42716ae2c2a4043321f2552f0166a7c2be Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 31 Dec 2018 19:06:36 +0100 Subject: [PATCH] Drop module.hot from production bundles (#5967) --- packages/next/client/page-loader.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/next/client/page-loader.js b/packages/next/client/page-loader.js index 672c2955..dddce00d 100644 --- a/packages/next/client/page-loader.js +++ b/packages/next/client/page-loader.js @@ -14,7 +14,6 @@ function supportsPreload (list) { } const hasPreload = supportsPreload(document.createElement('link').relList) -const webpackModule = module export default class PageLoader { constructor (buildId, assetPrefix) { @@ -107,21 +106,24 @@ export default class PageLoader { } } - // Wait for webpack to become idle if it's not. - // More info: https://github.com/zeit/next.js/pull/1511 - if (webpackModule && webpackModule.hot && webpackModule.hot.status() !== 'idle') { - console.log(`Waiting for webpack to become "idle" to initialize the page: "${route}"`) + if (process.env.NODE_ENV !== 'production') { + // Wait for webpack to become idle if it's not. + // More info: https://github.com/zeit/next.js/pull/1511 + if (module.hot && module.hot.status() !== 'idle') { + console.log(`Waiting for webpack to become "idle" to initialize the page: "${route}"`) - const check = (status) => { - if (status === 'idle') { - webpackModule.hot.removeStatusHandler(check) - register() + const check = (status) => { + if (status === 'idle') { + module.hot.removeStatusHandler(check) + register() + } } + module.hot.status(check) + return } - webpackModule.hot.status(check) - } else { - register() } + + register() } async prefetch (route) {