Re: Closure minimize parse error

Cezary Biernacki <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <CAE26fNjMfVVN1xLsROxjGL6WG15NihVzPFUS53TpnUR_QYoqWA@mail.gmail.com>
As far as I can tell, it is not directly supported, but you can override
existing minimizer and just disable minimisation for particular files, like
that:


In your *Module class add necessary contribution

@Contribute(ResourceMinimizer.class)
@Primary
public static void overrideJavaScriptMinimizer(final
MappedConfiguration<String, ResourceMinimizer> configuration) {
    configuration.overrideInstance("text/javascript",
MyGoogleClosureMinimizer.class);
}


and define your minimisation class by extending GoogleClosureMinimizer and
overriding "isEnabled()" method with appropriate logic to disable
minimisation for specific files

public class MyGoogleClosureMinimizer extends GoogleClosureMinimizer {

    @Override
    protected boolean isEnabled(final StreamableResource resource) {
        return super.isEnabled(resource) &&
!resource.getDescription().endsWith("/compatibility.js");
    }

}


Notes:

   - I have not tested this example code, so you might fix some details,
   but I know that something similar should work (I wrote my custom JavaScript
   minimizers for Tapestry 5.4);
   - GoogleClosureMinimizer is part of Tapestry's internals, so be warned
   that it might require extra porting to new Tapestry's versions;
   - alternative approach is to replace global ResourceMinimizer service
   (see org.apache.tapestry5.internal.services.assets.MasterResourceMinimizer
   for default implementation) and your own logic to decide if minimisation
   should be performed.


Best regards,
Cezary




On Mon, Mar 12, 2018 at 5:30 PM, Nathan Quirynen <
[email protected]> wrote:

> Hi,
>
> on our testing server we get the following error:
>
> ... JSC_PARSE_ERROR. Parse error. getters are not supported in older
> versions of JavaScript. If you are targeting
> newer versions of JavaScript, set the appropriate language_in option. at
> StreamableResource<text/javascript classpath:META-INF/assets/js/pdfjs/build/compatibility.js
> COMPRESSABLE lastModifi
> ed: Mon Mar 12 15:20:19 CET 2018 size: 50791> line 1732 : 0.
> at org.apache.tapestry5.internal.webresources.GoogleClosureMini
> mizer.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.perfo
> rm(OperationTrackerImpl.java:110)
> at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.
> perform(PerThreadOperationTracker.java:84)
> at org.apache.tapestry5.ioc.internal.RegistryImpl.perform(RegistryImpl.java:1266)
> ... It does not occur when running the same application on my local machine
> in a Tomcat (same as on server).
>
> Any idea what could be the problem here?
> If no fix can be found, is there a way to tell Tapestry to not minimize
> this specific file to maybe get it working that way?
>
>
> Nathan
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.