Permalink
Browse files

packager: ResolutionRequest: use _loadAsFile from _loadAsDir

Summary: We can switch that case easily since it was already discarding the error if any would happen.

Reviewed By: davidaurelio

Differential Revision: D5103851

fbshipit-source-id: a0991f626e94a45efbf666561041af258fdbef0a
  • Loading branch information...
jeanlauliac authored and facebook-github-bot committed May 23, 2017
1 parent 2e24197 commit 306c929000b385dee02dc3495caebd252a7b1307
Showing with 10 additions and 7 deletions.
  1. +10 −7 packager/src/node-haste/DependencyGraph/ResolutionRequest.js
@@ -732,13 +732,16 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
): TModule {
const packageJsonPath = path.join(potentialDirPath, 'package.json');
if (this._options.hasteFS.exists(packageJsonPath)) {
const main = this._options.moduleCache
.getPackage(packageJsonPath)
.getMain();
return tryResolveSync(
() => this._loadAsFileOrThrow(main, fromModule, toModule),
() => this._loadAsDir(main, fromModule, toModule),
);
const package_ = this._options.moduleCache.getPackage(packageJsonPath);
const mainPrefixPath = package_.getMain();
const dirPath = path.dirname(mainPrefixPath);
const prefixName = path.basename(mainPrefixPath);
const candidates = [];
const module = this._loadAsFile(dirPath, prefixName, candidates);
if (module != null) {
return module;
}
return this._loadAsDir(mainPrefixPath, fromModule, toModule);
}
return this._loadAsFileOrThrow(

0 comments on commit 306c929

Please sign in to comment.