wycats / rake-pipeline-web-filters

MIT License
116 stars 36 forks source link

CoffeeScript causing odd problems #18

Closed ahawkins closed 12 years ago

ahawkins commented 12 years ago

Here is my asset file

match "**/*.handlebars" do
  handlebars
end

match "**/*.coffee" do
  coffee_script
end

match "{javascripts,vendor/javascripts}/**/*.js" do
  minispade :module_id_generator => proc { |input|
    if input.path =~ /vendor/
      File.basename input.path, '.js'
    else
      input.path.gsub(/javascripts\//, "todos/").gsub(/\.js$/, '')
    end
  }

  concat "application.js"
end

match "**/*.{css,scss}" do
  sass

  concat "application.css"
end

match "public/**/*" do
  copy do |input|
    input.sub(/public\//, '')
  end
end

match "images/**/*" do
  copy
end

I have files like 'app/vendor/javascripts/backbone.js'. I'd like those turned to minispade modules named 'backbone'. This works sometimes. I've been trying to track down the problem. The minispade modules are being written as: vendor/todos/jquery.

Seen here:

adam at mba : ~/projects/frontend_server_example[master*] % grep jquery public/application.js        
});minispade.register('todos/boot', function() {minispade.require('jquery');
});minispade.register('vendor/todos/jquery', function() {/*!

Now after much debugging, I found the problem. I commented out the coffeescript section (I have no cofeescript files) and voila! Much to my surprise, the generated javascript is different:

adam at mba : ~/projects/frontend_server_example[master*] % grep jquery public/application.js        
});minispade.register('todos/boot', function() {minispade.require('jquery');
});minispade.register('jquery', function() {/*!

^ That's what I expect should happen, but it doesn't happen when coffescript is there.

I really have no clue what is happening with this. It's a very odd bug from my point of view. So apparently the file names are changing even though the CS filter isn't being used?

ahawkins commented 12 years ago

This caused by the temp dir existing. If the temp dir is wiped, all is good.