Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mangled names in debugger with source maps

The debugger in Chrome/Safari does not show unmangled variable names when using source maps generated with grunt-contrib-uglify. Source code is displayed and debugged correctly. I have verified that the source map contains the variable names. Is this a bug in uglify?

Original source:

// two

function two()
{
    var test = "test";

    console.log("this is a " + test);
}

Generated source:

function two(){var a="test";console.log("this is a "+a)}
//# sourceMappingURL=all.min.js.map

Source map:

{
    "version": 3,
    "file": "all.min.js",
    "sources": ["../src/two.js"],
    "names": ["two","test","console","log"],
    "mappings":";;AAEA,QAASA,OAEL,GAAIC,GAAO,MAEXC,SAAQC,IAAI,aAAeF",
    "sourceRoot":"../"
}
like image 704
Aparajita Avatar asked Feb 26 '15 06:02

Aparajita


People also ask

How are Sourcemaps loaded?

Source Maps are downloaded and attached to the browser when you open the developer tools. Until then the browser is not aware of the sourceMap. Once Devtools is attached the modal triggers and enables the sourceMapManager. The sourceMapManager manages the sourceMap in Chrome.

What is a source mapping URL?

A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.


1 Answers

As noted by @rd5, this is issue 327092 in Google Chrome, reported on 2013-12-09.

As of 2018-07-01, the issue is still unresolved.

like image 60
bignose Avatar answered Oct 04 '22 20:10

bignose