is RubyMine coffeescript debugger works only with rails?

Hi, I got coffee script debugger work somehow on rails project, but right now i'm working on single coffee-script code compiled via sprockets and a simple rack server. Is debugger gonna work with it? Because I can t get it work - the console output redirection to rubymine works but no breakpoint is working - it just draws it as passed one. I saw on thouse extension for source map generating and found there such code:

require "coffee-script-redux-debugger/version"
require "coffee-script-redux-debugger/source_map_comment"
require "sprockets"
require 'sprockets/processing'
require 'sprockets/server'
require 'coffee-script-redux-debugger/coffee_script_redux'
module Sprockets
  class CoffeeScriptReduxDebuggerClass < ::Rails::Railtie
    initializer "coffee.script.redux.debugger", :after => "sprockets.environment" do |app|
      app.assets.register_postprocessor 'application/javascript', SourceMapComment
    end
  end

As you might guess I dont have any ::Rails::Railtie, but do have sprockets. So will it work for me?
Thx
1 comment

sandric mora, to make coffee script debugger work, you need to provide CoffeeScript file content, compiled JavaScript file content and SourceMap file content.

For Ruby on Rails application with created gem that does all this work. In your case there are two possible solutions.

The first solution is each time you change file fileName.coffee file call CoffeeScriptRedux compiler to create fileName.map.js file (SourceMaps) and add to the end of generated fileName.js file comment:
{code}
//@ sourceMappingURL=fileName.js.map
{code}
(The last thing is required to say debugger where to look for source map file)

The second solution is to put all these things into preprocessor that generates .js file by .coffee in your application. Please take a look to coffee-script-redux-debugger project on GitHub. Here we inserted sourceMap generation and "//@ sourceMappingURL=" comment addition to Sprocket (gem that used by Rails to work with assets)


In file lib/coffee-script-redux-debugger.rb we say that in case of '.coffee' extension we should return our file without chagnes, if extension is '.map' we should call CoffeeScriptRedux to generate source maps and at last if file type is JS we should call CoffeeScriptRedux to compile .coffee file to .js.

0

Please sign in to leave a comment.