Skip to content

Commit

Permalink
fix: update root endpoint, fixes #1226, #1240
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed May 11, 2019
1 parent 0c79474 commit 608805a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions root.js
Expand Up @@ -2,19 +2,24 @@ if (module.hot) {
var hot = require('./index').hot;
var cache = require.cache;

if (!module.parents || !module.parents[0]) {
if (!module.parents || module.parents.length === 0) {
throw new Error(
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' +
'Please use `import {hot} from "react-hot-loader"` instead',
);
}
// access parent
var parent = cache[module.parents[0]];
// remove itself from a cache
if (!parent) {
throw new Error(
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' +
'Please use `import {hot} from "react-hot-loader"` instead',
);
}
// remove self from a cache
delete cache[module.id];
// setup hot for caller

exports.hot = hot(Object.assign({ id: parent.i }, parent));
exports.hot = hot(parent);
} else {
// prod mode
exports.hot = function(a) {
Expand Down

0 comments on commit 608805a

Please sign in to comment.