diff --git a/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js b/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js index be00bb0c..aa81768d 100644 --- a/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js +++ b/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js @@ -90,19 +90,21 @@ class ResolutionRequest { 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), + ), ); }