GibboK
GibboK

Reputation: 73968

Dojo build how to minify code written in ECMASCRIPT5?

I am using dojo build tools in order to minify my project.

Part of my code is written using ECMASCRIPT5 and I receive and error from Closure Compiler when running the standard .bat file.

It seems that they are some limitation as by default the compiler is set on ES3 as 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() {
^

I need to be able to compile my ES5 code, and I change .bat file trying to pass the flag 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 %*

Unfortunately I still receive the same errors.

I would need to know:

Any ideas is very welcome thanks.

Upvotes: 1

Views: 797

Answers (1)

GibboK
GibboK

Reputation: 73968

Adding the following configuration in app.profile.js solve the issue.

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

From dojo documentation:

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.

Unfortunately the docs does no provide the details for that object. Below some links with more resources:

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

Upvotes: 4

Related Questions