Repository navigation
--enable-source-maps does not appear to show function names with webpack sourcemaps #35325
Description
Activity
- addedsource mapsIssues and PRs related to source map support.Issues and PRs related to source map support.
on Sep 26, 2020 @michael-wolfenden I'm wondering if you have any recommendations on how we should display the original function name?
The approach we've taken is to provide information about bot the call site with the error and the original call site, I'm wondering how we'd represent an alternate function name.
@michael-wolfenden what do you think of this?
Error: oh no! at o (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:970) -> [functionA] webpack:///./webpack.js:14:9 at n (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:952) -> [functionB] webpack:///./webpack.js:10:3I would expect the output to look something like the output that
source-map-supportgenerates> node ./dist/main.js D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:16 throw new Error('Roh Ruh') ^ Error: Roh Ruh at functionD (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:16:9) at functionC (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:12:3) at functionB (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:8:3) at Object.call (D:\github\node-sourcemap-repro\dist\webpack:\index-source-map-support.js:4:3) at __webpack_require__ (D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:19:22) at D:\github\node-sourcemap-repro\dist\webpack:\webpack\bootstrap:83:10 at Object.<anonymous> (D:\github\node-sourcemap-repro\dist\main.js:1:911) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32)@michael-wolfenden we've opted to include both the call site where the error happened, and the original call site in our implementation of applying source maps to stack traces in Node.js.
This is useful because sometimes you do want to look at the actual location where the error was thrown, i.e.,
at o (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:970)☝️ especially when using a minifier there can be bugs that only crop up in the minified code, e.g., a collision on symbol names.
I'd like to figure out a way to provide the original function name for you, without hiding the actual function name that executed.
- added a commit that references this issue
on Oct 31, 2020 Ah gotcha ... In that case, your suggestion looks good 👍
Reacted by Benjamin E. Coe- added a commit that references this issue
on Nov 3, 2020 - added a commit that references this issue
on Nov 27, 2020 - added a commit that references this issue
on Dec 7, 2020 - added 2 commits that reference this issue
on Apr 24, 2021 - added a commit that references this issue
on May 16, 2021 - added a commit that references this issue
on Jun 11, 2021 - added a commit that references this issue
on May 22, 2026
What steps will reproduce the bug?
Here is a complete, minimal reproduction
https://github.com/michael-wolfenden/node-sourcemap-repro
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
I would expect to see the real function names in the output.
Using the
source-map-supportpackage, the stack trace looks like:What do you see instead?
Using the
--enable-source-mapsflag, the stack trace looks like: