From 4bcc249a9f34aaac59658ca626c828bd6dbb8046 Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Wed, 14 Feb 2024 15:27:53 -0700 Subject: [PATCH] fix(dev): preload matched routes sequentially (#10116) * fix(dev): preload matched routes sequentially * add changeset --- .changeset/afraid-seals-tan.md | 5 +++++ packages/astro/src/prerender/routing.ts | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 .changeset/afraid-seals-tan.md diff --git a/.changeset/afraid-seals-tan.md b/.changeset/afraid-seals-tan.md new file mode 100644 index 000000000000..a40615e8d16d --- /dev/null +++ b/.changeset/afraid-seals-tan.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes an issue where the dev server froze when typescript aliases were used. diff --git a/packages/astro/src/prerender/routing.ts b/packages/astro/src/prerender/routing.ts index 1c1b8382546a..29e02611e4e3 100644 --- a/packages/astro/src/prerender/routing.ts +++ b/packages/astro/src/prerender/routing.ts @@ -40,16 +40,16 @@ async function preloadAndSetPrerenderStatus({ matches, settings, }: PreloadAndSetPrerenderStatusParams): Promise { - const preloaded = await Promise.all( - matches.map(async (route) => { + const preloaded = new Array + for (const route of matches) { const filePath = new URL(`./${route.component}`, settings.config.root); - if (routeIsRedirect(route)) { - return { + preloaded.push({ preloadedComponent: RedirectComponentInstance, route, filePath, - }; + }); + continue; } const preloadedComponent = await preload({ pipeline, filePath }); @@ -64,9 +64,8 @@ async function preloadAndSetPrerenderStatus({ route.prerender = prerenderStatus; } - return { preloadedComponent, route, filePath }; - }) - ); + preloaded.push({ preloadedComponent, route, filePath }); + } return preloaded; }