Closure Mode for CoffeeScript

258 views
Skip to first unread message

Michael Bolin

unread,
Aug 5, 2011, 4:04:51 PM8/5/11
to Closure Library Discuss
I put together a Closure Mode for CoffeeScript that you can play with
here:

http://bolinfest.com/coffee/

I wasn't aware of UberScript (https://github.com/jstrachan/coffee-
script/blob/master/TypeAnnotations.md) until I was just about done, so
I felt like I should see my thing through and publish it anyway, but
perhaps efforts could be combined. If this can become an effective way
to write Closure Library code, I would definitely add support for it
in plovr.

Happy Friday,
Michael

André Moraes

unread,
Aug 9, 2011, 7:40:30 AM8/9/11
to closure-lib...@googlegroups.com
MIchael, first of all, plovr made me look to closure-library with
better eyes than the last time I used, so thanks for that.

Now my question,
The generated source maps after the compilation step maps to the
coffescript or to the translated coffescript->javascript?

--
André Moraes
http://andredevchannel.blogspot.com/

John Lenz

unread,
Aug 9, 2011, 1:07:44 PM8/9/11
to closure-lib...@googlegroups.com
Micheal, the one thing I see missing is a discussion regarding exports and externs?  Is it possible to export a coffee script methods?

Michael Bolin

unread,
Aug 10, 2011, 10:28:04 AM8/10/11
to Closure Library Discuss
If you're talking about plovr, then I believe the generated source
maps map to the translated coffeescript->javascript. What you are
talking about could be done as future work, though I think special
handling would have to be done to know which subset of the production
JS was from CoffeeScript and which subset was hand-written or was
generated from Closure Templates.

Out of curiosity, what are you using the source maps for? The Closure
Inspector? Debugging stack traces on the server? Something else?

Michael Bolin

unread,
Aug 10, 2011, 10:31:37 AM8/10/11
to Closure Library Discuss
Well, you could just call goog.exportSymbol/exportProperty directly in
CoffeeScript. Or you could create a JS file with the equivalent calls,
if you're more comfortable with that.

As previously discussed, I'm not the biggest fan of an @export
annotation that always exports (http://code.google.com/p/closure-
compiler/issues/detail?id=50). Unfortunately, I haven't had time to
implement how I think it should work, either, but when I do, I'll keep
CoffeeScript in mind!

John Lenz

unread,
Aug 10, 2011, 11:44:24 AM8/10/11
to closure-lib...@googlegroups.com
I was thinking more specifically about the "quoted/unquoted" rules.  I don't use coffeescript myself (I read a tutorial) so I'm unclear on whether access type distinction is preserved.

In general I'm pretty excited about it being a front end for the Closure Compiler (this + UberScript's type additions).  I'm hoping it is possible to have coffeeScript generate a JsonML AST with source location information (which I believe would need to be added) to enable source mapping (the alternative requires using Rhino and building the compiler's AST directly using Java calls).

André Moraes

unread,
Aug 10, 2011, 12:23:01 PM8/10/11
to closure-lib...@googlegroups.com
Rigth now I am not using source maps because the app is still in development.
But when it comes to production maybe this could be usefull.

It's a js 2d game engine using Canvas to render graphics, is more of a
experiment than a real project.
But if the tests show some good results this might become a real project.

Reply all
Reply to author
Forward
0 new messages