From 5733fc625ea33ab1b07ddfd4f8412e15473d8cca Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 14 Jun 2021 16:00:03 -0400 Subject: [PATCH] perf: avoid double resolve user config on startup --- src/node/config.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/node/config.ts b/src/node/config.ts index 3434f467f5a2..4281e0538c14 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -47,7 +47,7 @@ export async function resolveConfig( root: string = process.cwd() ): Promise { const userConfig = await resolveUserConfig(root) - const site = await resolveSiteData(root) + const site = await resolveSiteData(root, userConfig) // resolve theme path const userThemeDir = resolve(root, 'theme') @@ -90,9 +90,11 @@ export async function resolveUserConfig(root: string) { return userConfig } -export async function resolveSiteData(root: string): Promise { - const userConfig = await resolveUserConfig(root) - +export async function resolveSiteData( + root: string, + userConfig?: UserConfig +): Promise { + userConfig = userConfig || (await resolveUserConfig(root)) return { lang: userConfig.lang || 'en-US', title: userConfig.title || 'VitePress',