some es6 features are not understood by grunt uglify js?

前端 未结 5 1637
眼角桃花
眼角桃花 2020-12-11 00:41

I used grunt-uglify in my project and I\'m working with es6. for some es6 features, such as fat arrow function, it\'s throwing an error. I think the uglify don\'t understant

5条回答
  •  死守一世寂寞
    2020-12-11 01:17

    Officially there's no tool that minifies ES6 yet (Other tools like Google Closure compiler supports ES6 but it transpile it into "traditional js" and then it's minified).

    Although not all the es6 features are supported in UglifyJs, the Harmony branch of UglifyJS2 seems to support arrow functions and other features.

    You can read the discussion about it in the issue of github here. It seems there's not another option to wait (or create your own ES6 minifier).

    Update

    Now you have 2 options to minify ES6:

    • Babili, an ES6+ aware minifier based on the Babel toolchain (beta)
    • The Harmony branch of UglifyJS

提交回复
热议问题