mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
perf(schema): use parallel promises (#24771)
Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
parent
ce18fdaf9f
commit
153d5ff273
@ -110,8 +110,7 @@ export default defineUntypedSchema({
|
||||
*/
|
||||
analyze: {
|
||||
$resolve: async (val, get) => {
|
||||
const rootDir = await get('rootDir')
|
||||
const analyzeDir = await get('analyzeDir')
|
||||
const [rootDir, analyzeDir] = await Promise.all([get('rootDir'), get('analyzeDir')])
|
||||
return defu(typeof val === 'boolean' ? { enabled: val } : val, {
|
||||
template: 'treemap',
|
||||
projectRoot: rootDir,
|
||||
|
@ -134,10 +134,13 @@ export default defineUntypedSchema({
|
||||
*/
|
||||
modulesDir: {
|
||||
$default: ['node_modules'],
|
||||
$resolve: async (val, get) => [
|
||||
...await Promise.all(val.map(async (dir: string) => resolve(await get('rootDir'), dir))),
|
||||
resolve(process.cwd(), 'node_modules')
|
||||
]
|
||||
$resolve: async (val, get) => {
|
||||
const rootDir = await get('rootDir')
|
||||
return [
|
||||
...await Promise.all(val.map(async (dir: string) => resolve(rootDir, dir))),
|
||||
resolve(process.cwd(), 'node_modules')
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -309,17 +312,14 @@ export default defineUntypedSchema({
|
||||
*/
|
||||
alias: {
|
||||
$resolve: async (val, get) => {
|
||||
const srcDir = await get('srcDir')
|
||||
const rootDir = await get('rootDir')
|
||||
const dirAssets = await get('dir.assets')
|
||||
const dirPublic = await get('dir.public')
|
||||
const [srcDir, rootDir, assetsDir, publicDir] = await Promise.all([get('srcDir'), get('rootDir'), get('dir.assets'), get('dir.public')])
|
||||
return {
|
||||
'~': srcDir,
|
||||
'@': srcDir,
|
||||
'~~': rootDir,
|
||||
'@@': rootDir,
|
||||
[dirAssets]: join(srcDir, dirAssets),
|
||||
[dirPublic]: join(srcDir, dirPublic),
|
||||
[assetsDir]: join(srcDir, assetsDir),
|
||||
[publicDir]: join(srcDir, publicDir),
|
||||
...val
|
||||
}
|
||||
}
|
||||
@ -352,15 +352,14 @@ export default defineUntypedSchema({
|
||||
*/
|
||||
ignore: {
|
||||
$resolve: async (val, get) => {
|
||||
const rootDir = await get('rootDir')
|
||||
const ignorePrefix = await get('ignorePrefix')
|
||||
const [rootDir, ignorePrefix, analyzeDir, buildDir] = await Promise.all([get('rootDir'), get('ignorePrefix'), get('analyzeDir'), get('buildDir')])
|
||||
return [
|
||||
'**/*.stories.{js,cts,mts,ts,jsx,tsx}', // ignore storybook files
|
||||
'**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}', // ignore tests
|
||||
'**/*.d.{cts,mts,ts}', // ignore type declarations
|
||||
'**/.{pnpm-store,vercel,netlify,output,git,cache,data}',
|
||||
relative(rootDir, await get('analyzeDir')),
|
||||
relative(rootDir, await get('buildDir')),
|
||||
relative(rootDir, analyzeDir),
|
||||
relative(rootDir, buildDir),
|
||||
ignorePrefix && `**/${ignorePrefix}*.*`
|
||||
].concat(val).filter(Boolean)
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export default defineUntypedSchema({
|
||||
if (val) {
|
||||
consola.warn('Directly configuring the `vite.publicDir` option is not supported. Instead, set `dir.public`. You can read more in `https://nuxt.com/docs/api/nuxt-config#public`.')
|
||||
}
|
||||
return val ?? resolve((await get('srcDir')), (await get('dir')).public)
|
||||
return val ?? await Promise.all([get('srcDir'), get('dir')]).then(([srcDir, dir]) => resolve(srcDir, dir.public))
|
||||
}
|
||||
},
|
||||
vue: {
|
||||
@ -92,14 +92,17 @@ export default defineUntypedSchema({
|
||||
server: {
|
||||
fs: {
|
||||
allow: {
|
||||
$resolve: async (val, get) => [
|
||||
await get('buildDir'),
|
||||
await get('srcDir'),
|
||||
await get('rootDir'),
|
||||
await get('workspaceDir'),
|
||||
...(await get('modulesDir')),
|
||||
...val ?? []
|
||||
]
|
||||
$resolve: async (val, get) => {
|
||||
const [buildDir, srcDir, rootDir, workspaceDir, modulesDir] = await Promise.all([get('buildDir'), get('srcDir'), get('rootDir'), get('workspaceDir'), get('modulesDir')])
|
||||
return [
|
||||
buildDir,
|
||||
srcDir,
|
||||
rootDir,
|
||||
workspaceDir,
|
||||
...(modulesDir),
|
||||
...val ?? []
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user