mirror of https://github.com/status-im/metro.git
Allow for falsy module exports
Reviewed By: javache Differential Revision: D3207353 fb-gh-sync-id: 3e23eb9cc9facea7993ce684f87ff4b7b0003a1c fbshipit-source-id: 3e23eb9cc9facea7993ce684f87ff4b7b0003a1c
This commit is contained in:
parent
ae9f74e68d
commit
faa9adf2ab
|
@ -27,13 +27,16 @@ function define(moduleId, factory) {
|
|||
modules[moduleId] = {
|
||||
factory,
|
||||
hasError: false,
|
||||
isInitialized: false,
|
||||
exports: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function require(moduleId) {
|
||||
const module = modules[moduleId];
|
||||
return module && module.exports || loadModule(moduleId, module);
|
||||
return module && module.isInitialized
|
||||
? module.exports
|
||||
: loadModule(moduleId, module);
|
||||
}
|
||||
|
||||
function guardedLoadModule(moduleId, module) {
|
||||
|
@ -68,6 +71,7 @@ function loadModuleImplementation(moduleId, module) {
|
|||
}
|
||||
|
||||
const exports = module.exports = {};
|
||||
module.isInitialized = true;
|
||||
const {factory} = module;
|
||||
try {
|
||||
if (__DEV__) {
|
||||
|
@ -83,6 +87,7 @@ function loadModuleImplementation(moduleId, module) {
|
|||
}
|
||||
return (module.exports = moduleObject.exports);
|
||||
} catch (e) {
|
||||
module.isInitialized = false;
|
||||
module.hasError = true;
|
||||
module.exports = undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue