chore: add warning for / mapping in resolve.alias (#18588)

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
This commit is contained in:
翠 / green 2024-11-06 15:11:24 +09:00 committed by GitHub
parent 7a33f6fabf
commit a51c254265
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -806,6 +806,16 @@ function resolveResolveOptions(
// resolve alias with internal client alias
const alias = normalizeAlias(mergeAlias(clientAlias, resolve?.alias || []))
const preserveSymlinks = resolve?.preserveSymlinks ?? false
if (alias.some((a) => a.find === '/')) {
logger.warn(
colors.yellow(
`\`resolve.alias\` contains an alias that maps \`/\`. ` +
`This is not recommended as it can cause unexpected behavior when resolving paths.`,
),
)
}
return resolveEnvironmentResolveOptions(
resolve,
alias,