@@ -208,20 +208,12 @@ export async function executeBuild(
208
208
if ( options . budgets ) {
209
209
const compatStats = generateBudgetStats ( metafile , initialFiles ) ;
210
210
budgetFailures = [ ...checkBudgets ( options . budgets , compatStats , true ) ] ;
211
- if ( budgetFailures . length > 0 ) {
212
- const errors = budgetFailures
213
- . filter ( ( failure ) => failure . severity === 'error' )
214
- . map ( ( { message } ) => message ) ;
215
- const warnings = budgetFailures
216
- . filter ( ( failure ) => failure . severity !== 'error' )
217
- . map ( ( { message } ) => message ) ;
218
-
219
- await printWarningsAndErrorsToConsoleAndAddToResult (
220
- context ,
221
- executionResult ,
222
- warnings ,
223
- errors ,
224
- ) ;
211
+ for ( const { message, severity } of budgetFailures ) {
212
+ if ( severity === 'error' ) {
213
+ executionResult . addError ( message ) ;
214
+ } else {
215
+ executionResult . addWarning ( message ) ;
216
+ }
225
217
}
226
218
}
227
219
@@ -234,7 +226,7 @@ export async function executeBuild(
234
226
// Check metafile for CommonJS module usage if optimizing scripts
235
227
if ( optimizationOptions . scripts ) {
236
228
const messages = checkCommonJSModules ( metafile , options . allowedCommonJsDependencies ) ;
237
- await logMessages ( context , { warnings : messages } ) ;
229
+ executionResult . addWarnings ( messages ) ;
238
230
}
239
231
240
232
// Copy assets
@@ -255,12 +247,10 @@ export async function executeBuild(
255
247
256
248
// Perform i18n translation inlining if enabled
257
249
let prerenderedRoutes : string [ ] ;
258
- let errors : string [ ] ;
259
- let warnings : string [ ] ;
260
250
if ( i18nOptions . shouldInline ) {
261
251
const result = await inlineI18n ( options , executionResult , initialFiles ) ;
262
- errors = result . errors ;
263
- warnings = result . warnings ;
252
+ executionResult . addErrors ( result . errors ) ;
253
+ executionResult . addWarnings ( result . warnings ) ;
264
254
prerenderedRoutes = result . prerenderedRoutes ;
265
255
} else {
266
256
const result = await executePostBundleSteps (
@@ -272,15 +262,13 @@ export async function executeBuild(
272
262
i18nOptions . hasDefinedSourceLocale ? i18nOptions . sourceLocale : undefined ,
273
263
) ;
274
264
275
- errors = result . errors ;
276
- warnings = result . warnings ;
265
+ executionResult . addErrors ( result . errors ) ;
266
+ executionResult . addWarnings ( result . warnings ) ;
277
267
prerenderedRoutes = result . prerenderedRoutes ;
278
268
executionResult . outputFiles . push ( ...result . additionalOutputFiles ) ;
279
269
executionResult . assetFiles . push ( ...result . additionalAssets ) ;
280
270
}
281
271
282
- await printWarningsAndErrorsToConsoleAndAddToResult ( context , executionResult , warnings , errors ) ;
283
-
284
272
if ( prerenderOptions ) {
285
273
executionResult . addOutputFile (
286
274
'prerendered-routes.json' ,
@@ -307,6 +295,8 @@ export async function executeBuild(
307
295
estimatedTransferSizes ,
308
296
) ;
309
297
298
+ await logMessages ( context , executionResult ) ;
299
+
310
300
// Write metafile if stats option is enabled
311
301
if ( options . stats ) {
312
302
executionResult . addOutputFile (
@@ -318,20 +308,3 @@ export async function executeBuild(
318
308
319
309
return executionResult ;
320
310
}
321
-
322
- async function printWarningsAndErrorsToConsoleAndAddToResult (
323
- context : BuilderContext ,
324
- executionResult : ExecutionResult ,
325
- warnings : string [ ] ,
326
- errors : string [ ] ,
327
- ) : Promise < void > {
328
- const errorMessages = errors . map ( ( text ) => ( { text, location : null } ) ) ;
329
- if ( errorMessages . length ) {
330
- executionResult . addErrors ( errorMessages ) ;
331
- }
332
-
333
- await logMessages ( context , {
334
- errors : errorMessages ,
335
- warnings : warnings . map ( ( text ) => ( { text, location : null } ) ) ,
336
- } ) ;
337
- }
0 commit comments