From f3e5bcc9c277ff4c9e6aeebdbdb19f9f26e1f62b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 6 Sep 2022 10:34:04 +0200 Subject: [PATCH] fix(resolveAlias): preserve relative paths as is --- src/utils.ts | 5 +++-- test/utils.spec.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index f58e6cc..2305ecd 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,5 @@ -import { normalize, join } from './path' +import { join } from './path' +import { normalizeWindowsPath } from './_internal' const pathSeparators = ['/', '\\', undefined] @@ -27,7 +28,7 @@ export function normalizeAliases (_aliases: Record) { } export function resolveAlias (path: string, aliases: Record) { - const _path = normalize(path) + const _path = normalizeWindowsPath(path) aliases = normalizeAliases(aliases) for (const alias in aliases) { if (_path.startsWith(alias)) { diff --git a/test/utils.spec.ts b/test/utils.spec.ts index 8446bb8..d97fd23 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -32,6 +32,7 @@ describe('alias', () => { } it('unchanged', () => { expect(resolveAlias('foo/bar.js', aliases)).toBe('foo/bar.js') + expect(resolveAlias('./bar.js', aliases)).toBe('./bar.js') }) }) })