[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
Mike Vitousek committed
Jun 13, 2024 at 11:02 UTC
2ba462b665bb4691067e67db3cfbffc56959b788
1 file changed
+11
compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts
+11
@@ -410,6 +410,17 @@ export function parseConfigPragma(pragma: string): EnvironmentConfig {
410
continue;
411
}
412
413
+ if (
414
+ key === "enableChangeDetectionForDebugging" &&
415
+ (val === undefined || val === "true")
416
+ ) {
417
+ maybeConfig[key] = {
418
+ source: "react-compiler-runtime",
419
+ importSpecifierName: "$structuralCheck",
420
+ };
421
+ continue;
422
+ }
423
+
424
if (typeof defaultConfig[key as keyof EnvironmentConfig] !== "boolean") {
425
// skip parsing non-boolean properties
426
continue;