File tree Expand file tree Collapse file tree 4 files changed +6
-5
lines changed Expand file tree Collapse file tree 4 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export const build = async (
52
52
compiler . run ( ( err , stats ) => {
53
53
if ( err ) {
54
54
reject ( err ) ;
55
- } else if ( stats ?. hasErrors ( ) ) {
55
+ } else if ( context . buildState . hasErrors ) {
56
56
reject ( new Error ( 'webpack build failed.' ) ) ;
57
57
}
58
58
// If there is a compilation error, the close method should not be called.
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ function applyDefaultPlugins(
82
82
pluginTarget ( ) ,
83
83
pluginOutput ( ) ,
84
84
pluginResolve ( ) ,
85
- pluginFileSize ( ) ,
85
+ pluginFileSize ( context ) ,
86
86
// cleanOutput plugin should before the html plugin
87
87
pluginCleanOutput ( ) ,
88
88
pluginAsset ( ) ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { JS_REGEX } from '../constants';
10
10
import { color , getAssetsFromStats } from '../helpers' ;
11
11
import { logger } from '../logger' ;
12
12
import type {
13
+ InternalContext ,
13
14
PrintFileSizeAsset ,
14
15
PrintFileSizeOptions ,
15
16
RsbuildPlugin ,
@@ -284,13 +285,13 @@ async function printFileSizes(
284
285
return logs ;
285
286
}
286
287
287
- export const pluginFileSize = ( ) : RsbuildPlugin => ( {
288
+ export const pluginFileSize = ( context : InternalContext ) : RsbuildPlugin => ( {
288
289
name : 'rsbuild:file-size' ,
289
290
290
291
setup ( api ) {
291
292
api . onAfterBuild ( async ( { stats, environments, isFirstCompile } ) => {
292
293
// No need to print file sizes if there is any compilation error
293
- if ( ! stats || stats . hasErrors ( ) || ! isFirstCompile ) {
294
+ if ( ! stats || context . buildState . hasErrors || ! isFirstCompile ) {
294
295
return ;
295
296
}
296
297
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export const build = async (
70
70
71
71
if ( err ) {
72
72
reject ( err ) ;
73
- } else if ( stats ?. hasErrors ( ) ) {
73
+ } else if ( context . buildState . hasErrors ) {
74
74
reject ( new Error ( RSPACK_BUILD_ERROR ) ) ;
75
75
} else {
76
76
resolve ( { stats } ) ;
You can’t perform that action at this time.
0 commit comments