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

Dojo build how to minify code written in ECMASCRIPT5?

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

我的部分代码是使用 ECMASCRIPT5 编写的,当 运行 标准 .bat file 时,我从 Closure Compiler 收到错误消息。

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


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() {
^

我需要能够编译我的 ES5 代码,我更改 .bat file 试图通过标志 language_in=ECMASCRIPT5

java -Xms256m -Xmx256m  -cp "%~dp0../shrinksafe/js.jar";"%~dp0../closureCompiler/compiler.jar";"%~dp0../shrinksafe/shrinksafe.jar" org.mozilla.javascript.tools.shell.Main  "%~dp0../../dojo/dojo.js" baseUrl="%~dp0../../dojo" load=build language_in=ECMASCRIPT5 %*

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

我需要知道:

非常欢迎任何想法谢谢。

app.profile.js中添加如下配置解决问题

// Set the optimization options for the Google closure compiler. 
optimizeOptions: { 
        languageIn: Packages.com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT5 
} 

来自 dojo 文档:

optimizeOptions (default = "undefined") This object is passed to the JavaScript optimizer to allow for compiler specific settings. Settings for UglifyJS and closure compiler can be set using this object.

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

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