From 526a78095abe6a5076d941d52836c011615c22e7 Mon Sep 17 00:00:00 2001 From: Alex Liu Date: Tue, 7 Feb 2023 22:01:03 +0800 Subject: [PATCH] fix(nuxt): defer adding route path to preloaded record (#18862) --- packages/nuxt/src/app/composables/preload.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/composables/preload.ts b/packages/nuxt/src/app/composables/preload.ts index b58c0af1f5..3f7345b8b1 100644 --- a/packages/nuxt/src/app/composables/preload.ts +++ b/packages/nuxt/src/app/composables/preload.ts @@ -39,7 +39,6 @@ export async function preloadRouteComponents (to: string, router: Router & { _ro if (!router._routePreloaded) { router._routePreloaded = new Set() } if (router._routePreloaded.has(to)) { return } - router._routePreloaded.add(to) const promises = router._preloadPromises = router._preloadPromises || [] @@ -48,6 +47,8 @@ export async function preloadRouteComponents (to: string, router: Router & { _ro return Promise.all(promises).then(() => preloadRouteComponents(to, router)) } + router._routePreloaded.add(to) + const components = router.resolve(to).matched .map(component => component.components?.default) .filter(component => typeof component === 'function')