diff --git a/.changeset/gold-deers-cry.md b/.changeset/gold-deers-cry.md new file mode 100644 index 000000000..d0f92c9de --- /dev/null +++ b/.changeset/gold-deers-cry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Improve getStaticPaths memoization to successfully store values in the cache diff --git a/packages/astro/src/runtime.ts b/packages/astro/src/runtime.ts index c10a3bce4..83fccfb90 100644 --- a/packages/astro/src/runtime.ts +++ b/packages/astro/src/runtime.ts @@ -31,7 +31,7 @@ const { CompileError } = parser; export interface AstroRuntimeConfig { astroConfig: AstroConfig; - cache: { staticPaths: Record }; + cache: { staticPaths: Record> }; logging: LogOptions; mode: RuntimeMode; snowpack: SnowpackDevServer; @@ -81,8 +81,8 @@ function getParams(array: string[]) { } async function getStaticPathsMemoized(runtimeConfig: AstroRuntimeConfig, component: string, mod: any, args: GetStaticPathsArgs): Promise { - runtimeConfig.cache.staticPaths[component] = runtimeConfig.cache.staticPaths[component] || (await mod.exports.getStaticPaths(args)).flat(); - return runtimeConfig.cache.staticPaths[component]; + runtimeConfig.cache.staticPaths[component] = runtimeConfig.cache.staticPaths[component] || mod.exports.getStaticPaths(args); + return (await runtimeConfig.cache.staticPaths[component]).flat(); } /** Pass a URL to Astro to resolve and build */