From 9f58dc64130db5126de8a608a5775a8b77d0c14d Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 21 Feb 2024 14:09:04 +0100 Subject: [PATCH] perf(resolve): enable fast path for file urls --- src/resolve.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/resolve.ts b/src/resolve.ts index bd505d7..b6b7be8 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -48,7 +48,12 @@ function _resolve(id: string, options: ResolveOptions = {}): string { return "node:" + id; } - // Skip resolve for absolute paths + // Enable fast path for file urls + if (id.startsWith("file:")) { + id = fileURLToPath(id); + } + + // Skip resolve for absolute paths (fast path) if (isAbsolute(id)) { try { const stat = statSync(id);