一些es6功能不被grunt uglify js理解? [英] some es6 features are not understood by grunt uglify js?

查看:964
本文介绍了一些es6功能不被grunt uglify js理解?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用了grunt-uglify,我正在使用es6。对于某些es6功能,如胖箭头功能,它会抛出一个错误。我认为uglify并不低于那种语法。所以我有办法解决这个问题。我的意思是我可以使用任何东西来使uglify了解所有的es6语法?

解决方案

正式没有任何工具,然而(其他工具,如Google Closure编译器,支持ES6,但它将其转换为传统js,然后将其简化)。



尽管并非所有的es6功能在UglifyJs中得到支持, UglifyJS2的Harmony分支似乎支持箭头功能和其他功能。



您可以在github这个问题上阅读关于它的讨论。似乎没有其他选择等待(或创建自己的ES6分选机)。



更新



现在您有两个选项来缩小ES6:




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 that syntax. so do i have a way to fix this issue. I mean can i use anything to make uglify understand all the es6 syntaxes?

解决方案

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:

这篇关于一些es6功能不被grunt uglify js理解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