terinjokes/gulp-uglify

GulpUglifyError: unable to minify JavaScript Caused by: SyntaxError when using let or const

Closed this issue · 4 comments

I am using the latest version 3.0.1 and gulp 4.0.
Why is the minimization of js files not performed if there is a let or const in the code?

code in js that cannot handle the plugin.

'use strict';

let slideItems    = document.querySelectorAll('.slides__item'),
    indContainer  = document.querySelector('.indicators'),
    indItems      = document.querySelectorAll('.indicators__item'),
    currentSlide  = 0;

const LEFT_ARROW  = 37,
      RIGHT_ARROW = 39,
      SPACE       = 32,
      FA_PAUSE    = '<i class="fas fa-pause"></i>',
      FA_PLAY     = '<i class="fas fa-play"></i>';

gulp 4 function for task (it works well with vars)

function minjs () {
  return src([path.js.files, '!' + path.js.filesMin])
    .pipe(uglify({
      toplevel: true,
    }))
    .pipe(rename({ suffix: '.min' }))
    .pipe(dest(path.js.folder)
      .on('end', () => { if(true) console.log('   ---------------   completed UGLIFY (.min.js)'); }));
}

Same issue

I use gulp-uglify-es instead of this module, everything is fine with es6.

You should be able to use this module by following the instructions in the README and using the maintained fork of UglifyJS: Terser.

uglify-es is no longer maintained and breaks scripts.