Monday, February 25, 2019

All About GCC Compiler

Recently in one of my project, I faced an issue where angular code was coming on the screen instead of the resolved values.

Example : {{value}}


From AEM 6.2 , a new minification engine GCC (Google Clojure Compiler) has been introduced that we can swipe with the current YUI engine.

In order to configure it , go the OSGI configuration HTML Library Manager or Adobe Granite HTML Library Manager (AEM 6.4) and update the compiler value to gcc instead of the default yui.


In order to make it project specific , you can use the OSGI configuration with PID com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl in the run modes and update the below values to enable gcc compiler :

1) htmllibmanager.processor.css=["min:gcc"]
2) htmllibmanager.processor.js=["min:gcc"]


The other way to get the same thing working is to specify the multivalue properties in your cq:ClientLibraryFolder as cssProcessor and jsProcessor as below :

jsProcessor: ["default:none", "min:gcc;compilationLevel=advanced"]

Note: This will only be limited to the particular client library.

A custom processor can also be created by implementing the interface com.adobe.granite.ui.clientlibs.script.ScriptProcessor and the same properties can be specified in the cq:ClientLibraryFolder as properties.

Additional GCC options:


a) failOnWarning (defaults to false)
b) languageIn (defaults to "ECMASCRIPT5")
c) languageOut (defaults to "ECMASCRIPT5")
d) compilationLevel (defaults to "simple") (values : whitespace,simple,advanced)
                  1) whitespace : removes comments,line breaks and unnecessary spaces
                  2) simple : performs the same as whitespace plus performs optimizations within         expressions and functions including renaming of local varibales.
                  3) advance: performs the same as simple plus provide additional global transformations.


For more information on the compiler check the below link:

https://developers.google.com/closure/compiler/