From 2ba3c7b2f6ab84f7fc4cd3cd83efb4083394f9d1 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Mon, 22 Aug 2022 11:06:14 +0100 Subject: [PATCH 1/5] add partial hydration flag --- package.json | 1 + packages/gatsby/src/utils/flags.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/package.json b/package.json index 760ff477fef82..b327bba801b0e 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ }, "private": true, "scripts": { + "hh": "cross-env COMPILER_OPTIONS=\"GATSBY_MAJOR=5\" npm-run-all -s check-versions \"lerna-prepare -- --{@}\" --", "bootstrap": "cross-env COMPILER_OPTIONS=\"GATSBY_MAJOR=4\" npm-run-all -s check-versions \"lerna-prepare -- --{@}\" --", "check-repo-fields": "node scripts/check-repo-fields.js", "check-versions": "node scripts/check-versions.js", diff --git a/packages/gatsby/src/utils/flags.ts b/packages/gatsby/src/utils/flags.ts index 7ac11b99fb762..206f20d1d3ce4 100644 --- a/packages/gatsby/src/utils/flags.ts +++ b/packages/gatsby/src/utils/flags.ts @@ -234,6 +234,28 @@ const activeFlags: Array = [ testFitness: (): fitnessEnum => false, requires: `As of gatsby@4.15.0 this feature is available as a config option inside gatsby-config. Learn more at https://gatsby.dev/graphql-typegen`, }, + { + name: `PARTIAL_HYDRATION`, + env: `GATSBY_PARTIAL_HYDRATION`, + command: `build`, + telemetryId: `PartialHydration`, + description: `TBD`, + umbrellaIssue: `TBD`, + experimental: true, + noCI: true, + testFitness: (): fitnessEnum => { + if (_CFLAGS_.GATSBY_MAJOR === `5`) { + return `LOCKED_IN` + } + + const isReact18 = + semver.major(require(`react-dom/package.json`).version) >= 18 || + String(semver.major(require(`react-dom/package.json`).version)) === `0` + + return isReact18 + }, + requires: `As of gatsby@4.TDB.0 this feature is available as a config option inside gatsby-config. Learn more at https://gatsby.dev/graphql-typegen`, + }, ] export default activeFlags From ae0ee38d66970f8a91fb5cafb1f2f7edbb67633b Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Mon, 22 Aug 2022 11:13:39 +0100 Subject: [PATCH 2/5] delete pkjson update --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index b327bba801b0e..760ff477fef82 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,6 @@ }, "private": true, "scripts": { - "hh": "cross-env COMPILER_OPTIONS=\"GATSBY_MAJOR=5\" npm-run-all -s check-versions \"lerna-prepare -- --{@}\" --", "bootstrap": "cross-env COMPILER_OPTIONS=\"GATSBY_MAJOR=4\" npm-run-all -s check-versions \"lerna-prepare -- --{@}\" --", "check-repo-fields": "node scripts/check-repo-fields.js", "check-versions": "node scripts/check-versions.js", From f096a91ebaad97f04748bd143e486ae37ecb7923 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 23 Aug 2022 10:20:00 +0100 Subject: [PATCH 3/5] adjust flag --- packages/gatsby/src/utils/flags.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/gatsby/src/utils/flags.ts b/packages/gatsby/src/utils/flags.ts index 206f20d1d3ce4..be0b5c9fc2abe 100644 --- a/packages/gatsby/src/utils/flags.ts +++ b/packages/gatsby/src/utils/flags.ts @@ -234,28 +234,26 @@ const activeFlags: Array = [ testFitness: (): fitnessEnum => false, requires: `As of gatsby@4.15.0 this feature is available as a config option inside gatsby-config. Learn more at https://gatsby.dev/graphql-typegen`, }, - { +] + +if (_CFLAGS_.GATSBY_MAJOR === `5`) { + activeFlags.push({ name: `PARTIAL_HYDRATION`, env: `GATSBY_PARTIAL_HYDRATION`, command: `build`, telemetryId: `PartialHydration`, description: `TBD`, - umbrellaIssue: `TBD`, + umbrellaIssue: `https://gatsby.dev/partial-hydration-umbrella-issue`, experimental: true, - noCI: true, testFitness: (): fitnessEnum => { - if (_CFLAGS_.GATSBY_MAJOR === `5`) { - return `LOCKED_IN` - } - const isReact18 = semver.major(require(`react-dom/package.json`).version) >= 18 || String(semver.major(require(`react-dom/package.json`).version)) === `0` return isReact18 }, - requires: `As of gatsby@4.TDB.0 this feature is available as a config option inside gatsby-config. Learn more at https://gatsby.dev/graphql-typegen`, - }, -] + requires: `Requires React v18 or above.`, + }) +} export default activeFlags From ac74adeb2dc4683a6a15af6ad2400d2dcc3fd049 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 23 Aug 2022 10:27:36 +0100 Subject: [PATCH 4/5] dry constraint check --- packages/gatsby/src/utils/flags.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/gatsby/src/utils/flags.ts b/packages/gatsby/src/utils/flags.ts index be0b5c9fc2abe..19b23b3462bf5 100644 --- a/packages/gatsby/src/utils/flags.ts +++ b/packages/gatsby/src/utils/flags.ts @@ -246,11 +246,14 @@ if (_CFLAGS_.GATSBY_MAJOR === `5`) { umbrellaIssue: `https://gatsby.dev/partial-hydration-umbrella-issue`, experimental: true, testFitness: (): fitnessEnum => { - const isReact18 = - semver.major(require(`react-dom/package.json`).version) >= 18 || - String(semver.major(require(`react-dom/package.json`).version)) === `0` + const v18Constraint = { + react: `>=18.0.0`, + } + const v0Constraint = { + react: `0.0.0`, + } - return isReact18 + return satisfiesSemvers(v18Constraint) || satisfiesSemvers(v0Constraint) }, requires: `Requires React v18 or above.`, }) From 8515d66c9fa36fdb0eafdee5a33091f261cdfb09 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 23 Aug 2022 16:42:26 +0100 Subject: [PATCH 5/5] Update packages/gatsby/src/utils/flags.ts Co-authored-by: Ward Peeters --- packages/gatsby/src/utils/flags.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/flags.ts b/packages/gatsby/src/utils/flags.ts index 19b23b3462bf5..722758683d08d 100644 --- a/packages/gatsby/src/utils/flags.ts +++ b/packages/gatsby/src/utils/flags.ts @@ -242,7 +242,7 @@ if (_CFLAGS_.GATSBY_MAJOR === `5`) { env: `GATSBY_PARTIAL_HYDRATION`, command: `build`, telemetryId: `PartialHydration`, - description: `TBD`, + description: `Enable partial hydration to reduce Total Blocking Time and Time To Interactive `, umbrellaIssue: `https://gatsby.dev/partial-hydration-umbrella-issue`, experimental: true, testFitness: (): fitnessEnum => {