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

Uncaught SyntaxError: Unexpected token * with comments at the end of a file #35

Closed
pixelhomie opened this issue Feb 3, 2015 · 4 comments

Comments

@pixelhomie
Copy link

Theres an issue with comments at the end of a file. For example:

jQuery(document).ready(function($) {
// do your stuff
});
// the bad comment

The last comment is causing an Unexpected token * Syntax Error.

@matthiasmullie
Copy link
Owner

I can't reproduce this issue - I tried minifying the above example and it seemed to do so correctly.
Any chance you could attach an exact example of an original file that fails this way, after minifying it?

@pixelhomie
Copy link
Author

I tried to minify Bootstrap Toggle (http://www.bootstraptoggle.com) and holder.js (http://imsky.github.io/holder). With the current master i get a different error: "Uncaught SyntaxError: Unexpected identifier". It seems that not all comments are removed in this file.

Minified file: http://www.file-upload.net/download-10261212/scripts.js.html

matthiasmullie added a commit that referenced this issue Feb 6, 2015
@matthiasmullie
Copy link
Owner

It took me awhile to figure out what went wrong here. I couldn't reproduce it as my IDE keeps adding an empty newline at the end of every file.

Anyway: when a script ends in a single-line comment & the next script is joined, it doesn't start at a newline, just right behind the previous script. Which results in it being part of the single-line comment, right until the next \n

5d1886a should fix this problem. Released 1.3.18

@pixelhomie
Copy link
Author

Working perfect. Thank You!

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

2 participants