@@ -129,6 +129,22 @@ const rule: Rule.RuleModule = {
129
129
} else {
130
130
reportableLevels = DEFAULT_REPORTABLE_LEVELS ;
131
131
}
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
+
132
148
const options : PluginOptions = {
133
149
...parsePluginOptions ( userOpts ) ,
134
150
...COMPILER_OPTIONS ,
@@ -139,6 +155,19 @@ const rule: Rule.RuleModule = {
139
155
userLogger ?. logEvent ( filename , event ) ;
140
156
if ( event . kind === "CompileError" ) {
141
157
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
+
142
171
if ( ! isReportableDiagnostic ( detail ) ) {
143
172
return ;
144
173
}
@@ -154,7 +183,7 @@ const rule: Rule.RuleModule = {
154
183
context . report ( {
155
184
message : detail . reason ,
156
185
loc,
157
- suggest : makeSuggestions ( detail ) ,
186
+ suggest,
158
187
} ) ;
159
188
}
160
189
}
0 commit comments