diff --git a/bundle-config-loader.js b/bundle-config-loader.js index 3c489b4b..0b396ff9 100644 --- a/bundle-config-loader.js +++ b/bundle-config-loader.js @@ -5,15 +5,15 @@ module.exports = function (source) { const hmr = ` if (module.hot) { const hmrUpdate = require("nativescript-dev-webpack/hmr").hmrUpdate; - let initialHmrUpdate = true; + global.__initialHmrUpdate = true; global.__hmrSyncBackup = global.__onLiveSync; global.__onLiveSync = function () { hmrUpdate(); }; - global.__hmrRefresh = function({ type, module } = {}) { - if (initialHmrUpdate) { + global.hmrRefresh = function({ type, module } = {}) { + if (global.__initialHmrUpdate) { return; } @@ -22,8 +22,8 @@ module.exports = function (source) { }); }; - hmrUpdate().then(() =>{ - initialHmrUpdate = false; + hmrUpdate().then(() => { + global.__initialHmrUpdate = false; }) } `; diff --git a/demo/AngularApp/app/main.ts b/demo/AngularApp/app/main.ts index eea29eb0..753b2683 100644 --- a/demo/AngularApp/app/main.ts +++ b/demo/AngularApp/app/main.ts @@ -17,7 +17,7 @@ if (module["hot"]) { module["hot"].accept(["./app.module"], () => { // Currently the context is needed only for application style modules. const moduleContext = {}; - global["__hmrRefresh"](moduleContext); + global["hmrRefresh"](moduleContext); }); } diff --git a/hot-loader-helper.js b/hot-loader-helper.js index 49dd51d5..d69a8848 100644 --- a/hot-loader-helper.js +++ b/hot-loader-helper.js @@ -3,7 +3,7 @@ module.exports.reload = function ({ type, module }) { if (module.hot) { module.hot.accept(); module.hot.dispose(() => { - global.__hmrRefresh({ type: '${type}', module: '${module}' }); + global.hmrRefresh({ type: '${type}', module: '${module}' }); }) } `}; diff --git a/lazy-ngmodule-hot-loader.js b/lazy-ngmodule-hot-loader.js index 1384f744..054602a3 100644 --- a/lazy-ngmodule-hot-loader.js +++ b/lazy-ngmodule-hot-loader.js @@ -6,7 +6,7 @@ const HOT_DISPOSE = ` module.hot.dispose(() => { // Currently the context is needed only for application style modules. const moduleContext = {}; - global.__hmrRefresh(moduleContext); + global.hmrRefresh(moduleContext); });`; const HMR_HANDLER = ` if (module.hot) {