Skip to content

Commit

Permalink
Perform a reload with unaccepted modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Skywalker13 committed Dec 1, 2020
1 parent cb29abb commit 8562dac
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions process-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,40 @@ var hmrDocsUrl = 'https://webpack.js.org/concepts/hot-module-replacement/'; // e

var lastHash;
var failureStatuses = { abort: 1, fail: 1 };
var applyOptions = {
ignoreUnaccepted: true,
ignoreDeclined: true,
ignoreErrored: true,
onUnaccepted: function(data) {
console.warn(
'Ignored an update to unaccepted module ' + data.chain.join(' -> ')
);
},
onDeclined: function(data) {
console.warn(
'Ignored an update to declined module ' + data.chain.join(' -> ')
);
},
onErrored: function(data) {
console.error(data.error);
console.warn(
'Ignored an error while updating module ' +
data.moduleId +
' (' +
data.type +
')'
);
},
};

function upToDate(hash) {
if (hash) lastHash = hash;
return lastHash == __webpack_hash__;
}

module.exports = function(hash, moduleMap, options) {
var applyOptions = {
ignoreUnaccepted: true,
ignoreDeclined: true,
ignoreErrored: true,
onUnaccepted: function(data) {
console.warn(
'Ignored an update to unaccepted module ' + data.chain.join(' -> ')
);
performReload();
},
onDeclined: function(data) {
console.warn(
'Ignored an update to declined module ' + data.chain.join(' -> ')
);
},
onErrored: function(data) {
console.error(data.error);
console.warn(
'Ignored an error while updating module ' +
data.moduleId +
' (' +
data.type +
')'
);
},
};

var reload = options.reload;
if (!upToDate(hash) && module.hot.status() == 'idle') {
if (options.log) console.log('[HMR] Checking for updates on the server...');
Expand Down

0 comments on commit 8562dac

Please sign in to comment.