Skip to content

Commit 27606c1

Browse files
committed
fix: Adapt to node's removal of the module header
As of version 11.11.0 (and backported to 10.16), node automatically strips the module closure header from the module source code. So, the fix for that caused off-by-one errors in the sourcemapped file. Set the headerLength to 0 when it is known to not be present.
1 parent 4a9c45d commit 27606c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source-map-support.js

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

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

0 commit comments

Comments
 (0)