Small refactor in module resolution

Reviewed By: jeanlauliac

Differential Revision: D6417509

fbshipit-source-id: 9c6abb8ceebb7048c775c9c9d21cd881f7e56c1f
This commit is contained in:
Rafael Oleza 2017-11-28 04:24:36 -08:00 committed by Facebook Github Bot
parent 5cc0939454
commit b0de96c74a
1 changed files with 10 additions and 8 deletions

View File

@ -90,19 +90,21 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
const platform = this._options.platform;
if (
!this._options.helpers.isNodeModulesDir(fromModule.path) &&
!(isRelativeImport(toModuleName) || isAbsolutePath(toModuleName))
isAbsolutePath(toModuleName) ||
isRelativeImport(toModuleName) ||
this._options.helpers.isNodeModulesDir(fromModule.path)
) {
const result = ModuleResolution.tryResolveSync(
() => this._resolveHasteDependency(fromModule, toModuleName, platform),
() =>
resolver.resolveNodeDependency(fromModule, toModuleName, platform),
return cacheResult(
resolver.resolveNodeDependency(fromModule, toModuleName, platform),
);
return cacheResult(result);
}
return cacheResult(
resolver.resolveNodeDependency(fromModule, toModuleName, platform),
ModuleResolution.tryResolveSync(
() => this._resolveHasteDependency(fromModule, toModuleName, platform),
() =>
resolver.resolveNodeDependency(fromModule, toModuleName, platform),
),
);
}