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
This commit is contained in:
parent
2e24197da3
commit
306c929000
|
@ -732,13 +732,16 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
||||||
): TModule {
|
): TModule {
|
||||||
const packageJsonPath = path.join(potentialDirPath, 'package.json');
|
const packageJsonPath = path.join(potentialDirPath, 'package.json');
|
||||||
if (this._options.hasteFS.exists(packageJsonPath)) {
|
if (this._options.hasteFS.exists(packageJsonPath)) {
|
||||||
const main = this._options.moduleCache
|
const package_ = this._options.moduleCache.getPackage(packageJsonPath);
|
||||||
.getPackage(packageJsonPath)
|
const mainPrefixPath = package_.getMain();
|
||||||
.getMain();
|
const dirPath = path.dirname(mainPrefixPath);
|
||||||
return tryResolveSync(
|
const prefixName = path.basename(mainPrefixPath);
|
||||||
() => this._loadAsFileOrThrow(main, fromModule, toModule),
|
const candidates = [];
|
||||||
() => this._loadAsDir(main, fromModule, toModule),
|
const module = this._loadAsFile(dirPath, prefixName, candidates);
|
||||||
);
|
if (module != null) {
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
return this._loadAsDir(mainPrefixPath, fromModule, toModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._loadAsFileOrThrow(
|
return this._loadAsFileOrThrow(
|
||||||
|
|
Loading…
Reference in New Issue