1

I'm trying to generate sourcemap files for uglified javascript with gulp. My task looks as follows:

gulp.task('scripts', ['clean'], function() {

  return gulp.src([ 'src/app/**/*.js' ])
    .pipe(sourcemaps.init())
    .pipe(concat('app.min.js'))
    .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dest/app'));

});

The output map generated by gulp-sourcemaps contains an empty names array, which prevents the browser to unmangle the function arguments back to its original names.

It seems to me that gulp-sourcemaps isn't merging the chained map files correctly? The gulp-concat does not output a names property (it doesn't needs to: it's simply concating) but gulp-uglify does:

gulp.task('scripts', ['clean'], function() {

  return gulp.src([ 'src/app/**/*.js' ])
    .pipe(sourcemaps.init())
//    .pipe(concat('app.min.js'))
    .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dest/app'));

});

The above does generates correct map files with the names property set.

Am I doing something wrong or does someone has a workaround for this?

null
  • 7,906
  • 3
  • 36
  • 37

1 Answers1

0

This seems to be a bug in Uglify2. Should be resolved by this simple fix:

https://github.com/mishoo/UglifyJS2/pull/546

barsju
  • 4,408
  • 1
  • 19
  • 24