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
Uglification error: Print the line number and actual source file #228
Comments
Maybe run your files individually through grunt-contrib-jshint before attempting uglification? By the way, most IDEs and text editors support JSHint through extensions/plugins. This provides a faster feedback cycle than looking at the console and mapping the errors back to the editor manually. |
@UltCombo there are a thousand ways around it, which doesn't mean the error message should be so useless. |
I've just tried to uglify a file with invalid syntax, the line numbers are correct for me. The error message outputs a comma-separated list of files instead of the file which threw the error, though. This seems to be due to the I don't know how easy or hard it would be to workaround this issue, seeing as the error is thrown from inside the Uglify2 library (it would probably need storing and passing around the current file before attempting to parse it with Uglify). I would just take one of the thousand ways around it meanwhile. |
From what I could see, the line number is incorrect. The line number displayed refers to the line number of the result of the concatenation of all uglified files. It's not the line number of the correct file (unless that file is the first file of the concatenation). p.s. Wouldn't it be simple to just uglify the files separately before concatenating them? |
@lewisdiamond I've tested it by uglifying two files inside of a folder ( And as far as I can see, each file is compiled individually inside of a forEach loop. Perhaps there is another issue with how your gruntfile is set up? |
When there's a Javascript error, the grunt uglify task doesn't print a very helpful message:
Warning: Uglification failed.
Unexpected token: punc (}).
Line 57 in src/myapp.js,src/alerts.js,src/extensions.js,src/nodeserialize.js,src/view.js
Use --force to continue.
The error is on line 57 of a file made by concatenating all my files. This concatenation isn't readily available either (I haven't found this temp file on my drive, you can always manually concat them but it doesn't mean the line numbers will match).
It would be much better if it would print the actual source file and the line number inside that source file.
The text was updated successfully, but these errors were encountered: