Skip to content

Commit a64d497

Browse files
authored
Merge pull request #255 from tapjs/node-header-length-change
fix: Adapt to node's removal of the module header
2 parents 8cb9300 + b2e96dd commit a64d497

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

source-map-support.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ function wrapCallSite(frame, state) {
355355

356356
// Fix position in Node where some (internal) code is prepended.
357357
// See https://github.com/evanw/node-source-map-support/issues/36
358-
var headerLength = 62;
358+
// Header removed in node at ^10.16 || >=11.11.0
359+
// v11 is not an LTS candidate, we can just test the one version with it.
360+
// Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
361+
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)/;
362+
var headerLength = noHeader.test(process.version) ? 0 : 62;
359363
if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) {
360364
column -= headerLength;
361365
}

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ it('function constructor', function() {
269269
compareStackTrace(createMultiLineSourceMap(), [
270270
'throw new Function(")");'
271271
], [
272-
'SyntaxError: Unexpected token )',
272+
/SyntaxError: Unexpected token '?\)'?/,
273273
]);
274274
});
275275

0 commit comments

Comments
 (0)