-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make webpackHotDevClient support webpack 2 too #840
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,8 +272,7 @@ function tryApplyUpdates(onHotUpdateSuccess) { | |
return; | ||
} | ||
|
||
// https://webpack.github.io/docs/hot-module-replacement.html#check | ||
module.hot.check(/* autoApply */true, function(err, updatedModules) { | ||
var checkCallback = function(err, updatedModules) { | ||
if (err || !updatedModules) { | ||
window.location.reload(); | ||
return; | ||
|
@@ -288,5 +287,18 @@ function tryApplyUpdates(onHotUpdateSuccess) { | |
// While we were updating, there was a new update! Do it again. | ||
tryApplyUpdates(); | ||
} | ||
}); | ||
} | ||
|
||
// https://webpack.github.io/docs/hot-module-replacement.html#check | ||
var result = module.hot.check(/* autoApply */true, checkCallback); | ||
|
||
// webpack 2 support | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (result && result.then) { | ||
result.then( | ||
function(updatedModules) { | ||
checkCallback(null, updatedModules); | ||
}, | ||
checkCallback | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For explicitness let’s also write this as a function that passes error as the first argument and |
||
); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s call this
handleApplyUpdates
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: let’s also make this a regular function declaration, i.e.
function handleApplyUpdates(...)