Check for inverseDependencies existance before calling HMR

Differential Revision: D6449768

fbshipit-source-id: d9fe8b54fec0754ffb8ce2db1e87f180862a57a3
This commit is contained in:
Rafael Oleza 2017-12-01 08:50:28 -08:00 committed by Facebook Github Bot
parent 8cf97e332f
commit 5d76d340e5
1 changed files with 9 additions and 3 deletions

View File

@ -72,9 +72,15 @@ function define(
// named parameter in `define` in production.
const inverseDependencies = arguments[4];
// If the module has already been defined and we're in dev mode,
// hot reload it.
global.__accept(moduleId, factory, dependencyMap, inverseDependencies);
// If the module has already been defined and the define method has been
// called with inverseDependencies, we can hot reload it.
if (inverseDependencies) {
global.__accept(moduleId, factory, dependencyMap, inverseDependencies);
} else {
console.warn(
`Trying to define twice module ID ${moduleId} in the same bundle`,
);
}
}
// prevent repeated calls to `global.nativeRequire` to overwrite modules