From a5131bd1509e93084260f5dd1d97e6e34edd7afc Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Fri, 20 Nov 2020 00:43:05 +0700 Subject: [PATCH] fix(gatsby): pull out a few bug fixes from https://github.com/gatsbyjs/gatsby/pull/28149/ (#28186) (#28188) * fix(gatsby): pull out a few bug fixes from https://github.com/gatsbyjs/gatsby/pull/28149/ * Add missing fix (cherry picked from commit f9fd11d319b3ec097cce6378ccedb86a7f2f8cc8) Co-authored-by: Kyle Mathews --- packages/gatsby/cache-dir/loader.js | 6 +++++- packages/gatsby/src/services/initialize.ts | 2 +- packages/gatsby/src/utils/dev-ssr/render-dev-html.ts | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/cache-dir/loader.js b/packages/gatsby/cache-dir/loader.js index bf2c925114603..6fd98a41e0e5a 100644 --- a/packages/gatsby/cache-dir/loader.js +++ b/packages/gatsby/cache-dir/loader.js @@ -568,5 +568,9 @@ export const publicLoader = { export default publicLoader export function getStaticQueryResults() { - return instance.staticQueryDb + if (instance) { + return instance.staticQueryDb + } else { + return {} + } } diff --git a/packages/gatsby/src/services/initialize.ts b/packages/gatsby/src/services/initialize.ts index 8da75b4c4805a..475119441c3c5 100644 --- a/packages/gatsby/src/services/initialize.ts +++ b/packages/gatsby/src/services/initialize.ts @@ -71,7 +71,7 @@ This will help the dev environment more closely mimic builds so you'll catch bui Try out develop SSR *today* by running your site with it enabled: -GATSBY_EXPERIMENT_DEV_SSR=true gatsby develop +GATSBY_EXPERIMENTAL_DEV_SSR=true gatsby develop Please let us know how it goes good, bad, or otherwise at gatsby.dev/dev-ssr-feedback `, diff --git a/packages/gatsby/src/utils/dev-ssr/render-dev-html.ts b/packages/gatsby/src/utils/dev-ssr/render-dev-html.ts index a2b15d6d8d9de..a27dcd33c9a69 100644 --- a/packages/gatsby/src/utils/dev-ssr/render-dev-html.ts +++ b/packages/gatsby/src/utils/dev-ssr/render-dev-html.ts @@ -3,6 +3,7 @@ import _ from "lodash" import { startListener } from "../../bootstrap/requires-writer" import { findPageByPath } from "../find-page-by-path" +import { getPageData as getPageDataExperimental } from "../get-page-data" const startWorker = (): any => { const newWorker = new JestWorker(require.resolve(`./render-dev-html-child`), { @@ -63,6 +64,9 @@ export const renderDevHTML = ({ isClientOnlyPage = true } + // Ensure the query has been run and written out. + await getPageDataExperimental(pageObj.path) + try { const htmlString = await worker.renderHTML({ path,