diff --git a/packages/gatsby/src/schema/graphql-engine/standalone-regenerate.ts b/packages/gatsby/src/schema/graphql-engine/standalone-regenerate.ts index a498c039f41b8..628725bf98508 100644 --- a/packages/gatsby/src/schema/graphql-engine/standalone-regenerate.ts +++ b/packages/gatsby/src/schema/graphql-engine/standalone-regenerate.ts @@ -18,9 +18,11 @@ node node_modules/gatsby/dist/schema/graphql-engine/standalone-regenerate.js */ import { createGraphqlEngineBundle } from "./bundle-webpack" +import { createPageSSRBundle } from "./../../utils/page-ssr-module/bundle-webpack" import reporter from "gatsby-cli/lib/reporter" import { loadConfigAndPlugins } from "../../utils/worker/child/load-config-and-plugins" import * as fs from "fs-extra" +import { store } from "../../redux" import { validateEngines } from "../../utils/validate-engines" async function run(): Promise { @@ -34,17 +36,30 @@ async function run(): Promise { console.log(`clearing webpack cache\n\n`) // get rid of cache if it exist await fs.remove(process.cwd() + `/.cache/webpack/query-engine`) + await fs.remove(process.cwd() + `/.cache/webpack/page-ssr`) } catch (e) { // eslint-disable no-empty } + const state = store.getState() + // recompile const buildActivityTimer = reporter.activityTimer( `Building Rendering Engines` ) try { buildActivityTimer.start() - await createGraphqlEngineBundle(process.cwd(), reporter, true) + await Promise.all([ + createGraphqlEngineBundle(process.cwd(), reporter, true), + createPageSSRBundle({ + rootDir: process.cwd(), + components: store.getState().components, + staticQueriesByTemplate: state.staticQueriesByTemplate, + webpackCompilationHash: state.webpackCompilationHash, // we set webpackCompilationHash above + reporter, + isVerbose: state.program.verbose, + }), + ]) } catch (err) { buildActivityTimer.panic(err) } finally { diff --git a/packages/gatsby/src/utils/webpack/loaders/webpack-remove-exports-loader.ts b/packages/gatsby/src/utils/webpack/loaders/webpack-remove-exports-loader.ts index e1e7bc28b8e27..a7298f14dc1d5 100644 --- a/packages/gatsby/src/utils/webpack/loaders/webpack-remove-exports-loader.ts +++ b/packages/gatsby/src/utils/webpack/loaders/webpack-remove-exports-loader.ts @@ -49,8 +49,8 @@ const webpackRemoveExportsLoader: LoaderDefinitionFunction = (err, result) => { if (err) { callback(err) - } else if (result && result.code && result.map) { - callback(null, result?.code, result?.map) + } else if (result && result.code) { + callback(null, result?.code, result?.map ?? undefined) } else { callback(null, source, sourceMap) }