Dojo构建如何缩小ECMASCRIPT5中编写的代码?

时间:2015-11-26 10:28:29

标签: javascript batch-file dojo google-closure-compiler

我正在使用dojo build tools来缩小我的项目。

我的部分代码是使用for (View v : array.getView()) { v.setOnClickListener(this) } 编写的,我在运行标准 .bat file时收到Closure Compiler的错误。

似乎它们有一些限制,因为默认情况下编译器在ES3上设置为described here

findViewById

我需要能够编译我的ES5代码,并且我更改ECMASCRIPT5尝试传递标记0 error(s), 1 warning(s) builderReference.js.uncompressed.js:15: ERROR - Parse error. getters are not supported in older versions of JS. If you are targeti ng newer versions of JS, set the appropriate language_in option. get builder() { ^

.bat file

不幸的是我仍然收到同样的错误。

我需要知道:

  • 如何缩小用ES5编写的代码?
  • language_in=ECMASCRIPT5
  • 中的标记是否正确
  • 是否可以在xxx.profile.js中添加此配置?

非常欢迎任何想法。

1 个答案:

答案 0 :(得分:4)

methodA中添加以下配置可解决问题。

self

来自dojo文档:

  

optimizeOptions(default =“undefined”)此对象传递给   JavaScript优化器允许编译器特定设置。设置   对于UglifyJS和闭包编译器可以使用此对象进行设置。

不幸的是,文档没有提供该对象的详细信息。下面是一些包含更多资源的链接:

http://dojo-toolkit.33424.n3.nabble.com/Build-Pass-options-to-Closure-compiler-td4002152.html

http://dojotoolkit.org/reference-guide/1.10/build/qref.html

https://groups.google.com/forum/#!msg/requirejs/9f4sgewYnAw/G-oSqCz2DSEJ

https://bugs.dojotoolkit.org/ticket/16196

https://github.com/dojo/util/pull/27

http://dojo-toolkit.33424.n3.nabble.com/Build-Pass-options-to-Closure-compiler-td4002152.html

https://bugs.dojotoolkit.org/ticket/16601