Skip to content

Commit 3032a1b

Browse files
LekoArtstyhoppAndarist
authored
fix(gatsby): Use xstate predictableActionArguments & update to 4.34 (#36342)
* update version and fix types * yolo add option * Work around removal of meta.state * Refactor `meta.state` access in `gatsby-source-filesystem` (#36355) Co-authored-by: Lennart <[email protected]> * fix ts-ignore * Upgrade XState to the latest 4.33.3 (#36451) * update to latest xstate * Use `pendingQueryRuns` available on the event (#36393) * Revert "Use `pendingQueryRuns` available on the event (#36393)" This reverts commit 9460dd3. Co-authored-by: tyhopp <[email protected]> Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Ty Hopp <[email protected]>
1 parent aca64b7 commit 3032a1b

File tree

8 files changed

+20
-9
lines changed

8 files changed

+20
-9
lines changed

packages/gatsby-source-filesystem/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"mime": "^2.5.2",
1717
"pretty-bytes": "^5.4.1",
1818
"valid-url": "^1.0.9",
19-
"xstate": "4.32.1"
19+
"xstate": "^4.34.0"
2020
},
2121
"devDependencies": {
2222
"@babel/cli": "^7.15.4",

packages/gatsby-source-filesystem/src/gatsby-node.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const chokidar = require(`chokidar`)
22
const fs = require(`fs`)
33
const path = require(`path`)
4-
const { Machine, interpret } = require(`xstate`)
4+
const { createMachine, interpret, assign } = require(`xstate`)
55

66
const { createFileNode } = require(`./create-file-node`)
77
const { ERROR_MAP } = require(`./error-utils`)
@@ -61,13 +61,17 @@ const createFSMachine = (
6161
}
6262

6363
const log = expr => (ctx, action, meta) => {
64-
if (meta.state.matches(`BOOTSTRAP.BOOTSTRAPPED`)) {
64+
if (ctx.bootstrapped) {
6565
reporter.info(expr(ctx, action, meta))
6666
}
6767
}
6868

69-
const fsMachine = Machine(
69+
const fsMachine = createMachine(
7070
{
71+
predictableActionArguments: true,
72+
context: {
73+
bootstrapped: false,
74+
},
7175
id: `fs`,
7276
type: `parallel`,
7377
states: {
@@ -81,6 +85,7 @@ const createFSMachine = (
8185
},
8286
BOOTSTRAPPED: {
8387
type: `final`,
88+
entry: assign({ bootstrapped: true }),
8489
},
8590
},
8691
},

packages/gatsby/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
"webpack-merge": "^5.8.0",
174174
"webpack-stats-plugin": "^1.0.3",
175175
"webpack-virtual-modules": "^0.3.2",
176-
"xstate": "4.32.1",
176+
"xstate": "^4.34.0",
177177
"yaml-loader": "^0.6.0"
178178
},
179179
"devDependencies": {

packages/gatsby/src/state-machines/data-layer/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const options: Partial<MachineOptions<IDataLayerContext, any>> = {
117117

118118
export const initializeDataMachine = createMachine(
119119
{
120+
predictableActionArguments: true,
120121
id: `initializeDataMachine`,
121122
context: {},
122123
initial: `customizingSchema`,
@@ -135,6 +136,7 @@ export const initializeDataMachine = createMachine(
135136

136137
export const reloadDataMachine = createMachine(
137138
{
139+
predictableActionArguments: true,
138140
id: `reloadDataMachine`,
139141
context: {},
140142
initial: `customizingSchema`,
@@ -153,6 +155,7 @@ export const reloadDataMachine = createMachine(
153155
*/
154156
export const recreatePagesMachine = createMachine(
155157
{
158+
predictableActionArguments: true,
156159
id: `recreatePagesMachine`,
157160
context: {},
158161
initial: `buildingSchema`,

packages/gatsby/src/state-machines/develop/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const getGraphqlTypegenConfig = (ctx: IBuildContext): boolean =>
2121
* This is the top-level state machine for the `gatsby develop` command
2222
*/
2323
const developConfig: MachineConfig<IBuildContext, any, AnyEventObject> = {
24+
predictableActionArguments: true,
2425
id: `build`,
2526
initial: `initializing`,
2627
// These are mutation events, sent to this machine by the mutation listener

packages/gatsby/src/state-machines/query-running/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { queryActions } from "./actions"
1010
const PAGE_QUERY_ENQUEUING_TIMEOUT = 50
1111

1212
export const queryStates: MachineConfig<IQueryRunningContext, any, any> = {
13+
predictableActionArguments: true,
1314
initial: `extractingQueries`,
1415
id: `queryRunningMachine`,
1516
on: {

packages/gatsby/src/state-machines/waiting/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type WaitingResult = Pick<IWaitingContext, "nodeMutationBatch">
1414
* mutations when we first start it
1515
*/
1616
export const waitingStates: MachineConfig<IWaitingContext, any, any> = {
17+
predictableActionArguments: true,
1718
id: `waitingMachine`,
1819
initial: `idle`,
1920
context: {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -24750,10 +24750,10 @@ xmlhttprequest-ssl@~1.5.4:
2475024750
version "1.5.5"
2475124751
resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e"
2475224752

24753-
xstate@4.32.1:
24754-
version "4.32.1"
24755-
resolved "https://registry.yarnpkg.com/xstate/-/xstate-4.32.1.tgz#1a09c808a66072938861a3b4acc5b38460244b70"
24756-
integrity sha512-QYUd+3GkXZ8i6qdixnOn28bL3EvA++LONYL/EMWwKlFSh/hiLndJ8YTnz77FDs+JUXcwU7NZJg7qoezoRHc4GQ==
24753+
xstate@^4.34.0:
24754+
version "4.34.0"
24755+
resolved "https://registry.yarnpkg.com/xstate/-/xstate-4.34.0.tgz#401901c478f0b2a7f07576c020b6e6f750b5bd10"
24756+
integrity sha512-MFnYz7cJrWuXSZ8IPkcCyLB1a2T3C71kzMeShXKmNaEjBR/JQebKZPHTtxHKZpymESaWO31rA3IQ30TC6LW+sw==
2475724757

2475824758
xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.0, xtend@~4.0.1:
2475924759
version "4.0.2"

0 commit comments

Comments
 (0)