Add value to staticPaths cache before we await it (#1498)
* Add value to staticPaths cache before we await it Fixes https://github.com/snowpackjs/astro/issues/1454 * Update `cache.staticPaths` to store Promises rather than immediate values
This commit is contained in:
parent
ab990b2204
commit
6813106a5d
2 changed files with 8 additions and 3 deletions
5
.changeset/gold-deers-cry.md
Normal file
5
.changeset/gold-deers-cry.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Improve getStaticPaths memoization to successfully store values in the cache
|
|
@ -31,7 +31,7 @@ const { CompileError } = parser;
|
|||
|
||||
export interface AstroRuntimeConfig {
|
||||
astroConfig: AstroConfig;
|
||||
cache: { staticPaths: Record<string, GetStaticPathsResult> };
|
||||
cache: { staticPaths: Record<string, Promise<GetStaticPathsResult>> };
|
||||
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<GetStaticPathsResult> {
|
||||
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 */
|
||||
|
|
Loading…
Reference in a new issue