Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YUI Compressor 2.4.8 failed on jQuery 2.2 #234

Open
stepand76 opened this issue Jan 15, 2016 · 23 comments
Open

YUI Compressor 2.4.8 failed on jQuery 2.2 #234

stepand76 opened this issue Jan 15, 2016 · 23 comments

Comments

@stepand76
Copy link

When I try to pass original uncompressed jquery-2.2.0.js file to YUI Compressor 2.4.8 I get following output (with jquery-2.1.4.js it works):

[ERROR] in jquery-2.2.0.js
  8239:27:missing name after . operator
[ERROR] in jquery-2.2.0.js
  8240:17:syntax error
[ERROR] in jquery-2.2.0.js
  8259:7:missing ) after argument list
[ERROR] in jquery-2.2.0.js
  8259:8:syntax error
[ERROR] in jquery-2.2.0.js
  8262:9:syntax error
[ERROR] in jquery-2.2.0.js
  8265:15:syntax error
[ERROR] in jquery-2.2.0.js
  8266:7:syntax error
[ERROR] in jquery-2.2.0.js
  8268:15:syntax error
[ERROR] in jquery-2.2.0.js
  8269:7:syntax error
[ERROR] in jquery-2.2.0.js
  8270:8:syntax error
[ERROR] in jquery-2.2.0.js
  8271:11:syntax error
[ERROR] in jquery-2.2.0.js
  8272:10:syntax error
[ERROR] in jquery-2.2.0.js
  8273:15:syntax error
[ERROR] in jquery-2.2.0.js
  8274:9:syntax error
[ERROR] in jquery-2.2.0.js
  8275:15:syntax error
[ERROR] in jquery-2.2.0.js
  8288:11:syntax error
[ERROR] in jquery-2.2.0.js
  8289:8:syntax error
[ERROR] in jquery-2.2.0.js
  8290:9:syntax error
[ERROR] in jquery-2.2.0.js
  8291:9:syntax error
[ERROR] in jquery-2.2.0.js
  8292:8:syntax error
[ERROR] in jquery-2.2.0.js
  8293:9:syntax error
[ERROR] in jquery-2.2.0.js
  8294:4:syntax error
[ERROR] in jquery-2.2.0.js
  8296:12:syntax error
[ERROR] in jquery-2.2.0.js
  8297:8:syntax error
[ERROR] in jquery-2.2.0.js
  8297:11:illegal character
[ERROR] in jquery-2.2.0.js
  8297:16:illegal character
[ERROR] in jquery-2.2.0.js
  8297:16:syntax error
[ERROR] in jquery-2.2.0.js
  8298:9:syntax error
[ERROR] in jquery-2.2.0.js
  8298:12:illegal character
[ERROR] in jquery-2.2.0.js
  8298:18:syntax error
[ERROR] in jquery-2.2.0.js
  8299:9:syntax error
[ERROR] in jquery-2.2.0.js
  8299:12:illegal character
[ERROR] in jquery-2.2.0.js
  8299:18:illegal character
[ERROR] in jquery-2.2.0.js
  8299:18:syntax error
[ERROR] in jquery-2.2.0.js
  8300:4:syntax error
[ERROR] in jquery-2.2.0.js
  8302:18:syntax error
[ERROR] in jquery-2.2.0.js
  8303:8:syntax error
[ERROR] in jquery-2.2.0.js
  8304:9:syntax error
[ERROR] in jquery-2.2.0.js
  8305:9:syntax error
[ERROR] in jquery-2.2.0.js
  8306:4:syntax error
[ERROR] in jquery-2.2.0.js
  8310:14:syntax error
[ERROR] in jquery-2.2.0.js
  8313:13:syntax error
[ERROR] in jquery-2.2.0.js
  8316:16:syntax error
[ERROR] in jquery-2.2.0.js
  8319:16:syntax error
[ERROR] in jquery-2.2.0.js
  8322:15:syntax error
[ERROR] in jquery-2.2.0.js
  8323:4:syntax error
[ERROR] in jquery-2.2.0.js
  8329:15:syntax error
[ERROR] in jquery-2.2.0.js
  8330:8:syntax error
[ERROR] in jquery-2.2.0.js
  8331:12:syntax error
[ERROR] in jquery-2.2.0.js
  8333:2:syntax error
[ERROR] in jquery-2.2.0.js
  8338:12:syntax error
[ERROR] in jquery-2.2.0.js
  8346:2:syntax error
[ERROR] in jquery-2.2.0.js
  8348:16:syntax error
[ERROR] in jquery-2.2.0.js
  8349:16:syntax error
[ERROR] in jquery-2.2.0.js
  8352:7:syntax error
[ERROR] in jquery-2.2.0.js
  8355:34:missing ; before statement
[ERROR] in jquery-2.2.0.js
  8356:13:syntax error
[ERROR] in jquery-2.2.0.js
  8358:3:syntax error
[ERROR] in jquery-2.2.0.js
  8361:12:syntax error
[ERROR] in jquery-2.2.0.js
  8535:10:invalid return
[ERROR] in jquery-2.2.0.js
  8614:10:invalid return
[ERROR] in jquery-2.2.0.js
  8641:11:invalid return
[ERROR] in jquery-2.2.0.js
  8781:9:invalid return
[ERROR] in jquery-2.2.0.js
  8782:2:syntax error
[ERROR] in jquery-2.2.0.js
  8784:10:syntax error
[ERROR] in jquery-2.2.0.js
  8786:2:syntax error
[ERROR] in jquery-2.2.0.js
  8788:12:syntax error
