adobe-research / theseus

A pretty darn cool JavaScript debugger for Brackets
Other
1.34k stars 69 forks source link

Support CoffeeScript #11

Open wmertens opened 11 years ago

wmertens commented 11 years ago

It would be great if Theseus could support coffeescript. I converted node-theseus to coffeescript with js2coffee (remove the hashbang first) and it then ran CoffeeScript files just fine but Brackets doesn't know what to do with them.

If I compile the coffeescript first to JS it works but then all dependencies need to be converted as well, plus it clutters up the project directory.

Ideally Theseus has native support for showing debugging CoffeeScript but just showing an on-the-fly compiled version of the script would already be very nice.

alltom commented 11 years ago

+1. I just don't know how to do it yet (and there are some bigger issues to address at the moment).

node-theseus uses the esprima library to instrument pure JavaScript code. We could keep doing that and use a source map in Brackets to tell what lines of CoffeeScript correspond to which JavaScript functions, or use another library for rewriting the CoffeeScript directly. I'm not sure which approach is better yet.

ElliotChong commented 11 years ago

Source maps may keep the implementation more flexible, such as built-in support for TypeScript or any other new transpiler that comes along.

tiye commented 10 years ago

I want it too.

giodamelio commented 10 years ago

:thumbsup: This would be super cool.

cooolbasha commented 10 years ago

is there any update on this

alltom commented 10 years ago

No, not yet. :\

joepie91 commented 9 years ago

I'd definitely like this as well, so that I can debug (server-side) CoffeeScript from Brackets.

joshuajabbour commented 9 years ago

:+1: This would also be awesome to allow for using Babel or other ES6 compilers.

alltom commented 9 years ago

Awesome enough to supply a patch? :kissing_closed_eyes:

m1sta commented 9 years ago

+1 for debugging with sourcemaps.

m1sta commented 9 years ago

The number of people using one or more of babel, traceur, coffeescript, sweetjs, or something else in the rest if the altjs world is already pretty substantial, and it's growing.

alltom commented 9 years ago

For sure! Nobody's happy with plain JavaScript these days. This just happens to be a massive undertaking. :\

m1sta commented 9 years ago

node-theseus uses the esprima library to instrument pure JavaScript code. We could keep doing that and use a source map in Brackets to tell what lines of CoffeeScript correspond to which JavaScript functions.

@alltom I think this is exactly the direction that should be taken. Brackets with semantic colouring, sourcemap recognition, and theseus, would then work beautifully with all compile-to-js languages (maybe)!

m1sta commented 9 years ago

Should this be tracked as an issue in Brackets directly?

alltom commented 9 years ago

I think this is the right place.

m1sta commented 9 years ago

I've never looked at the source code to Brackets or Theseus but I've had a little look at https://github.com/mozilla/source-map/ and it seems to make sense. Where would you recommend I start looking within the brackets or theseus source code if I want to take a stab at wiring things up?

alltom commented 9 years ago
  1. node-theseus uses Module._extensions['.js'] (deprecated) to rewrite JavaScript source code when it's require()'d. If the non-JS scripts are dynamically compiled to JavaScript using a similar method, then this needs to be made to cooperate with it.
  2. During instrumentation, fondue stores the locations of every function, parameter, call site, etc in an array of nodes. If there is a source map present in the file, instead of storing node.loc.start, node.loc.end, and options.path, it should run those locations backwards through the source map and store the locations from the original CoffeeScript or whatever.

I think these are the main integration points.

alltom commented 9 years ago

Ah, I just remembered that fondue/master is in an unstable state. If you want to work off the 0.6.1 release at adobe-research/fondue@f7a3bc6 then I'd have no problem porting it forward for you. (The new code is much easier to follow, but hasn't gone through the same hardening process as the 0.6.1 release.)