@@ -129,6 +129,22 @@ const rule: Rule.RuleModule = {
129129 } else {
130130 reportableLevels = DEFAULT_REPORTABLE_LEVELS ;
131131 }
132+ /**
133+ * Experimental setting to report all compilation bailouts on the compilation
134+ * unit (e.g. function or hook) instead of the offensive line.
135+ * Intended to be used when a codebase is 100% reliant on the compiler for
136+ * memoization (i.e. deleted all manual memo) and needs compilation success
137+ * signals for perf debugging.
138+ */
139+ let __unstable_donotuse_reportAllBailouts : boolean = false ;
140+ if (
141+ userOpts [ "__unstable_donotuse_reportAllBailouts" ] != null &&
142+ typeof userOpts [ "__unstable_donotuse_reportAllBailouts" ] === "boolean"
143+ ) {
144+ __unstable_donotuse_reportAllBailouts =
145+ userOpts [ "__unstable_donotuse_reportAllBailouts" ] ;
146+ }
147+
132148 const options : PluginOptions = {
133149 ...parsePluginOptions ( userOpts ) ,
134150 ...COMPILER_OPTIONS ,
@@ -139,6 +155,19 @@ const rule: Rule.RuleModule = {
139155 userLogger ?. logEvent ( filename , event ) ;
140156 if ( event . kind === "CompileError" ) {
141157 const detail = event . detail ;
158+ const suggest = makeSuggestions ( detail ) ;
159+ if ( __unstable_donotuse_reportAllBailouts && event . fnLoc != null ) {
160+ const locStr =
161+ detail . loc != null && typeof detail . loc !== "symbol"
162+ ? ` (@:${ detail . loc . start . line } :${ detail . loc . start . column } )`
163+ : "" ;
164+ context . report ( {
165+ message : `[ReactCompilerBailout] ${ detail . reason } ${ locStr } ` ,
166+ loc : event . fnLoc ,
167+ suggest,
168+ } ) ;
169+ }
170+
142171 if ( ! isReportableDiagnostic ( detail ) ) {
143172 return ;
144173 }
@@ -154,7 +183,7 @@ const rule: Rule.RuleModule = {
154183 context . report ( {
155184 message : detail . reason ,
156185 loc,
157- suggest : makeSuggestions ( detail ) ,
186+ suggest,
158187 } ) ;
159188 }
160189 }
0 commit comments