mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 09:45:04 +00:00
Allow already loaded modules to be require
’d by name string in dev mode
Summary: The code to require modules by their name (rather than their numeric ID) was buggy, because it didn’t check whether the module factory was already executed and the module already existed. This diff checks the already loaded modules, too, when loading modules by name. Reviewed By: lexs Differential Revision: D3281350 fbshipit-source-id: cef236e152fe5484f21c877d6cee37433fa11c76
This commit is contained in:
parent
f1d12f6b38
commit
d5ceb4175b
@ -41,17 +41,19 @@ function define(moduleId, factory) {
|
||||
}
|
||||
|
||||
function require(moduleId) {
|
||||
const module = modules[moduleId];
|
||||
const module = __DEV__
|
||||
? modules[moduleId] || modules[verboseNamesToModuleIds[moduleId]]
|
||||
: modules[moduleId];
|
||||
return module && module.isInitialized
|
||||
? module.exports
|
||||
: guardedLoadModule(moduleId, module);
|
||||
}
|
||||
|
||||
var inGuard = false;
|
||||
let inGuard = false;
|
||||
function guardedLoadModule(moduleId, module) {
|
||||
if (!inGuard && global.ErrorUtils) {
|
||||
inGuard = true;
|
||||
var returnValue;
|
||||
let returnValue;
|
||||
try {
|
||||
returnValue = loadModuleImplementation(moduleId, module);
|
||||
} catch (e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user