diff --git a/bundle-config-loader.js b/bundle-config-loader.js index 92b73398..c3d6f763 100644 --- a/bundle-config-loader.js +++ b/bundle-config-loader.js @@ -19,12 +19,12 @@ module.exports = function (source) { require("nativescript-dev-webpack/hot")(__webpack_require__.h(), (fileName) => applicationFiles.getFile(fileName)); }; - global.__hmrRefresh = function(type) { + global.__hmrRefresh = function({ type, module }) { global.__hmrNeedReload = true; setTimeout(() => { if(global.__hmrNeedReload) { global.__hmrNeedReload = false; - global.__hmrLivesyncBackup(); + global.__hmrLivesyncBackup({ type, module }); } }); } @@ -45,9 +45,9 @@ module.exports = function (source) { if (loadCss) { source = ` require("${ - angular ? - 'nativescript-dev-webpack/load-application-css-angular' : - 'nativescript-dev-webpack/load-application-css-regular' + angular ? + 'nativescript-dev-webpack/load-application-css-angular' : + 'nativescript-dev-webpack/load-application-css-regular' }")(); ${source} `; diff --git a/hot-loader-helper.js b/hot-loader-helper.js index 1314d277..49dd51d5 100644 --- a/hot-loader-helper.js +++ b/hot-loader-helper.js @@ -1,9 +1,9 @@ -module.exports.reload = function(type) { return ` +module.exports.reload = function ({ type, module }) { + return ` if (module.hot) { module.hot.accept(); module.hot.dispose(() => { - global.__hmrRefresh('${type}'); + global.__hmrRefresh({ type: '${type}', module: '${module}' }); }) } `}; - diff --git a/markup-hot-loader.js b/markup-hot-loader.js index 6d330447..601cb16f 100644 --- a/markup-hot-loader.js +++ b/markup-hot-loader.js @@ -1,5 +1,7 @@ const { reload } = require("./hot-loader-helper"); module.exports = function (source) { - return `${source};${reload('markup')}`; + const typeMarkup = "markup"; + const modulePath = this.resourcePath.replace(this.context, "."); + return `${source};${reload({ type: typeMarkup, module: modulePath })}`; }; diff --git a/script-hot-loader.js b/script-hot-loader.js index c8ba3e30..7f59aaaa 100644 --- a/script-hot-loader.js +++ b/script-hot-loader.js @@ -1,5 +1,7 @@ const { reload } = require("./hot-loader-helper"); module.exports = function (source) { - return `${source};${reload('script')}`; + const typeScript = "script"; + const modulePath = this.resourcePath.replace(this.context, "."); + return `${source};${reload({ type: typeScript, module: modulePath })}`; }; diff --git a/style-hot-loader.js b/style-hot-loader.js index 23e6ad72..90fd5ce8 100644 --- a/style-hot-loader.js +++ b/style-hot-loader.js @@ -1,5 +1,7 @@ const { reload } = require("./hot-loader-helper"); module.exports = function (source) { - return `${source};${reload('style')}`; + const typeStyle = "style"; + const modulePath = this.resourcePath.replace(this.context, "."); + return `${source};${reload({ type: typeStyle, module: modulePath })}`; };