question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging variables not working with sourcemaps + uglify

See original GitHub issue

I have the following gulp task for bundling javascript:

gulp.task('js', function () {
    return gulp.src(paths.js)
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(concat('bundle.min.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('dist'));
});

When I run this in the Chrome dev tools, sourcemaps are found and breakpoints work, but variables can’t be debugged.

Take this example chunk of angular code:

iarApp.config(['$animateProvider', function ($animateProvider) {
    $animateProvider.classNameFilter(/angular-animate/);
}]);

If I add a breakpoint to see the value of $animateProvider, I get the following:

enter image description here

But if I turn off variable mangling in Uglify:

.pipe(uglify({ mangle: false }))

Then it works:

enter image description here

So it seems that the gulp-sourcemaps plugin can’t follow up variables after Uglify mangles the names.

Can anyone else get the same issue and/or know a solution?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rafaelcamargocommented, Jan 26, 2017

@fernandoneira I have just tried your workaround { mangle: false } and works fine. Thanks man!

0reactions
phatedcommented, Mar 13, 2017

This is a sourcemap problem, not a gulp-sourcemaps issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging variables not working with gulp sourcemaps + uglify
When I run this in the Chrome dev tools, sourcemaps are found and breakpoints work, but variables can't be debugged. Take this example...
Read more >
Debugging variables not working with sourcemaps + uglify
I have the following gulp task for bundling javascript: gulp.task('js', function () { return gulp.src(paths.js) .pipe(sourcemaps.init()) .pipe(uglify()) ...
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
Here are four reasons why your source maps are broken and tips on how ... Debugging Minified JavaScript with Source Maps, before continuing....
Read more >
Javascript Debugging Made Easier with Sourcemaps
Sourcemaps bacically are a way to map the combined/minified file back to the original file.
Read more >
UglifyJS 3 - JavaScript on Fiber - FIBJS
uglify -js@3 has a simplified API and CLI that is not backwards compatible with ... `content` Input source map, useful if you're compressing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found