Using Google Closure Compiler (GCC) Options with AEM Client LibrariesPosted by Sean on Thursday, November 29, 2018
Debugging GCC Client Library Minification
This got me to a low enough level of info on what errors were acutally occuring during compilation, so I that I knew what the problem was. As it turns out, some our developers had been using the ES6
let keyword to declare variables, and the compiler was choking on this because the source mode defaults to ES5.
Once I knew that, the next step was figuring out how to fix it.
Using GCC Options
By setting the
jsProcessor properties on the
cq:ClientLibraryFolder folder node, you can change how a particularly client library is processed. This is, I think, well known and understood. For a good example of this, see how ACS Commons uses it for gcc minification.
In addition to changing the processor from yui to gcc though, you can also pass additional options to GCC to tune the compilation process. For example, if your js source uses ES6/ES2015 syntax, as ours was, you can pass the
languageIn option to have it transpile your ES6 code to ES5.
In addition to
languageIn, you can also pass
To combine multiple options, you simply separate each one with a semi-colon as follows.
Note that all of these options can also be set globally on the
jsProcessor property of the
com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl service configuration.