@@ -114,12 +114,6 @@ function retrieveSourceMap(source) {
114
114
}
115
115
116
116
function mapSourcePosition ( position ) {
117
- // Fix position in Node where some (internal) code is prepended.
118
- // See https://github.com/evanw/node-source-map-support/issues/36
119
- if ( ! isInBrowser ( ) && position . line === 1 ) {
120
- position . column -= 62
121
- }
122
-
123
117
var sourceMap = sourceMapCache [ position . source ] ;
124
118
if ( ! sourceMap ) {
125
119
// Call the (overrideable) retrieveSourceMap function to get the source map.
@@ -271,16 +265,25 @@ function cloneCallSite(frame) {
271
265
return object ;
272
266
}
273
267
274
- function wrapCallSite ( frame ) {
268
+ function wrapCallSite ( frame , fromModule ) {
275
269
// Most call sites will return the source file from getFileName(), but code
276
270
// passed to eval() ending in "//# sourceURL=..." will return the source file
277
271
// from getScriptNameOrSourceURL() instead
278
272
var source = frame . getFileName ( ) || frame . getScriptNameOrSourceURL ( ) ;
279
273
if ( source ) {
274
+ var line = frame . getLineNumber ( ) ;
275
+ var column = frame . getColumnNumber ( ) - 1 ;
276
+
277
+ // Fix position in Node where some (internal) code is prepended.
278
+ // See https://github.com/evanw/node-source-map-support/issues/36
279
+ if ( fromModule && line === 1 ) {
280
+ column -= 63 ;
281
+ }
282
+
280
283
var position = mapSourcePosition ( {
281
284
source : source ,
282
- line : frame . getLineNumber ( ) ,
283
- column : frame . getColumnNumber ( ) - 1
285
+ line : line ,
286
+ column : column
284
287
} ) ;
285
288
frame = cloneCallSite ( frame ) ;
286
289
frame . getFileName = function ( ) { return position . source ; } ;
@@ -310,8 +313,15 @@ function prepareStackTrace(error, stack) {
310
313
fileContentsCache = { } ;
311
314
sourceMapCache = { } ;
312
315
}
316
+
317
+ var fromModule =
318
+ ! isInBrowser ( ) &&
319
+ stack . length &&
320
+ stack [ stack . length - 1 ] . getFileName ( ) === 'module.js'
321
+ ;
322
+
313
323
return error + stack . map ( function ( frame ) {
314
- return '\n at ' + wrapCallSite ( frame ) ;
324
+ return '\n at ' + wrapCallSite ( frame , fromModule ) ;
315
325
} ) . join ( '' ) ;
316
326
}
317
327
0 commit comments