-
Notifications
You must be signed in to change notification settings - Fork 33
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
Yuglify fails to parse jquery.js #19
Comments
Seeing same issue with jQuery 2.1.0. |
I'm finding it has to do with an exclamation mark at the beginning of a comment in the middle of a variable assignment. (Happens in jQuery when Sizzle is defined)
|
On testing it again, it looks like it's not fixed by that pull request. |
Still having an issue with this with Jquery-1.11.1.js
You can easily get this to work by removing the comment blocks including the /*! comments. Beginning of the file, and where it shows "sizzle". Once they are removed yuglify works as normal. |
I'm willing to downgrade my jquery and/or yuglify versions if that can make it work (its far easier for me than modifying the code of jquery, because we don't really include the code for thirdparties in our projects. Do anyone know what versions of jquery/yuglify should I use, while waiting for the fix ? Thank you ! |
@ewjoachim works ok with jquery version 2.0.3. |
I can confirm that removing the two comment blocks starting with /*! resolves the compile issue. |
Considering that jQuery 2.x doesn't support IE8, lots of people will still be using jQuery 1.11+ for the near future, which still has this problem. I'm going to just use "uglify-js" in the meantime. |
any updates on this one? with v2.1.3 the issue still remains, btw i can also confirm that by removing the two comment blocks starting with /*! resolves the compile issue. |
any workaround except changing jquery's code? |
Same story, here. BTW, I am wondering why |
Lemme explain why this is happening. When you look at the var Sizzle =
/*!
* Sizzle CSS Selector Engine v2.2.0-pre
* http://sizzlejs.com/
*
* Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2014-12-16
*/
(function( window ) {
// ...
}); which looks totally fine at first sight. However, during the compilation process var Sizzle =
;"yUglify: preserved comment block";
(function( window ) {
// ...
}); This fails to be a valid JavaScript. So the question here is why do we want to replace a block comment with something which has a semantic meaning. I think everyone understand the reason something has to be done, because otherwise the minify process might break things. However, we could replace that block comment with something more like:
which should not break anything and it's shorter then the current solution. |
Ah! I can see what you did there https://github.com/yui/yuglify/blob/master/lib/jsminify.js#L44-L50 I understand that this is a hack there to prevent |
Turns out, not having an ability to preserve "license" comments is a long existing issue in |
BTW, have you considered using https://github.com/mishoo/UglifyJS2 instead? |
Ha! I've seen there's already an issue for this #7. |
@apendua: After hours of hair-pulling I came across this discussion. Just switched from Yugilfy to UglifyJS2, problem gone. Tx. |
I'm just adding jQuery to a static files work-flow for my project, so I just changed to the already minified version of jQuery which doesn't have the evil comments discussed earlier. I realize this isn't even a workaround for the issue at hand but it might be helpful for some people. |
@jonykalavera Nice trick 👍 |
Using jquery.min.js instead of jquery.js solved the issue for me. |
I got burned by this problem this AM -- not from jquery but from the minified versions of bootstrap and parsley javascript. Recommend generalizing the name of this issue. +1 for some kind of fix. Seems to happen for me only from terminal input though. |
@jonykalavera it works! thanks! :) I wonder if this issue is being working on or not? |
Use Google's CDN to serve these incredibly common libraries, falling back to our local minified versions if needed. Yuglify can't compress the standard jQuery library (as noted on yui/yuglify#19). As a workaround, we can pass the minified version to Yuglify, as the minified version lacks comments that are triggering the error. Also, move the last bit of JavaScript into the minified project source.
I thought it was still an issue with jQuery 3.4.1 and 3.5.0. minified and non-minified both. I was using django-compressor, and it turns out, this is the right config:
|
Steps to reproduce:
This failure to parse occurred some time between jQuery 1.10 and 1.11 as 1.10 parses fine:
I submitted a bug to jQuery, but they believe this is a Yuglify bug. See: http://bugs.jquery.com/ticket/14998
The text was updated successfully, but these errors were encountered: