metro: ModuleResolution: do not allow recursive package directories

Reviewed By: davidaurelio

Differential Revision: D6612113

fbshipit-source-id: 8b688cb3eed5cc76b07f471ecc98e22e765583ad
This commit is contained in:
Jean Lauliac 2017-12-24 03:06:11 -08:00 committed by Facebook Github Bot
parent 9ff46c13e3
commit 6adc4cccd2
1 changed files with 5 additions and 5 deletions

View File

@ -107,7 +107,7 @@ type FileCandidates =
* a module name as directory.
*/
type DirCandidates =
| {|+type: 'package', +dir: DirCandidates, +file: FileCandidates|}
| {|+type: 'package', +index: FileCandidates, +file: FileCandidates|}
| {|+type: 'index', +file: FileCandidates|};
type FileAndDirCandidates = {|+dir: DirCandidates, +file: FileCandidates|};
@ -477,13 +477,13 @@ function resolvePackage(
if (fileResult.type === 'resolved') {
return fileResult;
}
const dirResult = resolveDir(context, mainPrefixPath, platform);
if (dirResult.type === 'resolved') {
return dirResult;
const indexResult = resolveFile(context, mainPrefixPath, 'index', platform);
if (indexResult.type === 'resolved') {
return indexResult;
}
return failedFor({
type: 'package',
dir: dirResult.candidates,
index: indexResult.candidates,
file: fileResult.candidates,
});
}