From 41de1f0a8d767174f16367c14dbe8ed2820f8b2c Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Thu, 25 Aug 2022 10:34:32 +0100 Subject: [PATCH] feat(gatsby): add partial hydration flag (#36436) * add partial hydration flag * delete pkjson update * adjust flag * dry constraint check * Update packages/gatsby/src/utils/flags.ts Co-authored-by: Ward Peeters --- packages/gatsby/src/utils/flags.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/gatsby/src/utils/flags.ts b/packages/gatsby/src/utils/flags.ts index 7ac11b99fb762..722758683d08d 100644 --- a/packages/gatsby/src/utils/flags.ts +++ b/packages/gatsby/src/utils/flags.ts @@ -236,4 +236,27 @@ const activeFlags: Array = [ }, ] +if (_CFLAGS_.GATSBY_MAJOR === `5`) { + activeFlags.push({ + name: `PARTIAL_HYDRATION`, + env: `GATSBY_PARTIAL_HYDRATION`, + command: `build`, + telemetryId: `PartialHydration`, + 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 => { + const v18Constraint = { + react: `>=18.0.0`, + } + const v0Constraint = { + react: `0.0.0`, + } + + return satisfiesSemvers(v18Constraint) || satisfiesSemvers(v0Constraint) + }, + requires: `Requires React v18 or above.`, + }) +} + export default activeFlags