mirror of https://github.com/status-im/metro.git
metro-bundler: ModuleGraph: nit: reduce code nesting
Reviewed By: davidaurelio Differential Revision: D6324409 fbshipit-source-id: da7626772cb24b4f3749962e72e5952982b917d6
This commit is contained in:
parent
c04393b397
commit
f0a4418b5b
|
@ -68,7 +68,9 @@ const NULL_MODULE: Moduleish = {
|
||||||
const createModuleMap = ({files, helpers, moduleCache, sourceExts}) => {
|
const createModuleMap = ({files, helpers, moduleCache, sourceExts}) => {
|
||||||
const map = Object.create(null);
|
const map = Object.create(null);
|
||||||
files.forEach(filePath => {
|
files.forEach(filePath => {
|
||||||
if (!helpers.isNodeModulesDir(filePath)) {
|
if (helpers.isNodeModulesDir(filePath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let id;
|
let id;
|
||||||
let module;
|
let module;
|
||||||
if (filePath.endsWith(PACKAGE_JSON)) {
|
if (filePath.endsWith(PACKAGE_JSON)) {
|
||||||
|
@ -79,13 +81,14 @@ const createModuleMap = ({files, helpers, moduleCache, sourceExts}) => {
|
||||||
id = module.name;
|
id = module.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id && module && module.isHaste()) {
|
if (!(id && module && module.isHaste())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!map[id]) {
|
if (!map[id]) {
|
||||||
map[id] = Object.create(null);
|
map[id] = Object.create(null);
|
||||||
}
|
}
|
||||||
const platform =
|
const platform =
|
||||||
parsePlatformFilePath(filePath, platforms).platform ||
|
parsePlatformFilePath(filePath, platforms).platform || GENERIC_PLATFORM;
|
||||||
GENERIC_PLATFORM;
|
|
||||||
|
|
||||||
const existingModule = map[id][platform];
|
const existingModule = map[id][platform];
|
||||||
// 0 = Module, 1 = Package in jest-haste-map
|
// 0 = Module, 1 = Package in jest-haste-map
|
||||||
|
@ -101,8 +104,6 @@ const createModuleMap = ({files, helpers, moduleCache, sourceExts}) => {
|
||||||
'with the same name across two different files.',
|
'with the same name across two different files.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue