File tree Expand file tree Collapse file tree 8 files changed +42
-17
lines changed
cases/diagnostic/disable-stats-errors Expand file tree Collapse file tree 8 files changed +42
-17
lines changed Original file line number Diff line number Diff line change
1
+ import { rspackTest } from '@e2e/helper' ;
2
+
3
+ const EXPECTED_LOG = `Build failed. No errors reported since Rspack's "stats.errors" is disabled.` ;
4
+
5
+ rspackTest (
6
+ 'should print a hint if stats.errors is disabled after a dev failure' ,
7
+ async ( { dev } ) => {
8
+ const rsbuild = await dev ( ) ;
9
+ await rsbuild . expectLog ( EXPECTED_LOG ) ;
10
+ } ,
11
+ ) ;
12
+
13
+ rspackTest (
14
+ 'should print a hint if stats.errors is disabled after a build failure' ,
15
+ async ( { build } ) => {
16
+ const rsbuild = await build ( {
17
+ catchBuildError : true ,
18
+ } ) ;
19
+ await rsbuild . expectLog ( EXPECTED_LOG ) ;
20
+ } ,
21
+ ) ;
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from '@rsbuild/core' ;
2
+
3
+ export default defineConfig ( {
4
+ tools : {
5
+ rspack : {
6
+ stats : {
7
+ errors : false ,
8
+ } ,
9
+ } ,
10
+ } ,
11
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import './non-existent-file.js' ;
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ import {
19
19
import { type ExtendedLogHelper , proxyConsole } from './logs' ;
20
20
21
21
function makeBox ( title : string ) {
22
- const header = `╭────────────── Logs from: "${ title } " ── ────────────╮` ;
23
- const footer = `╰────────────── Logs from: "${ title } " ── ────────────╯` ;
22
+ const header = `╭──────────── Logs from: "${ title } " ────────────╮` ;
23
+ const footer = `╰──────────── Logs from: "${ title } " ────────────╯` ;
24
24
return {
25
25
header : `\n${ header } \n` ,
26
26
footer : `${ footer } \n` ,
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export async function createCompiler(options: InitConfigsOptions) {
42
42
compiler ,
43
43
context . action ,
44
44
) ;
45
- const hasErrors = helpers . getStatsErrors ( stats ) . length > 0 ;
45
+ const hasErrors = statsInstance . hasErrors ( ) ;
46
46
47
47
context . buildState . stats = stats ;
48
48
context . buildState . status = 'done' ;
Original file line number Diff line number Diff line change @@ -5,16 +5,14 @@ import { isMultiCompiler } from './';
5
5
import { formatStatsError } from './format' ;
6
6
7
7
function formatErrorMessage ( errors : string [ ] ) {
8
- const title = color . bold (
9
- color . red ( errors . length > 1 ? 'Build errors: ' : 'Build error: ' ) ,
10
- ) ;
11
-
12
8
if ( ! errors . length ) {
13
- return `${ title } \n ${ color . yellow ( `For more details, please set ' stats.errors: true' ` ) } ` ;
9
+ return `Build failed. No errors reported since Rspack's " stats.errors" is disabled. ` ;
14
10
}
15
11
12
+ const title = color . bold (
13
+ color . red ( errors . length > 1 ? 'Build errors: ' : 'Build error: ' ) ,
14
+ ) ;
16
15
const text = `${ errors . join ( '\n\n' ) } \n` ;
17
-
18
16
return `${ title } \n${ text } ` ;
19
17
}
20
18
Original file line number Diff line number Diff line change 3
3
color ,
4
4
formatStats ,
5
5
getRsbuildStats ,
6
- getStatsErrors ,
7
6
isSatisfyRspackVersion ,
8
7
prettyTime ,
9
8
rspackMinVersion ,
@@ -187,7 +186,7 @@ export async function createCompiler(options: InitConfigsOptions): Promise<{
187
186
HOOK_NAME ,
188
187
( statsInstance : Rspack . Stats | Rspack . MultiStats ) => {
189
188
const stats = getRsbuildStats ( statsInstance , compiler , context . action ) ;
190
- const hasErrors = getStatsErrors ( stats ) . length > 0 ;
189
+ const hasErrors = statsInstance . hasErrors ( ) ;
191
190
192
191
context . buildState . stats = stats ;
193
192
context . buildState . status = 'done' ;
Original file line number Diff line number Diff line change 3
3
*/
4
4
5
5
export { modifyBundlerChain } from '../configChain' ;
6
- export {
7
- formatStats ,
8
- getRsbuildStats ,
9
- getStatsErrors ,
10
- prettyTime ,
11
- } from '../helpers' ;
6
+ export { formatStats , getRsbuildStats , prettyTime } from '../helpers' ;
12
7
export { registerBuildHook , registerDevHook } from '../hooks' ;
13
8
export { inspectConfig } from '../inspectConfig' ;
14
9
export {
You can’t perform that action at this time.
0 commit comments