Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

AEM 6.5.2 JS files are not minified with gcc and yui

Avatar

Level 3

Hi,

 

JS minify is not happening in AEM 6.5.2 instance for our project. I tried with gcc (min:gcc;languageIn=ECMASCRIPT6) with Adobe Granite HTML Library Manager and also tried with default minify (min:yui). Both seems not working.

 

Thanks in Advance.

24 Replies

Avatar

Community Advisor

Could you please try to minify your js here-

https://www.freeformatter.com/javascript-minifier.html

 

If it works here then we can check in aem , nor it should not work online only there must be some error in your js file, due to which you are not able to minify the js.

Avatar

Level 3
Thank you for your response. I tried minifying using the free formatter and it throws an error in JS files. Basically it throws an error in lines which used "let" keyword. Does min:gcc not support let?

Avatar

Community Advisor
yes it wont you need to fix all these errors

Avatar

Level 3
I fixed all the errors and it works in freeformatter. But no effect in AEM and still it is not minified in AEM (version 6.5.2)

Avatar

Community Advisor
check the logs and share the logs whats the error

Avatar

Level 3

The following is the error that i can see it in error.log but the error is very uncertain. Very rarely i get this.

ERROR [com.adobe.granite.ui.clientlibs.processor.gcc.impl.GCCScriptProcessor] Error setting compiler options for flags {minify=true, languageIn=ECMASCRIPT6}: No enum constant com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT6

 

DEBUG [com.adobe.granite.ui.clientlibs.impl.HtmlLibraryBuilderImpl] processing {My clientlibrary path} with processor gcc for mode min rejected.

Tried with min:yui and i could not see any errors but no result either.

Avatar

Level 10

Hi @divyas70997717 ,

I see that you are trying to use ECMASCRIPT6 as an option for gcc.

"gcc" stands for Google Closure Compiler. There seems to be no ECMASCRIPT6 option for languageIn, you'll have to pick one from the following list (which I got from the documentation on GCC's GitHub page

ECMASCRIPT3
ECMASCRIPT5
ECMASCRIPT5_STRICT
ECMASCRIPT6_TYPED (experimental)
ECMASCRIPT_2015
ECMASCRIPT_2016
ECMASCRIPT_2017
ECMASCRIPT_2018
ECMASCRIPT_2019
STABLE
ECMASCRIPT_NEXT

ECMASCRIPT_2015 is equivalent to ES6 btw: https://www.w3schools.com/js/js_es6.asp

Hope this helps, let me know  

Avatar

Level 3
Thank you for your response. I have already tried ECMASCRIPT_2015 and also with other options. It did not work out so i have used ECMASCRIPT6 option.

Avatar

Employee
jsProcessor=[default:none,min:gcc;languageIn=ECMASCRIPT_2015;languageOut=ECMASCRIPT_2015]

Avatar

Level 3
Tried this option default:none,min:gcc;languageIn=ECMASCRIPT_2015;languageOut=ECMASCRIPT_2015 and it is also not working.

Avatar

Employee
Can you share the output in the error.log from the HTML Library Manager? It likely spits out some more details on why the minification fails. Can you manually minify your JS directly on Google Closure? Here : https://closure-compiler.appspot.com/home

Avatar

Level 2

I am too facing the same issue. Here it is from log.

 

10.06.2020 14:40:34.526 *INFO* [202.174.120.2 [1591800034525] GET /etc.clientlibs/appName/clientlibs/clientlib-base.min.css HTTP/1.1] com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl Start building CSS library: /apps/appName/clientlibs/clientlib-base (minified)
10.06.2020 14:40:36.192 *INFO* [202.174.120.2 [1591800034525] GET /etc.clientlibs/appName/clientlibs/clientlib-base.min.css HTTP/1.1] com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl finished building library /apps/appName/clientlibs/clientlib-base.css
10.06.2020 14:40:41.441 *INFO* [202.174.120.2 [1591800041441] GET /etc.clientlibs/appName/clientlibs/clientlib-base.min.js HTTP/1.1] com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl Start building JS library: /apps/appName/clientlibs/clientlib-base (minified)
10.06.2020 14:40:41.444 *ERROR* [202.174.120.2 [1591800041441] GET /etc.clientlibs/appName/clientlibs/clientlib-base.min.js HTTP/1.1] com.adobe.granite.ui.clientlibs.processor.gcc.impl.GCCScriptProcessor Error setting compiler options for flags { languageOut=ECMASCRIPT_2019, minify=true, languageIn=ECMASCRIPT_2019, compilationLevel=advanced}: No enum constant com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT_2019
10.06.2020 14:40:41.449 *INFO* [202.174.120.2 [1591800041441] GET /etc.clientlibs/appName/clientlibs/clientlib-base.min.js HTTP/1.1] com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl finished building library /apps/appName/clientlibs/clientlib-base.js

Avatar

Level 4

Hi, any update on this? I have the same issue now. On gcc compiler site, my scritpts compiled fine. and on my clientlibrary folder, no matter what I set: min:gcc;languageIn=ECMASCRIPT_2016;languageOut=ECMASCRIPT3.

The javscript file doesn't compiled during runtime. Any idea?

Avatar

Level 2

Hi,

If there are any compilation error seen in the AEM error log, try fixing it. If there are no error then just try with option min:gcc and no other language parameter. To recompile in the AEM instance put a space and save the original JS source file GCC option will try to compile and minify it. 

Avatar

Level 4

No luck, still the same, es6 javascript not got transcompiled and forms rule editor still cannot be opened due to AEM thinks it is a syntax error.

 

Avatar

Level 2

Suggested to create an Adobe AEM support ticket or you can try minify as part of your codebase build release as a workaround solution. We had tried these language options for ES6 javascripts but had come across similar issues.

Avatar

Level 4

Thanks, opened a ticket to Adobe support already. Seems for now, we have to gcc ourselves and put the compiled code in the client library.

Avatar

Level 4

problem resolved:

In HTML library manager, change the default jsProcessor to min:gcc.

Then for client library folder, add the following:

jsProcessor=[min:gcc;obfuscate=true;languageIn=ECMASCRIPT_2019;languageOut=ECMASCRIPT3]

 

then application works. At least AEM js compiler syntax check passed for this configuration.

Avatar

Level 2

Ok nice. But curios to know with this configuration is it really compressing the JS as part of minification?

Avatar

Level 4

No, just the AEM forms rules editor can pass the validation, the final output *.min.js still not minified and the client library source code showed on the final publisher page. Seems need more dig into it. ^_^

 I enabled the Minify on the HTML client library manager, still, the ecmascript_2019 source code passthrough to the final page javscript file. no minify and no transcompile.