lib: allow skipping source maps in node_modules

Files in `node_modules` are not authored by the user directly and the
original sources are less relevant to the user.

Skipping source maps in `node_modules` improves the general
performance. Add `module.setSourceMapsSupport(enabled, options)` to
skip source maps in `node_modules` if it is needed. This moves
all source maps related API to `node:module` and this a step to
promote the source maps API to stable.

PR-URL: https://github.com/nodejs/node/pull/56639
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Chengzhong Wu authored and Antoine du Hamel committed 2025-01-30 10:44:33 +01:00
1 parent f885496d9c
commit 2fb007fdce
24 files changed
+491 -48

No files matched your search

@@ -0,0 +1,3 @@
var functionA=function(){functionB()};function functionB(){functionC()}var functionC=function(){functionD()},functionD=function(){if(0<Math.random())throw Error("an error!");},thrower=functionA;try{functionA()}catch(a){throw a;};
//# sourceMappingURL=enclosing-call-site.js.map
@@ -0,0 +1,27 @@
const functionA = () => {
functionB()
}
function functionB() {
functionC()
}
const functionC = () => {
functionD()
}
const functionD = () => {
(function functionE () {
if (Math.random() > 0) {
throw new Error('an error!')
}
})()
}
const thrower = functionA
try {
thrower()
} catch (err) {
throw err
}
@@ -0,0 +1,8 @@
{
"version":3,
"file":"enclosing-call-site-min.js",
"lineCount":1,
"mappings":"AAAA,IAAMA,UAAYA,QAAA,EAAM,CACtBC,SAAA,EADsB,CAIxBA,SAASA,UAAS,EAAG,CACnBC,SAAA,EADmB,CAIrB,IAAMA,UAAYA,QAAA,EAAM,CACtBC,SAAA,EADsB,CAAxB,CAIMA,UAAYA,QAAA,EAAM,CAEpB,GAAoB,CAApB,CAAIC,IAAA,CAAKC,MAAL,EAAJ,CACE,KAAUC,MAAJ,CAAU,WAAV,CAAN,CAHkB,CAJxB,CAYMC,QAAUP,SAEhB,IAAI,CACFO,SAAA,EADE,CAEF,MAAOC,CAAP,CAAY,CACZ,KAAMA,EAAN,CADY;",
"sources":["enclosing-call-site.js"],
"names":["functionA","functionB","functionC","functionD","Math","random","Error","thrower","err"]
}