enable ES6 support on ClosureJavaScriptCompressionHandler

cancel
Showing results for 
Search instead for 
Did you mean: 
vincent-kali
Established Member

enable ES6 support on ClosureJavaScriptCompressionHandler

Hi,

I'm using some JS component in AIKAU widgets. It works fine when debug mode is enabled in share, but when debug is disabled, widget is not rendered.

Following error message appears in log: [extensions.surf.ClosureJavaScriptCompressionHandler] [http-apr-8080-exec-7] input.js:195: ERROR - this language feature is only supported for ECMASCRIPT6 mode or better: class. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT to enable ES6 features.

I'm using alfresco CE 5.2.g with aikau 1.0.101.

How to enable ES6 support on ClosureJavaScriptCompressionHandler ?

Thanks.

 

3 Replies
afaust
Master

Re: enable ES6 support on ClosureJavaScriptCompressionHandler

Instead of trying to fiddle with the ClosureJavaScriptCompressionHandler, you may be better off to replace that with the ExternalJavaScriptCompressionHandler, which is able to call an external command (most likely some Node.js based script) to run the compression. This class was introduced alongside ExternalLessCssThemeHandler to allow for flexibility in using better tools, when the Surf-provided classes did not keep up with current standards - which they have not, considered there isn't any noticeable development anymore apart from bugfixes.

vincent-kali
Established Member

Re: enable ES6 support on ClosureJavaScriptCompressionHandler

Thanks for this valuable advice.

Could you share an example of how to implement this ?

(the error message of ClosureJavaScriptCompressionHandler looks like a simple settings may enable ES6 support. What do you think about that ?)

Highlighted
afaust
Master

Re: enable ES6 support on ClosureJavaScriptCompressionHandler

You'll need to configure a bean with ID "javascript.compression.handler" using that class, e.g. in custom-slingshot-application-context.xml, and have that bean extend from the parent "javascript.compression.handler.abstract".

Sure, the error message sounds like you could just set a flag. But the flag is currentl hard-coded in the ClosureJavaScriptCompressionHandler class and would require you to patch that class and recompile.