@@ -21,6 +21,7 @@ import { IBuildContext } from "./types"
21
21
import { loadConfig } from "../bootstrap/load-config"
22
22
import { loadPlugins } from "../bootstrap/load-plugins"
23
23
import type { InternalJob } from "../utils/jobs/types"
24
+ import type { IDataLayerContext } from "./../state-machines/data-layer/types"
24
25
import { enableNodeMutationsDetection } from "../utils/detect-node-mutations"
25
26
import { compileGatsbyFiles } from "../utils/parcel/compile-gatsby-files"
26
27
import { resolveModule } from "../utils/module-resolver"
@@ -71,12 +72,15 @@ process.on(`unhandledRejection`, (reason: unknown) => {
71
72
// Otherwise leave commented out.
72
73
// require(`../bootstrap/log-line-function`)
73
74
75
+ type WebhookBody = IDataLayerContext [ "webhookBody" ]
76
+
74
77
export async function initialize ( {
75
78
program : args ,
76
79
parentSpan,
77
80
} : IBuildContext ) : Promise < {
78
81
store : Store < IGatsbyState , AnyAction >
79
82
workerPool : WorkerPool . GatsbyWorkerPool
83
+ webhookBody ?: WebhookBody
80
84
} > {
81
85
if ( process . env . GATSBY_DISABLE_CACHE_PERSISTENCE ) {
82
86
reporter . info (
@@ -651,8 +655,21 @@ export async function initialize({
651
655
}
652
656
}
653
657
658
+ let initialWebhookBody : WebhookBody = undefined
659
+
660
+ if ( process . env . GATSBY_INITIAL_WEBHOOK_BODY ) {
661
+ try {
662
+ initialWebhookBody = JSON . parse ( process . env . GATSBY_INITIAL_WEBHOOK_BODY )
663
+ } catch ( e ) {
664
+ reporter . error (
665
+ `Failed to parse GATSBY_INITIAL_WEBHOOK_BODY as JSON:\n"${ e . message } "`
666
+ )
667
+ }
668
+ }
669
+
654
670
return {
655
671
store,
656
672
workerPool,
673
+ webhookBody : initialWebhookBody ,
657
674
}
658
675
}
0 commit comments