rspivak / slimit

SlimIt - a JavaScript minifier/parser in Python
MIT License
551 stars 94 forks source link

Invalid removal of parentheses of immediately called function #28

Closed rivol closed 12 years ago

rivol commented 12 years ago

Consider this JS snippet:

(function($) {
    $.hello = 'world';
}(jQuery));

The result of running Slimit on it is:

function($){$.hello='world';}(jQuery);

which is invalid JS. The outer parentheses are required here, so Slimit shouldn't remove them.

The real-world issue that I stumbled upon was with jQuery Timeago plugin: https://github.com/rmm5t/jquery-timeago It's using the above-mentioned construct and slimit is unable to pack it :-(

rspivak commented 12 years ago

Thanks for the bug report. I'll look into this.

rspivak commented 12 years ago

Fixed in 94085491a62337a59510d59500c30745fd740553

I've also uploaded a new version of Slimit 0.6.2 to PyPI. Let me know if you have any other issues and thanks again.

rivol commented 12 years ago

Wow, thanks a lot for the quick response :-) I can confirm that 0.6.2 works fine and resolves my issues.