Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit a9402ec

Browse files
authored
refactor(HMR): rename global.__hmrRefresh function (#765)
* refactor(HMR): rename global.__hmrRefresh function * refactor(HMR): add __initialHmrUpdate to global scope
1 parent b582c65 commit a9402ec

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

bundle-config-loader.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ module.exports = function (source) {
55
const hmr = `
66
if (module.hot) {
77
const hmrUpdate = require("nativescript-dev-webpack/hmr").hmrUpdate;
8-
let initialHmrUpdate = true;
8+
global.__initialHmrUpdate = true;
99
global.__hmrSyncBackup = global.__onLiveSync;
1010
1111
global.__onLiveSync = function () {
1212
hmrUpdate();
1313
};
1414
15-
global.__hmrRefresh = function({ type, module } = {}) {
16-
if (initialHmrUpdate) {
15+
global.hmrRefresh = function({ type, module } = {}) {
16+
if (global.__initialHmrUpdate) {
1717
return;
1818
}
1919
@@ -22,8 +22,8 @@ module.exports = function (source) {
2222
});
2323
};
2424
25-
hmrUpdate().then(() =>{
26-
initialHmrUpdate = false;
25+
hmrUpdate().then(() => {
26+
global.__initialHmrUpdate = false;
2727
})
2828
}
2929
`;

demo/AngularApp/app/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (module["hot"]) {
1717
module["hot"].accept(["./app.module"], () => {
1818
// Currently the context is needed only for application style modules.
1919
const moduleContext = {};
20-
global["__hmrRefresh"](moduleContext);
20+
global["hmrRefresh"](moduleContext);
2121
});
2222
}
2323

hot-loader-helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports.reload = function ({ type, module }) {
33
if (module.hot) {
44
module.hot.accept();
55
module.hot.dispose(() => {
6-
global.__hmrRefresh({ type: '${type}', module: '${module}' });
6+
global.hmrRefresh({ type: '${type}', module: '${module}' });
77
})
88
}
99
`};

lazy-ngmodule-hot-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const HOT_DISPOSE = `
66
module.hot.dispose(() => {
77
// Currently the context is needed only for application style modules.
88
const moduleContext = {};
9-
global.__hmrRefresh(moduleContext);
9+
global.hmrRefresh(moduleContext);
1010
});`;
1111
const HMR_HANDLER = `
1212
if (module.hot) {

0 commit comments

Comments
 (0)