fix(schema): use rootDir, not process.cwd, for modulesDir (#25766)

This commit is contained in:
Daniel Roe 2024-02-13 11:19:25 +00:00 committed by GitHub
parent 29b338f8aa
commit 37d24eed7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View File

@ -9,6 +9,8 @@ export default defineBuildConfig({
name: 'config',
builder: 'untyped',
defaults: {
srcDir: '/<srcDir>/',
workspaceDir: '/<workspaceDir>/',
rootDir: '/<rootDir>/',
vite: {
base: '/'

View File

@ -136,10 +136,10 @@ export default defineUntypedSchema({
$default: ['node_modules'],
$resolve: async (val: string[] | undefined, get): Promise<string[]> => {
const rootDir = await get('rootDir') as string
return [
...await Promise.all((val || []).map(async (dir: string) => resolve(rootDir, dir))),
resolve(process.cwd(), 'node_modules')
]
return [...new Set([
...(val || []).map((dir: string) => resolve(rootDir, dir)),
resolve(rootDir, 'node_modules')
])]
}
},

View File

@ -92,14 +92,14 @@ export default defineUntypedSchema({
allow: {
$resolve: async (val: string[] | undefined, get) => {
const [buildDir, srcDir, rootDir, workspaceDir, modulesDir] = await Promise.all([get('buildDir'), get('srcDir'), get('rootDir'), get('workspaceDir'), get('modulesDir')]) as [string, string, string, string, string]
return [
return [...new Set([
buildDir,
srcDir,
rootDir,
workspaceDir,
...(modulesDir),
...val ?? []
]
])]
}
}
}