Skip to content
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

Merged
merged 2 commits into from
Oct 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions packages/react-dev-utils/webpackHotDevClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
function handleApplyUpdates(err, updatedModules) {
if (err || !updatedModules) {
window.location.reload();
return;
Expand All @@ -288,5 +287,20 @@ 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, handleApplyUpdates);

// // Webpack 2 returns a Promise instead of invoking a callback
if (result && result.then) {
result.then(
function(updatedModules) {
handleApplyUpdates(null, updatedModules);
},
function(err) {
handleApplyUpdates(err, null);
}
);
}
};