From 080d394c74678dee8a8415c2047487e9c20c84e8 Mon Sep 17 00:00:00 2001 From: Codebuff Contributor Date: Fri, 15 May 2026 06:09:48 +0600 Subject: [PATCH] Fix React Compiler leaking Symbol() into output AST loc fields babel-plugin-react-compiler uses a Symbol() sentinel (GeneratedSource) for synthesized nodes without source locations. In codegenPlace(), the sentinel was being directly assigned to the output Babel AST node's loc field via an unchecked cast. This violates Babel's Node.loc contract (SourceLocation | null) and causes v8.serialize() to throw when downstream tools try to serialize the compiled AST across worker/process boundaries. The fix adds a guard to only set loc when it is not GeneratedSource, matching the existing pattern used by withLoc() and createCallExpression() in the same file. --- .../src/ReactiveScopes/CodegenReactiveFunction.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts index 123a69afc21b..72b9d4947c77 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -2926,7 +2926,9 @@ function codegenPlace(cx: Context, place: Place): t.Expression | t.JSXText { suggestions: null, }); const identifier = convertIdentifier(place.identifier); - identifier.loc = place.loc as any; + if (place.loc != null && place.loc !== GeneratedSource) { + identifier.loc = place.loc as any; + } return identifier; }