From b55fc7a5ca647c415986904315319afee32a979b Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Mon, 23 Jun 2025 16:01:34 +0200 Subject: [PATCH] log if a compiler error was opted out of --- .../babel-plugin-react-compiler/src/Entrypoint/Options.ts | 1 + .../babel-plugin-react-compiler/src/Entrypoint/Program.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts index 0c23ceb345296..87305333e3e78 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts @@ -225,6 +225,7 @@ export type CompileErrorEvent = { kind: 'CompileError'; fnLoc: t.SourceLocation | null; detail: CompilerErrorDetailOptions; + optedOut?: boolean; }; export type CompileDiagnosticEvent = { kind: 'CompileDiagnostic'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts index de8d16fb12a6e..d79fdf9f1a608 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts @@ -174,6 +174,7 @@ function logError( filename: string | null; }, fnLoc: t.SourceLocation | null, + optedOut: boolean, ): void { if (context.opts.logger) { if (err instanceof CompilerError) { @@ -182,6 +183,7 @@ function logError( kind: 'CompileError', fnLoc, detail: detail.options, + optedOut, }); } } else { @@ -208,7 +210,7 @@ function handleError( }, fnLoc: t.SourceLocation | null, ): void { - logError(err, context, fnLoc); + logError(err, context, fnLoc, false); if ( context.opts.panicThreshold === 'all_errors' || (context.opts.panicThreshold === 'critical_errors' && @@ -592,7 +594,7 @@ function processFn( const compileResult = tryCompileFunction(fn, fnType, programContext); if (compileResult.kind === 'error') { if (directives.optOut != null) { - logError(compileResult.error, programContext, fn.node.loc ?? null); + logError(compileResult.error, programContext, fn.node.loc ?? null, true); } else { handleError(compileResult.error, programContext, fn.node.loc ?? null); }