nervo / yuicompressor

16 stars 4 forks source link

javascript compression fails when using delete as function name on object #4

Closed jbhamilton closed 9 years ago

jbhamilton commented 9 years ago

When an object has a method named "delete" the compression fails

Ex:

SC.delete('/resource',function(){
});

Error:

[ERROR] in public/js/js.js
  805:18:missing name after . operator
[ERROR] in public/js/js.js
  806:21:syntax error
[ERROR] in public/js/js.js
  807:10:syntax error
[ERROR] in public/js/js.js
  812:1:missing ) after argument list
[ERROR] in public/js/js.js
  812:2:syntax error
[ERROR] in public/js/js.js
  1:0:Compilation produced 5 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 5 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:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
nervo commented 9 years ago

Looks like an upstream issue :)

jbhamilton commented 9 years ago

Yeah it is. I opened the same issue on the upstream branch.

nervo commented 9 years ago

My personnal advice: forget yuicompressor, this is a so 2010 technology :) Have a look on nodejs ecosystem.

jbhamilton commented 9 years ago

Will do. Do you have a personal favorite you use that compresses both css and js that I could look into? Thanks!

nervo commented 9 years ago

You would better use dedicated tools. For instance css-clean (https://www.npmjs.com/package/clean-css) for css, and uglify-js (https://www.npmjs.com/package/uglify-js) for js. I recommand also a build tool, like gulp (my favourite) or grunt.