Skip to content

Commit

Permalink
fix(gatsby): fix partial hydration constraints (gatsbyjs#36468)
Browse files Browse the repository at this point in the history
* fix(gatsby): fix partial hydration constraints

* Update flags.ts

* Update flags.ts

* lint
  • Loading branch information
wardpeet authored Aug 29, 2022
1 parent 434ca56 commit 58eee35
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions packages/gatsby/src/utils/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,7 @@ const activeFlags: Array<IFlag> = [
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.`,
},
{
Expand All @@ -203,14 +196,7 @@ const activeFlags: Array<IFlag> = [
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.`,
},
{
Expand All @@ -234,10 +220,7 @@ const activeFlags: Array<IFlag> = [
testFitness: (): fitnessEnum => false,
requires: `As of [email protected] 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`,
Expand All @@ -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

0 comments on commit 58eee35

Please sign in to comment.