Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): Use xstate predictableActionArguments & update to 4.34 #36342

Merged
merged 13 commits into from
Nov 17, 2022
Merged
2 changes: 1 addition & 1 deletion packages/gatsby-source-filesystem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"mime": "^2.5.2",
"pretty-bytes": "^5.4.1",
"valid-url": "^1.0.9",
"xstate": "4.32.1"
"xstate": "^4.34.0"
},
"devDependencies": {
"@babel/cli": "^7.15.4",
Expand Down
11 changes: 8 additions & 3 deletions packages/gatsby-source-filesystem/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const chokidar = require(`chokidar`)
const fs = require(`fs`)
const path = require(`path`)
const { Machine, interpret } = require(`xstate`)
const { createMachine, interpret, assign } = require(`xstate`)

const { createFileNode } = require(`./create-file-node`)
const { ERROR_MAP } = require(`./error-utils`)
Expand Down Expand Up @@ -61,13 +61,17 @@ const createFSMachine = (
}

const log = expr => (ctx, action, meta) => {
if (meta.state.matches(`BOOTSTRAP.BOOTSTRAPPED`)) {
if (ctx.bootstrapped) {
reporter.info(expr(ctx, action, meta))
}
}

const fsMachine = Machine(
const fsMachine = createMachine(
{
predictableActionArguments: true,
context: {
bootstrapped: false,
},
id: `fs`,
type: `parallel`,
states: {
Expand All @@ -81,6 +85,7 @@ const createFSMachine = (
},
BOOTSTRAPPED: {
type: `final`,
entry: assign({ bootstrapped: true }),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"webpack-merge": "^5.8.0",
"webpack-stats-plugin": "^1.0.3",
"webpack-virtual-modules": "^0.3.2",
"xstate": "4.32.1",
"xstate": "^4.34.0",
"yaml-loader": "^0.6.0"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby/src/state-machines/data-layer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const options: Partial<MachineOptions<IDataLayerContext, any>> = {

export const initializeDataMachine = createMachine(
{
predictableActionArguments: true,
id: `initializeDataMachine`,
context: {},
initial: `customizingSchema`,
Expand All @@ -135,6 +136,7 @@ export const initializeDataMachine = createMachine(

export const reloadDataMachine = createMachine(
{
predictableActionArguments: true,
id: `reloadDataMachine`,
context: {},
initial: `customizingSchema`,
Expand All @@ -153,6 +155,7 @@ export const reloadDataMachine = createMachine(
*/
export const recreatePagesMachine = createMachine(
{
predictableActionArguments: true,
id: `recreatePagesMachine`,
context: {},
initial: `buildingSchema`,
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/state-machines/develop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const getGraphqlTypegenConfig = (ctx: IBuildContext): boolean =>
* This is the top-level state machine for the `gatsby develop` command
*/
const developConfig: MachineConfig<IBuildContext, any, AnyEventObject> = {
predictableActionArguments: true,
id: `build`,
initial: `initializing`,
// These are mutation events, sent to this machine by the mutation listener
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/state-machines/query-running/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { queryActions } from "./actions"
const PAGE_QUERY_ENQUEUING_TIMEOUT = 50

export const queryStates: MachineConfig<IQueryRunningContext, any, any> = {
predictableActionArguments: true,
initial: `extractingQueries`,
id: `queryRunningMachine`,
on: {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/state-machines/waiting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type WaitingResult = Pick<IWaitingContext, "nodeMutationBatch">
* mutations when we first start it
*/
export const waitingStates: MachineConfig<IWaitingContext, any, any> = {
predictableActionArguments: true,
id: `waitingMachine`,
initial: `idle`,
context: {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24750,10 +24750,10 @@ xmlhttprequest-ssl@~1.5.4:
version "1.5.5"
resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e"

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

xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.0, xtend@~4.0.1:
version "4.0.2"
Expand Down