Skip to content

Commit

Permalink
Merge pull request #255 from tapjs/node-header-length-change
Browse files Browse the repository at this point in the history
fix: Adapt to node's removal of the module header
  • Loading branch information
LinusU authored Oct 28, 2019
2 parents 8cb9300 + b2e96dd commit a64d497
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion source-map-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ function wrapCallSite(frame, state) {

// Fix position in Node where some (internal) code is prepended.
// See https://github.com/evanw/node-source-map-support/issues/36
var headerLength = 62;
// Header removed in node at ^10.16 || >=11.11.0
// v11 is not an LTS candidate, we can just test the one version with it.
// Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
var noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
var headerLength = noHeader.test(process.version) ? 0 : 62;
if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) {
column -= headerLength;
}
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ it('function constructor', function() {
compareStackTrace(createMultiLineSourceMap(), [
'throw new Function(")");'
], [
'SyntaxError: Unexpected token )',
/SyntaxError: Unexpected token '?\)'?/,
]);
});

Expand Down

1 comment on commit a64d497

@SanderDeWaal1992
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit gave me a problem in Chrome, I created an issue for this: #262.

Please sign in to comment.