Topic: Rails3.1rc4: CoffeeScript Precompilation Breaks in/for Production

I'm having issue getting coffeescripts to precompile (i.e. 'rake assets:precompile') correctly for production (meaning they are not doing so correctly at all).  I have this in my app/javascripts:

application.js          (application code)
application_test.js   (Jasmine tests for application code)
base.js                   (vendor and third-party frameworks)
base_test.js            (vendor frameworks for testing, i.e. Jasmine)

We'll look at two. Examples of application and base:

// application.js
//= require_self
//= require_tree ../../models
//= require_tree ../../controllers
//= require_tree ../../views

// .... more application specific code ....
// base.js
//= require jquery
//= require jquery_ujs 
//= require_tree ../../../vendor/assets/javascripts
//= require_tree ../../../vendor/sprockets

// ... overrides of third-party stuff as needed ...

Base.js compiles just fine because all of its required files are plain Javascript.  Application will compile the first CoffeeScript it hits, include it, and then not include any others. 

So for example, I'm using a client-side Javascript MVC (Spine.js) and have a model called Assignment (assignment.js.coffee) that is the first coffeescript file in app/models (sitting right next to my assignment.rb Rails model).  The coffeescript Assignment is compiled and included in application.js (from the "require_tree ../../models" line) but then all my other models in that folder are not, nor any from the controllers or views require directives.  If I require another plain js file in application.js, it is included just fine.  And on top of this, my application_test.js and base_test.js file (which also include coffeescript files) will include the code from the Assignment model, even when making require directive for the ../../models folder! It's as if the coffeescript compiler gets stuck on the first file is compiles.

In development, this all works fine.  When I go to precompile it or run in/for production mode, it breaks.  That is, I run this command: "bundle exec rake assets:precompile RAILS_ENV=production".  And just for completeness, my production.rb has this:

  config.assets.precompile += %w( application_test.js base.js base_test.js base.css )

Thoughts? I'm using Rails 3.1 rc4 with sprockets 2 beta.10.  Why this is not working baffling me.

Last edited by onedanshow (2011-06-21 13:26:13)

Re: Rails3.1rc4: CoffeeScript Precompilation Breaks in/for Production

It breaks. But what stack trace/errors does it give when it breaks?