Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div>{y * x}</div>;
}`,
errors: [
{
message:
"[ReactCompilerBailout] (BuildHIR::lowerStatement) Handle var kinds in VariableDeclaration (@:3:2)",
},
],
},
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand All @@ -154,7 +183,7 @@ const rule: Rule.RuleModule = {
context.report({
message: detail.reason,
loc,
suggest: makeSuggestions(detail),
suggest,
});
}
}
Expand Down