From be8e8417e0d39dfbf282d309769c697f4a98d643 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Tue, 8 Jul 2025 17:08:22 -0700 Subject: [PATCH] [compiler] Show logged errors in playground In playground it's helpful to show all errors, even those that don't completely abort compilation. For example, to help demonstrate that the compiler catches things like setState in effects. This detects these errors and ensures we show them. --- compiler/apps/playground/components/Editor/EditorImpl.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/apps/playground/components/Editor/EditorImpl.tsx b/compiler/apps/playground/components/Editor/EditorImpl.tsx index 39571fa092..45490088fe 100644 --- a/compiler/apps/playground/components/Editor/EditorImpl.tsx +++ b/compiler/apps/playground/components/Editor/EditorImpl.tsx @@ -44,6 +44,7 @@ import { PrintedCompilerPipelineValue, } from './Output'; import {transformFromAstSync} from '@babel/core'; +import {LoggerEvent} from 'babel-plugin-react-compiler/dist/Entrypoint'; function parseInput( input: string, @@ -210,7 +211,11 @@ function compile(source: string): [CompilerOutput, 'flow' | 'typescript'] { }, logger: { debugLogIRs: logIR, - logEvent: () => {}, + logEvent: (_filename: string | null, event: LoggerEvent) => { + if (event.kind === 'CompileError') { + error.details.push(new CompilerErrorDetail(event.detail)); + } + }, }, }); transformOutput = invokeCompiler(source, language, opts);