mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +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: {
|
analyze: {
|
||||||
$resolve: async (val, get) => {
|
$resolve: async (val, get) => {
|
||||||
const rootDir = await get('rootDir')
|
const [rootDir, analyzeDir] = await Promise.all([get('rootDir'), get('analyzeDir')])
|
||||||
const analyzeDir = await get('analyzeDir')
|
|
||||||
return defu(typeof val === 'boolean' ? { enabled: val } : val, {
|
return defu(typeof val === 'boolean' ? { enabled: val } : val, {
|
||||||
template: 'treemap',
|
template: 'treemap',
|
||||||
projectRoot: rootDir,
|
projectRoot: rootDir,
|
||||||
|
@ -134,10 +134,13 @@ export default defineUntypedSchema({
|
|||||||
*/
|
*/
|
||||||
modulesDir: {
|
modulesDir: {
|
||||||
$default: ['node_modules'],
|
$default: ['node_modules'],
|
||||||
$resolve: async (val, get) => [
|
$resolve: async (val, get) => {
|
||||||
...await Promise.all(val.map(async (dir: string) => resolve(await get('rootDir'), dir))),
|
const rootDir = await get('rootDir')
|
||||||
resolve(process.cwd(), 'node_modules')
|
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: {
|
alias: {
|
||||||
$resolve: async (val, get) => {
|
$resolve: async (val, get) => {
|
||||||
const srcDir = await get('srcDir')
|
const [srcDir, rootDir, assetsDir, publicDir] = await Promise.all([get('srcDir'), get('rootDir'), get('dir.assets'), get('dir.public')])
|
||||||
const rootDir = await get('rootDir')
|
|
||||||
const dirAssets = await get('dir.assets')
|
|
||||||
const dirPublic = await get('dir.public')
|
|
||||||
return {
|
return {
|
||||||
'~': srcDir,
|
'~': srcDir,
|
||||||
'@': srcDir,
|
'@': srcDir,
|
||||||
'~~': rootDir,
|
'~~': rootDir,
|
||||||
'@@': rootDir,
|
'@@': rootDir,
|
||||||
[dirAssets]: join(srcDir, dirAssets),
|
[assetsDir]: join(srcDir, assetsDir),
|
||||||
[dirPublic]: join(srcDir, dirPublic),
|
[publicDir]: join(srcDir, publicDir),
|
||||||
...val
|
...val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,15 +352,14 @@ export default defineUntypedSchema({
|
|||||||
*/
|
*/
|
||||||
ignore: {
|
ignore: {
|
||||||
$resolve: async (val, get) => {
|
$resolve: async (val, get) => {
|
||||||
const rootDir = await get('rootDir')
|
const [rootDir, ignorePrefix, analyzeDir, buildDir] = await Promise.all([get('rootDir'), get('ignorePrefix'), get('analyzeDir'), get('buildDir')])
|
||||||
const ignorePrefix = await get('ignorePrefix')
|
|
||||||
return [
|
return [
|
||||||
'**/*.stories.{js,cts,mts,ts,jsx,tsx}', // ignore storybook files
|
'**/*.stories.{js,cts,mts,ts,jsx,tsx}', // ignore storybook files
|
||||||
'**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}', // ignore tests
|
'**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}', // ignore tests
|
||||||
'**/*.d.{cts,mts,ts}', // ignore type declarations
|
'**/*.d.{cts,mts,ts}', // ignore type declarations
|
||||||
'**/.{pnpm-store,vercel,netlify,output,git,cache,data}',
|
'**/.{pnpm-store,vercel,netlify,output,git,cache,data}',
|
||||||
relative(rootDir, await get('analyzeDir')),
|
relative(rootDir, analyzeDir),
|
||||||
relative(rootDir, await get('buildDir')),
|
relative(rootDir, buildDir),
|
||||||
ignorePrefix && `**/${ignorePrefix}*.*`
|
ignorePrefix && `**/${ignorePrefix}*.*`
|
||||||
].concat(val).filter(Boolean)
|
].concat(val).filter(Boolean)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ export default defineUntypedSchema({
|
|||||||
if (val) {
|
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`.')
|
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: {
|
vue: {
|
||||||
@ -92,14 +92,17 @@ export default defineUntypedSchema({
|
|||||||
server: {
|
server: {
|
||||||
fs: {
|
fs: {
|
||||||
allow: {
|
allow: {
|
||||||
$resolve: async (val, get) => [
|
$resolve: async (val, get) => {
|
||||||
await get('buildDir'),
|
const [buildDir, srcDir, rootDir, workspaceDir, modulesDir] = await Promise.all([get('buildDir'), get('srcDir'), get('rootDir'), get('workspaceDir'), get('modulesDir')])
|
||||||
await get('srcDir'),
|
return [
|
||||||
await get('rootDir'),
|
buildDir,
|
||||||
await get('workspaceDir'),
|
srcDir,
|
||||||
...(await get('modulesDir')),
|
rootDir,
|
||||||
...val ?? []
|
workspaceDir,
|
||||||
]
|
...(modulesDir),
|
||||||
|
...val ?? []
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user