mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-11 11:50:54 +08:00
webpack: add HMR
This commit is contained in:
@@ -13,3 +13,30 @@ let contextModule = context<SomeModule>('./someModule');
|
||||
require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => {
|
||||
|
||||
});
|
||||
|
||||
// check if HMR is enabled
|
||||
if(module.hot) {
|
||||
// accept update of dependency
|
||||
module.hot.accept("./handler.js", function() {
|
||||
//...
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = null;
|
||||
|
||||
// check if HMR is enabled
|
||||
if(module.hot) {
|
||||
|
||||
// accept itself
|
||||
module.hot.accept();
|
||||
|
||||
// dispose handler
|
||||
module.hot.dispose(function() {
|
||||
// revoke the side effect
|
||||
//...
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var status: string = module.hot.status();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user