rainforestapp / decaf

Coffeescript to ES.next transpiler. Now maintained over at
https://github.com/juliankrispel/decaf
MIT License
106 stars 10 forks source link

Does decaf have a cli? #8

Closed systeminsightsbuild closed 8 years ago

systeminsightsbuild commented 8 years ago

I don't want a runtime transform, but rather fully convert the coffeescript (even if that means some post manually work).

Does decaf support that mode?

karlhorky commented 8 years ago

I would like to see this documented too.

juliankrispel commented 8 years ago

A cli feature is on the short-term roadmap, @systeminsightsbuild @karlhorky how do you expect using a tool like that? Should it transform your files or create new ones?

I know it seems simple enough but I'd like to hear use-cases to design this well :)

eventualbuddha commented 8 years ago

This is exactly why I created decaffeinate. The intent is to completely replace your .coffee files with .js files written in ES6. I also created esnext in part to further modernize the source, for example translating var foo = require('foo'); to import foo from 'foo';.

My suggestion would be that a CLI for decaf should write .js files next to the .coffee files it processes, and having a "process everything in this directory" mode would be great (decaffeinate doesn't have that yet). I'd like to be able to convert a whole project at once, preserving as much of the original formatting/comments/etc as possible, which obviously necessitates #1 but also means preserving things like this:

$('.form')
  .find('.button')
    .attr('enabled', false)
  .end()
  .find('.input')
    .addClass('invalid');

That problem is the original reason I took the approach I did with decaffeinate (string edits based on AST). Using recast as a printer is a good approach in that you'll always end up with valid JS (not something decaffeinate always does) and the transformation is more straightforward (I'm not very proud of how messy decaffeinate's source is), but it makes the above into a harder problem. Trade-offs are a bummer :-1:

backspaces commented 8 years ago

Yup, I'd like to be able to translate my coffee to es6, and leave the coffee behind .. es6 along with the JS Standard Style has made JS good enough. I realize this is not the goal of decaf but...

Yes, I'll miss several features, but at this point, I think Babel will be in our code for ever, modules for example, and may be all we need for some missing features.

A question: does decaf plan to translate CS Classes to es6 Classes? There are some differences, but I'm fine giving up some corner cases for convergence with the rest of the JS world!

-- Owen

juliankrispel commented 8 years ago

@backspaces that is exactly the (original) goal of decaf.

Classes are supported right now yes!

please have a look at the test suite for more info of what exactly is supported.

juliankrispel commented 8 years ago

decaf now has a cli :)