Open stepand76 opened 8 years ago
same problem here!
Any chance that this will be fixed?
This is a bug in YUI Compressor. Could you report it to them?
It is reported to the YUI Compressor, isn't it?
I'm sorry, for a moment I thought it was reported against jQuery... I commented too fast, please disregard.
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.
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! :)
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.
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
Well, any chance this to be fixed?
+1
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.
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.
A work around by using babel plugins: https://gist.github.com/LeiZeng/535de7c66f1a847c7bf80705098ea517
Still breaking for jquery is there a reason this is closed?
@nueverest This issue is not closed.
+1
+1
Issue still appears. As you can see it here too: https://github.com/yui/yuicompressor/issues/262 Is this Project still alive?
+1
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)
That's correct - jquery 3.3.1 is not valid ECMAScript 3 syntax; YUICompressor does not support anything else at this time.
I have solved with custom methods, i have used a fork https://github.com/MrD0llaro/yuicompressor
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):