Skip to content

Commit c9db03a

Browse files
author
Ives van Hoorne
committed
Add module.hot.status
1 parent 043d287 commit c9db03a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/app/src/sandbox/eval/manager.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default class Manager {
7676
dependencies: Object;
7777
webpackHMR: boolean = false;
7878
hardReload: boolean = false;
79+
hmrStatus: 'idle' | 'check' | 'apply' | 'fail' = 'idle';
7980

8081
// List of modules that are being transpiled, to prevent duplicate jobs.
8182
transpileJobs: { [transpiledModuleId: string]: true };
@@ -143,6 +144,8 @@ export default class Manager {
143144
return;
144145
}
145146

147+
this.hmrStatus = 'apply';
148+
146149
// Evaluate the *changed* HMR modules first
147150
this.getTranspiledModules()
148151
.filter(t => t.hmrConfig && t.hmrConfig.isDirty())
@@ -155,6 +158,8 @@ export default class Manager {
155158
// Run post evaluate
156159
this.getTranspiledModules().forEach(t => t.postEvaluate(this));
157160

161+
this.hmrStatus = 'idle';
162+
158163
return exports;
159164
}
160165

@@ -266,6 +271,7 @@ export default class Manager {
266271
* @param {*} entry
267272
*/
268273
async transpileModules(entry: Module) {
274+
this.hmrStatus = 'check';
269275
this.setEnvironmentVariables();
270276
const transpiledModule = this.getTranspiledModule(entry);
271277

@@ -546,6 +552,7 @@ export default class Manager {
546552
* continuing
547553
*/
548554
markHardReload() {
555+
this.hmrStatus = 'fail';
549556
this.hardReload = true;
550557
}
551558

packages/app/src/sandbox/eval/transpiled-module.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ export default class TranspiledModule {
611611
this.hmrConfig.setDisposeHandler(cb);
612612
},
613613
data: hotData,
614+
status: () => manager.hmrStatus,
614615
},
615616
};
616617
this.compilation.hot.data = hotData;

0 commit comments

Comments
 (0)