From d946dee00976fb9cab566a0525bd188e1058c113 Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Tue, 16 Apr 2019 18:00:46 -0400 Subject: [PATCH] fix: preserve leading "./" in `normalizePath` result --- packages/metro-resolver/src/resolve.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/metro-resolver/src/resolve.js b/packages/metro-resolver/src/resolve.js index 8dffedf599..c660835fbe 100644 --- a/packages/metro-resolver/src/resolve.js +++ b/packages/metro-resolver/src/resolve.js @@ -421,12 +421,16 @@ function isRelativeImport(filePath: string) { } function normalizePath(modulePath) { + const wasRelative = isRelativeImport(modulePath); if (path.sep === '/') { modulePath = path.normalize(modulePath); } else if (path.posix) { modulePath = path.posix.normalize(modulePath); } - + // Ensure `normalize` cannot strip leading "./" + if (wasRelative && modulePath[0] !== '.') { + modulePath = './' + modulePath; + } return modulePath.replace(/\/$/, ''); }