From d032e4c50b17213145bdc4ec8ee9c348486dd910 Mon Sep 17 00:00:00 2001 From: Dimitar Tachev Date: Tue, 29 Oct 2019 14:12:31 +0200 Subject: [PATCH] fix: stop ignoring the initial hot updates --- bundle-config-loader.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bundle-config-loader.ts b/bundle-config-loader.ts index db662054..c60a163c 100644 --- a/bundle-config-loader.ts +++ b/bundle-config-loader.ts @@ -34,26 +34,22 @@ const loader: loader.Loader = function (source, map) { const hmr = ` if (module.hot) { const hmrUpdate = require("nativescript-dev-webpack/hmr").hmrUpdate; - global.__initialHmrUpdate = true; - global.__hmrSyncBackup = global.__onLiveSync; + global.__coreModulesLiveSync = global.__onLiveSync; global.__onLiveSync = function () { + // handle hot updated on LiveSync hmrUpdate(); }; global.hmrRefresh = function({ type, path } = {}) { - if (global.__initialHmrUpdate) { - return; - } - + // the hot updates are applied, ask the modules to apply the changes setTimeout(() => { - global.__hmrSyncBackup({ type, path }); + global.__coreModulesLiveSync({ type, path }); }); }; - hmrUpdate().then(() => { - global.__initialHmrUpdate = false; - }) + // handle hot updated on initial app start + hmrUpdate(); } `; @@ -96,4 +92,4 @@ const loader: loader.Loader = function (source, map) { }; -export default loader; \ No newline at end of file +export default loader;