File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -54,20 +54,22 @@ export let router
54
54
export let ErrorComponent
55
55
let ErrorDebugComponent
56
56
let Component
57
+ let stripAnsi = ( s ) => s
57
58
58
- export default async ( { ErrorDebugComponent : passedDebugComponent } = { } ) => {
59
+ export default async ( { ErrorDebugComponent : passedDebugComponent , stripAnsi : passedStripAnsi } = { } ) => {
59
60
// Wait for all the dynamic chunks to get loaded
60
61
for ( const chunkName of chunks ) {
61
62
await pageLoader . waitForChunk ( chunkName )
62
63
}
63
64
65
+ stripAnsi = passedStripAnsi || stripAnsi
64
66
ErrorDebugComponent = passedDebugComponent
65
67
ErrorComponent = await pageLoader . loadPage ( '/_error' )
66
68
67
69
try {
68
70
Component = await pageLoader . loadPage ( pathname )
69
71
} catch ( err ) {
70
- console . error ( `${ err . message } \n${ err . stack } ` )
72
+ console . error ( stripAnsi ( `${ err . message } \n${ err . stack } ` ) )
71
73
Component = ErrorComponent
72
74
}
73
75
@@ -119,7 +121,7 @@ export async function renderError (error) {
119
121
ReactDOM . unmountComponentAtNode ( appContainer )
120
122
121
123
const errorMessage = `${ error . message } \n${ error . stack } `
122
- console . error ( errorMessage )
124
+ console . error ( stripAnsi ( errorMessage ) )
123
125
124
126
if ( prod ) {
125
127
const initProps = { err : error , pathname, query, asPath }
Original file line number Diff line number Diff line change 1
1
import 'react-hot-loader/patch'
2
+ import stripAnsi from 'strip-ansi'
2
3
import initNext , * as next from './'
3
4
import ErrorDebugComponent from '../lib/error-debug'
4
5
import initOnDemandEntries from './on-demand-entries-client'
5
6
import initWebpackHMR from './webpack-hot-middleware-client'
6
7
7
8
window . next = next
8
9
9
- initNext ( { ErrorDebugComponent } )
10
+ initNext ( { ErrorDebugComponent, stripAnsi } )
10
11
. then ( ( emitter ) => {
11
12
initOnDemandEntries ( )
12
13
initWebpackHMR ( )
@@ -34,5 +35,5 @@ initNext({ ErrorDebugComponent })
34
35
} )
35
36
} )
36
37
. catch ( ( err ) => {
37
- console . error ( `${ err . message } \n${ err . stack } ` )
38
+ console . error ( stripAnsi ( `${ err . message } \n${ err . stack } ` ) )
38
39
} )
You can’t perform that action at this time.
0 commit comments