[ERROR] in jquery-2.2.0.js
  8790:2:syntax error
[ERROR] in jquery-2.2.0.js
  8791:3:syntax error
[ERROR] in jquery-2.2.0.js
  9830:7:invalid return
[ERROR] in jquery-2.2.0.js
  9831:1:syntax error
[ERROR] in jquery-2.2.0.js
  1:0:Compilation produced 71 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 71 syntax errors.
    at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:172)
    at org.mozilla.javascript.Parser.parse(Parser.java:396)
    at org.mozilla.javascript.Parser.parse(Parser.java:340)
    at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
    at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:536)
    at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:147)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
@fiatux
Copy link

fiatux commented Jan 25, 2016

same problem here!

@stepand76
Copy link
Author

Any chance that this will be fixed?

@mgol
Copy link

mgol commented Jan 27, 2016

This is a bug in YUI Compressor. Could you report it to them?

@stepand76
Copy link
Author

It is reported to the YUI Compressor, isn't it?

@mgol
Copy link

mgol commented Jan 27, 2016

I'm sorry, for a moment I thought it was reported against jQuery... I commented too fast, please disregard.

@IceReaper
Copy link

Problem: "throws" and several other names are marked as reserved in YUI, while jquery assumes they are not and uses them.
Location: https://github.com/yui/yuicompressor/blob/c41a4b504a996b9c2a49b497e2f61ba7998b0408/src/org/mozilla/javascript/TokenStream.java

Step1: Make a list of all wrongly-reserved-names plus proof-link
Step2: Remove them and make a PR or fork of YUI and / or jQuery, depending on who violates the JS-RFC. Shouldn't take that much time to do.

If there is already such PR, link it here. Haven't found one.

@tml
Copy link
Contributor

tml commented Feb 15, 2016

To clarify - "throws" and several other names are marked as reserved in JAVASCRIPT, and YUICompressor is respecting that declaration.

The trick that makes it a bit harder is that YUICompressor isn't tied to a specific version of Java/ECMAScript, and in older versions, these are illegal identifiers. So you have to allow it for ES5+ while not allowing it in ES4 and earlier; while keeping in mind that there's no standardized way for a bit of JavaScript code to declare which version of JS/ES it thinks it wants to be.

If you have ideas for solving all of those problems in the same go, I'd love to hear about them! :)

@IceReaper
Copy link

As an ugly workaround it could be possible to do a replacement before / after minification. The replacement-logic could be triggered by a simple --language-version parameter.

@bashor
Copy link

bashor commented Mar 21, 2016

Same issue with kotlin.js. Should I report separate issue?

To reproduce download kotlin-compiler-1.0.1.zip and see kotlinc/lib/kotlin-jslib.jar/kotlin.js

@stepand76
Copy link
Author

Well, any chance this to be fixed?

@saleehk
Copy link

saleehk commented Mar 24, 2016

+1

@meyermc
Copy link

meyermc commented Mar 28, 2016

I have this same issue with pdf.js, I tried to give them a pull request and they rejected it, pointing out that 'char' is not a reserved word in ES5.1 and that ECMSScript permits reserved words ('catch', 'delete') as property names. So, declaring a reserved word variable or function is illegal but assigning a function literal to a reserved word property is valid.

@varun1987shrivastava
Copy link

I think this is related to the keywords that js file uses clash with some in-build keywords of the compressor. you can try using the minified version of the js file to get rid of this issue. this is something i did in my project when using jquery-3.1.0.

@LeiZeng
Copy link

LeiZeng commented Dec 27, 2016

A work around by using babel plugins:
https://gist.github.com/LeiZeng/535de7c66f1a847c7bf80705098ea517

@nueverest
Copy link

Still breaking for jquery is there a reason this is closed?

@mgol
Copy link

mgol commented Feb 28, 2017

@nueverest This issue is not closed.

@dignityinside
Copy link

+1

1 similar comment
@timurgen
Copy link

timurgen commented Mar 1, 2017

+1

@Chris2011
Copy link

Issue still appears. As you can see it here too: #262 Is this Project still alive?

@SuperPat45
Copy link

+1

@NucleaPeon
Copy link

Yuicompressor fails against jquery v3.3.1 too

[ERROR] in jquery-3.3.1.js
  3845:9:missing name after . operator
[ERROR] in jquery-3.3.1.js
  3846:11:syntax error
[ERROR] in jquery-3.3.1.js
  3847:5:missing ; before statement
[ERROR] in jquery-3.3.1.js
  3850:2:missing ) after argument list
[ERROR] in jquery-3.3.1.js
  8783:27:missing name after . operator
[ERROR] in jquery-3.3.1.js
  8784:17:syntax error
[ERROR] in jquery-3.3.1.js
  8800:8:invalid return
[ERROR] in jquery-3.3.1.js
  8800:34:missing ; before statement
[ERROR] in jquery-3.3.1.js
  10363:7:invalid return
[ERROR] in jquery-3.3.1.js
  10364:1:syntax error
[ERROR] in jquery-3.3.1.js
  1:0:Compilation produced 10 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 10 syntax errors.
        at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:172)
        at org.mozilla.javascript.Parser.parse(Parser.java:396)
        at org.mozilla.javascript.Parser.parse(Parser.java:340)
        at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
        at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:536)
        at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:147)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)

@tml
Copy link
Contributor

tml commented Jan 3, 2019

That's correct - jquery 3.3.1 is not valid ECMAScript 3 syntax; YUICompressor does not support anything else at this time.

@MrD0llaro
Copy link

I have solved with custom methods, i have used a fork https://github.com/MrD0llaro/yuicompressor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests