Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(kit): use pathe to resolve aliases #8453

Merged
merged 2 commits into from Oct 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/kit/src/resolve.ts
Expand Up @@ -2,7 +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 { normalizeAliases, resolveAlias as _resolveAlias } from 'pathe/utils'
danielroe marked this conversation as resolved.
Show resolved Hide resolved
import { tryUseNuxt, useNuxt } from './context'
import { tryResolveModule } from './internal/cjs'
import { isIgnored } from './ignore'
Expand Down Expand Up @@ -106,13 +106,7 @@ export function resolveAlias (path: string, alias?: Record<string, string>): str
if (!alias) {
alias = tryUseNuxt()?.options.alias || {}
}
for (const key in normalizeAliases(alias)) {
if (key === '@' && !path.startsWith('@/')) { continue } // Don't resolve @foo/bar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we have removed @ and @/ check from pathe util

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we now respect path separate which should do the same thing.

if (path.startsWith(key)) {
path = alias[key] + path.slice(key.length)
}
}
return path
return _resolveAlias(path, alias)
}

export interface Resolver {
Expand Down