SourceMaps in Chrome allow debug of any source language compiled to JS (plus.google.com)
A small demo of the SourceMaps support in Chrome Dev Tools which allows languages which are cross compiled to Javascript (Java, CoffeeScript, Objective-J, ClotureScript, even minified-JS) to be source level debugged in the browser.
Firefox will also be sporting support for SourceMaps.
32 comments
[ 110 ms ] story [ 1879 ms ] threadThe talk emphasizes debugging js as output of another language. But did I understand correctly that it can be used to debug js programs directly? Makes sense and would be awesome.
Great job - again.
The demo I showed also is using SuperDevMode for GWT, which dramatically speeds up the compile. Notice, I compile a project (the Mail sample) of several hundred Java source files in less than 2 seconds.
That would be a useful tool in reverse engineering.
It's reached a demoable state, but is not complete and can't be landed: it was worked on by an intern and the intern has now gone back to life.
It's a pretty simple but extremely useful idea. To use your example, the CoffeeScript compiler knows exactly which bits of generated JavaScript correspond to exactly what bits of CoffeeScript code, so the compiler can output a mapping that says "these lines of JavaScript are the result of this line of CoffeeScript...so when you step through this CoffeeScript line, execute these X lines of JavaScript, if an error occurs in these X lines of JavaScript show there error as occurring on line Y of the CoffeeScript code.
I haven't done much front-end lately so I'm not sure what if any the CoffeeScript compiler has in terms of generating source maps, but if browsers are supporting it I imagine it won't be long if it's not here already.
How accurate does the source position information have to be? I don't think the CoffeeScript lexer can output column numbers (at least it didn't last time I checked) and the re-writing stage might give them a little trouble. Should be doable though.
Guess I should head over to github and see how they're doing and start reading the SourceMap spec.
https://github.com/jashkenas/coffee-script/issues/558
Great move guys!
Maybe you're thinking about how the Traceur ES6 to JavaScript compiler outputs SourceMap information?