Skip to content

Commit f7a5744

Browse files
committed
Updated readme + extra config option
1 parent 263df48 commit f7a5744

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,21 @@ if (process.env.NODE_ENV === 'development') {
4545
}
4646
```
4747

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+
4856
### Configuration
4957

5058
The following configuration options are available:
5159

5260
```javascript
5361
{
5462
disabledForXHR: true // Disable the middleware for XHR requests
63+
disableSourceMapSupport: false // Disables support for sourcemaps
5564
}
5665
```

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

33
const defaultOptions = {
4-
disabledForXHR: true
4+
disabledForXHR: true,
5+
disableSourceMapSupport: false,
56
};
67

78
module.exports.express = function stack(options) {

src/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function trimResult(input) {
5858
return result;
5959
}
6060

61-
function parseStack(error) {
61+
function parseStack(opts, error) {
6262
const stack = error.stack.split('\n').slice(1);
6363
const regex = /at ([\w.]+) \(([^:]+):(\d+):(\d+)\)/;
6464

@@ -89,7 +89,7 @@ function parseStack(error) {
8989
}
9090
return result;
9191
})
92-
.then(r => parseSourceMap(r))
92+
.then(r => (opts.disableSourceMapSupport ? r : parseSourceMap(r)))
9393
.then(r => trimResult(r));
9494
})
9595
);
@@ -140,7 +140,7 @@ function getProcess() {
140140
}
141141

142142
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 => {
144144
const codemirror = args[0];
145145
const stack = args[1];
146146
// 3: Create config for Handlebars

0 commit comments

Comments
 (0)