Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 Possible Bug in Asset Pipeline and Uglifier

I ran into a problem deploying on Heroku do to a failure in the rake task

rake assets:precompile

At the bottom is the error I get if I integrate

  • Rails 3.1
  • Jquery calendar: https://github.com/themouette/jquery-week-calendar
  • Twitter bootstrap

The error happens from uglifier.

I suspect that problem could be related to the inclusion of many localizations for the calendar.

I worked around the error by setting:

# Compress JavaScripts and CSS
config.assets.compress = false

I was not able to examine the files as the temporary files are cleaned up. I also could not get the debugger in RubyMine to stop at a breakpoint.

Any ideas if this is a bug? Any way to get the temporary files to not get deleted? Any way to make the RubyMine debugger work on the rake task (yes, tried the obvious, using EAP 112-291.

rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets rake aborted! Unexpected character '' (line: 21454, col: 0, pos: 641761)

Error at new JS_Parse_Error (/tmp/execjs20111231-15374-1fve7h4.js:497:22) at js_error (/tmp/execjs20111231-15374-1fve7h4.js:505:15) at parse_error (/tmp/execjs20111231-15374-1fve7h4.js:596:17) at Object.next_token [as input] (/tmp/execjs20111231-15374-1fve7h4.js:839:17) at next (/tmp/execjs20111231-15374-1fve7h4.js:943:37) at Object.semicolon [as 1] (/tmp/execjs20111231-15374-1fve7h4.js:986:38) at prog1 (/tmp/execjs20111231-15374-1fve7h4.js:1527:28) at simple_statement (/tmp/execjs20111231-15374-1fve7h4.js:1123:35) at /tmp/execjs20111231-15374-1fve7h4.js:1031:35 at /tmp/execjs20111231-15374-1fve7h4.js:1510:32

like image 919
justingordon Avatar asked Dec 21 '22 04:12

justingordon


2 Answers

You will probably find that one of you js files has a syntax error somewhere. This could be a missing semicolon at the end of a block, or some other minor problem. Often browsers will still load the js and it will work, but uglifier cannot compress it with those errors. I would start looking in the localisation files first.

One way to find out which file contains the error is to re precompile locally with a minimal set of files and add things one by one until it breaks. If it is due to a missing semicolon, the breakage will the second-last file you added.

like image 186
Richard Hulse Avatar answered Jan 14 '23 03:01

Richard Hulse


Mine precompiled after I removed a stray "debugger" statement. Woops.

like image 31
TheWorkerAnt Avatar answered Jan 14 '23 03:01

TheWorkerAnt