Updating ResourceMinimizer to handle ES6

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Updating ResourceMinimizer to handle ES6

JumpStart
Is there any plan to upgrade the ResourceMinimizer to handle EcmaScript 6? I’m having to downgrade some javascript to avoid the minimiser rejecting it in production. For example:

2019-07-29 05:25:33,162 SEVERE [com.google.javascript.jscomp] (default task-14) StreamableResource<text/javascript classpath:META-INF/assets/clientapp/indexedDBHandler.js COMPRESSABLE lastModified: Mon Jul 29 05:25:14 UTC 2019 size: 10105>:29: ERROR - Parse error. syntax error
                return new Promise((resolve, reject) => {
                                                      ^

2019-07-29 05:25:33,181 ERROR [org.apache.tapestry5.ioc.Registry] (default task-14) Compilation failed: JSC_PARSE_ERROR. Parse error. syntax error at StreamableResource<text/javascript classpath:META-INF/assets/clientapp/indexedDBHandler.js COMPRESSABLE

        at org.apache.tapestry5.internal.webresources.GoogleClosureMinimizer.doMinimize(GoogleClosureMinimizer.java:97)
        at org.apache.tapestry5.internal.webresources.AbstractMinimizer$1.perform(AbstractMinimizer.java:72)
        at org.apache.tapestry5.internal.webresources.AbstractMinimizer$1.perform(AbstractMinimizer.java:68)
        at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.perform(OperationTrackerImpl.java:110)

Cheers,

Geoff
Reply | Threaded
Open this post in threaded view
|

Re: Updating ResourceMinimizer to handle ES6

Ben Weidig
Hi Geoff,

we ran into some issues with Google Closure in our projects so we added a
RequestFilter that blacklists JS compression for some files by settings
org.apache.tapestry5.TapestryConstants.DISABLE_JAVASCRIPT_MINIMIZATION in
the request to true based on regex-patterns.

Tapestry 5.5 update Google Closure to a version from 2017 (vs 2013 in 5.4)
but I'm not sure if it's configured for ES6 though, or with which version
Google Closure started supporting ES6.

An alternative approach (which we didn't use, blacklisting was good for us)
is replacing the minimizer with a custom version, it's contributed
in org.apache.tapestry5.webresources.modules.WebResourcesModule.setupDefaultResourceMinimizers(MappedConfiguration<String,
ResourceMinimizer>) and should be overridable.

The topic came up on the mailing list before:

http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Closure-minimize-parse-error-td5733834.html

Hope this helps.

Cheers
Ben

On Thu, Aug 1, 2019 at 6:48 AM JumpStart <
[hidden email]> wrote:

> Is there any plan to upgrade the ResourceMinimizer to handle EcmaScript 6?
> I’m having to downgrade some javascript to avoid the minimiser rejecting it
> in production. For example:
>
> 2019-07-29 05:25:33,162 SEVERE [com.google.javascript.jscomp] (default
> task-14) StreamableResource<text/javascript
> classpath:META-INF/assets/clientapp/indexedDBHandler.js COMPRESSABLE
> lastModified: Mon Jul 29 05:25:14 UTC 2019 size: 10105>:29: ERROR - Parse
> error. syntax error
>                 return new Promise((resolve, reject) => {
>                                                       ^
> …
> 2019-07-29 05:25:33,181 ERROR [org.apache.tapestry5.ioc.Registry] (default
> task-14) Compilation failed: JSC_PARSE_ERROR. Parse error. syntax error at
> StreamableResource<text/javascript
> classpath:META-INF/assets/clientapp/indexedDBHandler.js COMPRESSABLE
> …
>         at
> org.apache.tapestry5.internal.webresources.GoogleClosureMinimizer.doMinimize(GoogleClosureMinimizer.java:97)
>         at
> org.apache.tapestry5.internal.webresources.AbstractMinimizer$1.perform(AbstractMinimizer.java:72)
>         at
> org.apache.tapestry5.internal.webresources.AbstractMinimizer$1.perform(AbstractMinimizer.java:68)
>         at
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.perform(OperationTrackerImpl.java:110)
>
> Cheers,
>
> Geoff