From 2ba462b665bb4691067e67db3cfbffc56959b788 Mon Sep 17 00:00:00 2001 From: Mike Vitousek Date: Thu, 13 Jun 2024 11:02:47 -0700 Subject: [PATCH] [compiler][playground] Make change detection work in playground Summary: The change detection mode was unavailable in the playground because the pragma was not a boolean. This fixes that by special casing it in pragma parsing, similar to validateNoCapitalizedCalls ghstack-source-id: 4a8c17d21ab8b7936ca61c9dd1f7fdf8322614c9 Pull Request resolved: https://github.com/facebook/react/pull/29889 --- .../src/HIR/Environment.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts index 2a94eec79bdc0..499ce8de3db90 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts @@ -410,6 +410,17 @@ export function parseConfigPragma(pragma: string): EnvironmentConfig { continue; } + if ( + key === "enableChangeDetectionForDebugging" && + (val === undefined || val === "true") + ) { + maybeConfig[key] = { + source: "react-compiler-runtime", + importSpecifierName: "$structuralCheck", + }; + continue; + } + if (typeof defaultConfig[key as keyof EnvironmentConfig] !== "boolean") { // skip parsing non-boolean properties continue;