From 58eee35a46e48c578b9dac3a2408d54782a71029 Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Mon, 29 Aug 2022 12:16:24 +0200 Subject: [PATCH] fix(gatsby): fix partial hydration constraints (#36468) * fix(gatsby): fix partial hydration constraints * Update flags.ts * Update flags.ts * lint --- packages/gatsby/src/utils/flags.ts | 39 +++++++++++------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/gatsby/src/utils/flags.ts b/packages/gatsby/src/utils/flags.ts index 722758683d08d..d964332caf175 100644 --- a/packages/gatsby/src/utils/flags.ts +++ b/packages/gatsby/src/utils/flags.ts @@ -184,14 +184,7 @@ const activeFlags: Array = [ experimental: true, umbrellaIssue: `https://gatsby.dev/lmdb-feedback`, description: `Store nodes in a persistent embedded database (vs in-memory). Lowers peak memory usage. Requires Node v14.10 or above.`, - testFitness: (): fitnessEnum => { - if (_CFLAGS_.GATSBY_MAJOR === `4`) { - return `LOCKED_IN` - } - - const [major, minor] = process.versions.node.split(`.`) - return (Number(major) === 14 && Number(minor) >= 10) || Number(major) > 14 - }, + testFitness: (): fitnessEnum => `LOCKED_IN`, requires: `Requires Node v14.10 or above.`, }, { @@ -203,14 +196,7 @@ const activeFlags: Array = [ umbrellaIssue: `https://gatsby.dev/pqr-feedback`, description: `Parallelize running page queries in order to better saturate all available cores. Improves time it takes to run queries during gatsby build. Requires Node v14.10 or above.`, includedFlags: [`LMDB_STORE`], - testFitness: (): fitnessEnum => { - if (_CFLAGS_.GATSBY_MAJOR === `4`) { - return `LOCKED_IN` - } - - const [major, minor] = process.versions.node.split(`.`) - return (Number(major) === 14 && Number(minor) >= 10) || Number(major) > 14 - }, + testFitness: (): fitnessEnum => `LOCKED_IN`, requires: `Requires Node v14.10 or above.`, }, { @@ -234,10 +220,7 @@ 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`, @@ -250,13 +233,19 @@ if (_CFLAGS_.GATSBY_MAJOR === `5`) { react: `>=18.0.0`, } const v0Constraint = { - react: `0.0.0`, + react: `^0.0.0`, } - return satisfiesSemvers(v18Constraint) || satisfiesSemvers(v0Constraint) + return ( + _CFLAGS_.GATSBY_MAJOR === `5` && + (satisfiesSemvers(v18Constraint) || satisfiesSemvers(v0Constraint)) + ) }, - requires: `Requires React v18 or above.`, - }) -} + requires: + Number(_CFLAGS_.GATSBY_MAJOR) < 5 + ? `Partial hydration is only available in Gatsby V5. Please upgrade Gatsby.` + : `Partial hydration requires React 18+ to work.`, + }, +] export default activeFlags