Skip to content

Commit 3436da1

Browse files
privatenumberjuanarbol
authored andcommitted
util: preserve function names without source map names
Signed-off-by: Hiroki Osame <hiroki.osame@gmail.com> PR-URL: #65108 Fixes: #65104 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Signed-off-by: Juan JosΓ© Arboleda <soyjuanarbol@gmail.com>
1 parent 589a8d4 commit 3436da1

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

β€Žlib/util.jsβ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,7 @@ function reconstructCallSite(callSite) {
537537
if (!entry?.originalSource) return;
538538
return {
539539
__proto__: null,
540-
// If the name is not found, it is an empty string to match the behavior of `util.getCallSite()`
541-
functionName: entry.name ?? '',
540+
functionName: entry.name || callSite.functionName,
542541
scriptName: entry.originalSource,
543542
lineNumber: entry.originalLine + 1,
544543
column: entry.originalColumn + 1,

β€Žtest/fixtures/source-map/get-call-sites-function-name-mapped.jsβ€Ž

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": 3,
3+
"sources": ["get-call-sites-function-name-original.js"],
4+
"sourcesContent": ["const { getCallSites } = require('node:util'); function foo() { process.stdout.write(JSON.stringify(getCallSites({ sourceMap: true })[0])); } foo();"],
5+
"mappings": "AAAA,KAAM,CAAE,YAAa,EAAI,QAAQ,WAAW,EAAG,SAAS,KAAM,CAAE,QAAQ,OAAO,MAAM,KAAK,UAAU,aAAa,CAAE,UAAW,EAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAG,CAAE,IAAI",
6+
"names": []
7+
}

0 commit comments

Comments
Β (0)