From a3b374bc3bb7ff60fe4d4897fe9578f64cccc505 Mon Sep 17 00:00:00 2001 From: Ibra Ben Date: Fri, 10 May 2024 15:10:11 +0100 Subject: [PATCH] fix: resolveFullPath adds extension to bare imports when file with the same module name exists (#197) --- src/utils/import-path-resolver.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/import-path-resolver.ts b/src/utils/import-path-resolver.ts index 6e7fce3..63894dc 100644 --- a/src/utils/import-path-resolver.ts +++ b/src/utils/import-path-resolver.ts @@ -99,7 +99,11 @@ class ImportPathResolver { * If no corresponding file can be found, return the original path. */ private resolveFullPath(importPath: string, ext = '.js') { - if (importPath.match(new RegExp(`\${ext}$`))) { + // If bare import or already a full path import + if ( + !importPath.startsWith('.') || + importPath.match(new RegExp(`\${ext}$`)) + ) { return importPath; } // Try adding the extension (if not obviously a directory)