File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -45,12 +45,21 @@ if (process.env.NODE_ENV === 'development') {
45
45
}
46
46
```
47
47
48
+ ### Source Map Support
49
+
50
+ Even though it is not desirable to run transpiled source code inside the
51
+ node js runtime, you often do not escape the use of it because of Server Side
52
+ Rendering applications. ` debug-error-middleware ` automatically supports sourcemaps.
53
+ This will result in stack traces that are easier to interpret. You can disable
54
+ source map support through a configuration option.
55
+
48
56
### Configuration
49
57
50
58
The following configuration options are available:
51
59
52
60
``` javascript
53
61
{
54
62
disabledForXHR: true // Disable the middleware for XHR requests
63
+ disableSourceMapSupport: false // Disables support for sourcemaps
55
64
}
56
65
```
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const defaultOptions = {
4
- disabledForXHR : true
4
+ disabledForXHR : true ,
5
+ disableSourceMapSupport : false ,
5
6
} ;
6
7
7
8
module . exports . express = function stack ( options ) {
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ function trimResult(input) {
58
58
return result ;
59
59
}
60
60
61
- function parseStack ( error ) {
61
+ function parseStack ( opts , error ) {
62
62
const stack = error . stack . split ( '\n' ) . slice ( 1 ) ;
63
63
const regex = / a t ( [ \w . ] + ) \( ( [ ^ : ] + ) : ( \d + ) : ( \d + ) \) / ;
64
64
@@ -89,7 +89,7 @@ function parseStack(error) {
89
89
}
90
90
return result ;
91
91
} )
92
- . then ( r => parseSourceMap ( r ) )
92
+ . then ( r => ( opts . disableSourceMapSupport ? r : parseSourceMap ( r ) ) )
93
93
. then ( r => trimResult ( r ) ) ;
94
94
} )
95
95
) ;
@@ -140,7 +140,7 @@ function getProcess() {
140
140
}
141
141
142
142
module . exports = function main ( opts , error , req ) {
143
- return Promise . all ( [ loadPrism ( ) , parseStack ( error ) ] ) . then ( args => {
143
+ return Promise . all ( [ loadPrism ( ) , parseStack ( opts , error ) ] ) . then ( args => {
144
144
const codemirror = args [ 0 ] ;
145
145
const stack = args [ 1 ] ;
146
146
// 3: Create config for Handlebars
You can’t perform that action at this time.
0 commit comments