theseus icon indicating copy to clipboard operation
theseus copied to clipboard

Support CoffeeScript

Open wmertens opened this issue 12 years ago • 18 comments

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.

wmertens avatar Jun 12 '13 13:06 wmertens

+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.

alltom avatar Jun 12 '13 19:06 alltom

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

ElliotChong avatar Jul 06 '13 16:07 ElliotChong

I want it too.

tiye avatar Aug 29 '13 11:08 tiye

:thumbsup: This would be super cool.

giodamelio avatar Sep 03 '13 17:09 giodamelio

is there any update on this

cooolbasha avatar Feb 21 '14 21:02 cooolbasha

No, not yet. :\

alltom avatar Feb 21 '14 22:02 alltom

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

joepie91 avatar Jul 20 '14 23:07 joepie91

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

jfexyz avatar Mar 25 '15 23:03 jfexyz

Awesome enough to supply a patch? :kissing_closed_eyes:

alltom avatar Mar 26 '15 02:03 alltom

+1 for debugging with sourcemaps.

m1sta avatar Mar 31 '15 14:03 m1sta

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.

m1sta avatar Mar 31 '15 14:03 m1sta

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

alltom avatar Apr 01 '15 03:04 alltom

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 avatar Apr 01 '15 10:04 m1sta

Should this be tracked as an issue in Brackets directly?

m1sta avatar Apr 01 '15 10:04 m1sta

I think this is the right place.

alltom avatar Apr 01 '15 12:04 alltom

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?

m1sta avatar Apr 01 '15 13:04 m1sta

  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 avatar Apr 01 '15 13:04 alltom

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.)

alltom avatar Apr 01 '15 13:04 alltom