Minify es2017 with gulp
Hey guys i am currently using uglify-gulp with babel to minify my js. And it works great with es2015 and es2016. But it breaks if I try to do es2017.
Does anyone know of any workarounds to minify js that uses the new experimental features in es2017?
gulp.src('build/js/bundled/bundle.js')
.pipe(babel({
compact: false,
presets: ["es2017", "react"],
plugins: ["transform-decorators-legacy"],
}))
.pipe(uglify())
.pipe(gulp.dest('build/js/bundled'));
which generates this error
GulpUglifyError: unable to minify JavaScript
If I change es2017 to es2015 / es2016 it shrinks my packages that do not have es2017 functionality. But I want to be able to use these experimental features and be able to minify my code
source to share
I think Uglify cannot parse some ES2015 features, so you need to translate them to ES5 ( es2017
target Node 5+).
With these web upload instructions , specifically presets and plugins, you should be able to get it to work (at least for me, how could I replicate similar Uglify problems just using es2017
):
presets: ['es2015', 'es2017', 'react'],
plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties']
source to share