diff --git a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
index dc4f6b7f88f..55690a67cd5 100644
--- a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
+++ b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
@@ -179,6 +179,26 @@ const tests: CompilerTestCases = {
},
],
},
+ {
+ name: "Test experimental/unstable report all bailouts mode",
+ options: [
+ {
+ reportableLevels: new Set([ErrorSeverity.InvalidReact]),
+ __unstable_donotuse_reportAllBailouts: true,
+ },
+ ],
+ code: normalizeIndent`
+ function Foo(x) {
+ var y = 1;
+ return
{y * x}
;
+ }`,
+ errors: [
+ {
+ message:
+ "[ReactCompilerBailout] (BuildHIR::lowerStatement) Handle var kinds in VariableDeclaration (@:3:2)",
+ },
+ ],
+ },
],
};
diff --git a/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts b/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
index 5ab464eb001..a407748898b 100644
--- a/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
+++ b/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
@@ -129,6 +129,22 @@ const rule: Rule.RuleModule = {
} else {
reportableLevels = DEFAULT_REPORTABLE_LEVELS;
}
+ /**
+ * Experimental setting to report all compilation bailouts on the compilation
+ * unit (e.g. function or hook) instead of the offensive line.
+ * Intended to be used when a codebase is 100% reliant on the compiler for
+ * memoization (i.e. deleted all manual memo) and needs compilation success
+ * signals for perf debugging.
+ */
+ let __unstable_donotuse_reportAllBailouts: boolean = false;
+ if (
+ userOpts["__unstable_donotuse_reportAllBailouts"] != null &&
+ typeof userOpts["__unstable_donotuse_reportAllBailouts"] === "boolean"
+ ) {
+ __unstable_donotuse_reportAllBailouts =
+ userOpts["__unstable_donotuse_reportAllBailouts"];
+ }
+
const options: PluginOptions = {
...parsePluginOptions(userOpts),
...COMPILER_OPTIONS,
@@ -139,6 +155,19 @@ const rule: Rule.RuleModule = {
userLogger?.logEvent(filename, event);
if (event.kind === "CompileError") {
const detail = event.detail;
+ const suggest = makeSuggestions(detail);
+ if (__unstable_donotuse_reportAllBailouts && event.fnLoc != null) {
+ const locStr =
+ detail.loc != null && typeof detail.loc !== "symbol"
+ ? ` (@:${detail.loc.start.line}:${detail.loc.start.column})`
+ : "";
+ context.report({
+ message: `[ReactCompilerBailout] ${detail.reason}${locStr}`,
+ loc: event.fnLoc,
+ suggest,
+ });
+ }
+
if (!isReportableDiagnostic(detail)) {
return;
}
@@ -154,7 +183,7 @@ const rule: Rule.RuleModule = {
context.report({
message: detail.reason,
loc,
- suggest: makeSuggestions(detail),
+ suggest,
});
}
}