From 022a084dcacbabb1356ca08a7d416799f3530580 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 29 Aug 2022 09:18:11 +0100 Subject: [PATCH] fix(kit): normalize (sort) aliases before resolving --- packages/kit/src/resolve.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/kit/src/resolve.ts b/packages/kit/src/resolve.ts index 6f0bd00810e..68e3b5459fd 100644 --- a/packages/kit/src/resolve.ts +++ b/packages/kit/src/resolve.ts @@ -2,6 +2,7 @@ import { promises as fsp, existsSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { basename, dirname, resolve, join, normalize, isAbsolute } from 'pathe' import { globby } from 'globby' +import { normalizeAliases } from 'pathe/utils' import { tryUseNuxt, useNuxt } from './context' import { tryResolveModule } from './internal/cjs' import { isIgnored } from './ignore' @@ -105,7 +106,7 @@ export function resolveAlias (path: string, alias?: Record): str if (!alias) { alias = tryUseNuxt()?.options.alias || {} } - for (const key in alias) { + for (const key in normalizeAliases(alias)) { if (key === '@' && !path.startsWith('@/')) { continue } // Don't resolve @foo/bar if (path.startsWith(key)) { path = alias[key] + path.slice(key.length)