Skip to content

Commit be8e841

Browse files
committed
[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.
1 parent 956d770 commit be8e841

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/apps/playground/components/Editor/EditorImpl.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
PrintedCompilerPipelineValue,
4545
} from './Output';
4646
import {transformFromAstSync} from '@babel/core';
47+
import {LoggerEvent} from 'babel-plugin-react-compiler/dist/Entrypoint';
4748

4849
function parseInput(
4950
input: string,
@@ -210,7 +211,11 @@ function compile(source: string): [CompilerOutput, 'flow' | 'typescript'] {
210211
},
211212
logger: {
212213
debugLogIRs: logIR,
213-
logEvent: () => {},
214+
logEvent: (_filename: string | null, event: LoggerEvent) => {
215+
if (event.kind === 'CompileError') {
216+
error.details.push(new CompilerErrorDetail(event.detail));
217+
}
218+
},
214219
},
215220
});
216221
transformOutput = invokeCompiler(source, language, opts);

0 commit comments

Comments
 (0)