diff --git a/packages/gatsby/cache-dir/loader.js b/packages/gatsby/cache-dir/loader.js index bd18f4a3ae212..c81c37c27ae0b 100644 --- a/packages/gatsby/cache-dir/loader.js +++ b/packages/gatsby/cache-dir/loader.js @@ -92,7 +92,7 @@ export class BaseLoader { // } this.pageDb = new Map() this.inFlightDb = new Map() - this.staticQueryDb = new Map() + this.staticQueryDb = {} this.pageDataDb = new Map() this.prefetchTriggered = new Set() this.prefetchCompleted = new Set() @@ -258,8 +258,8 @@ export class BaseLoader { const staticQueryBatchPromise = Promise.all( staticQueryHashes.map(staticQueryHash => { // Check for cache in case this static query result has already been loaded - if (this.staticQueryDb.has(staticQueryHash)) { - const jsonPayload = this.staticQueryDb.get(staticQueryHash) + if (this.staticQueryDb[staticQueryHash]) { + const jsonPayload = this.staticQueryDb[staticQueryHash] return { staticQueryHash, jsonPayload } } @@ -275,7 +275,7 @@ export class BaseLoader { staticQueryResults.forEach(({ staticQueryHash, jsonPayload }) => { staticQueryResultsMap[staticQueryHash] = jsonPayload - this.staticQueryDb.set(staticQueryHash, jsonPayload) + this.staticQueryDb[staticQueryHash] = jsonPayload }) return staticQueryResultsMap @@ -532,3 +532,7 @@ export const publicLoader = { } export default publicLoader + +export function getStaticQueryResults() { + return instance.staticQueryDb +} diff --git a/packages/gatsby/cache-dir/production-app.js b/packages/gatsby/cache-dir/production-app.js index a7bbab8c0e8ba..4e870917528f8 100644 --- a/packages/gatsby/cache-dir/production-app.js +++ b/packages/gatsby/cache-dir/production-app.js @@ -18,6 +18,7 @@ import { ProdLoader, publicLoader, PageResourceStatus, + getStaticQueryResults, } from "./loader" import EnsureResources from "./ensure-resources" import stripPrefix from "./strip-prefix" @@ -70,15 +71,16 @@ apiRunnerAsync(`onClientEntry`).then(() => { {({ location }) => ( - {({ pageResources, location }) => ( - - - {children} - - - )} + {({ pageResources, location }) => { + const staticQueryResults = getStaticQueryResults() + return ( + + + {children} + + + ) + }} )}