metro-resolver
Advanced tools
Comparing version 0.31.0 to 0.32.0
{ | ||
"version": "0.31.0", | ||
"version": "0.32.0", | ||
"name": "metro-resolver", | ||
@@ -4,0 +4,0 @@ "description": "🚇 Metro resolution logic", |
@@ -28,2 +28,3 @@ /** | ||
const Resolver = { | ||
@@ -30,0 +31,0 @@ FailedToResolveNameError: require('./FailedToResolveNameError'), |
@@ -37,2 +37,4 @@ /** | ||
function resolve( | ||
@@ -43,5 +45,9 @@ context, | ||
{ | ||
if (isRelativeImport(moduleName) || isAbsolutePath(moduleName)) { | ||
if ( | ||
!context.resolveRequest && ( | ||
isRelativeImport(moduleName) || isAbsolutePath(moduleName))) | ||
{ | ||
return resolveModulePath(context, moduleName, platform); | ||
} | ||
const realModuleName = context.redirectModulePath(moduleName); | ||
@@ -54,3 +60,6 @@ // exclude | ||
originModulePath = context.originModulePath; | ||
if (isRelativeImport(realModuleName) || isAbsolutePath(realModuleName)) { | ||
if ( | ||
!context.resolveRequest && ( | ||
isRelativeImport(realModuleName) || isAbsolutePath(realModuleName))) | ||
{ | ||
// derive absolute path /.../node_modules/originModuleDir/realModuleName | ||
@@ -67,4 +76,14 @@ const fromModuleParentIdx = | ||
// At that point we only have module names that | ||
// aren't relative paths nor absolute paths. | ||
if (context.resolveRequest) { | ||
try { | ||
const resolution = context.resolveRequest( | ||
moduleName, | ||
context.originModulePath); | ||
if (resolution) { | ||
return { type: 'sourceFile', filePath: resolution }; | ||
} | ||
} catch (error) {} | ||
} | ||
if (context.allowHaste) { | ||
@@ -71,0 +90,0 @@ const normalizedName = normalizePath(realModuleName); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42523
529