kimroen / ember-cli-coffeescript

Adds precompilation of CoffeeScript files and all the basic generation types to the ember generate command.
MIT License
72 stars 49 forks source link

Support coffeescript 2 #144

Open toovy opened 7 years ago

toovy commented 7 years ago

Hi there,

Coffeescript 2 is getting real: http://coffeescript.org/v2/ (https://github.com/coffeescript6/discuss/issues/80).

It supports many ES2015 features. The reason why I would love to see it in ember is the async/await and generator support. The most important reason though is that the nasty import/export hacks using backticks to write plain JS is not needed any more:

export default Ember.Route.extend

  model: ->
    @foo()

  foo: ->
    a = await @bar()
    b = await @biz()
    "#{a}-#{b}"

  bar: ->
    new Ember.RSVP.Promise (resolve) ->
      setTimeout ->
        resolve("baz")
      , 2000

  biz: ->
    new Ember.RSVP.Promise (resolve) ->
      setTimeout ->
        resolve("biz")
      , 2000

I've made a quick test and it is simple to get it running by altering only a few lines of ember-cli-coffeescript and broccoli-coffee:

But I think this needs more discussion on a meta level, as Coffeescript 1 runs in every browser, but Coffeescript 2 needs transpilation. Thankfully Ember includes Babel, so that is also pretty easy to accomplish:

var app = new EmberApp(defaults, {
    'ember-cli-babel': {
      includePolyfill: true
    }
  });

That's the reason why I did not just create pull requests. Maybe new repos should be created, called ember-cli-coffeescript-2 and babel-coffee-2? That would ensure that there is a clear distinction between old Coffeescript (1) and ES2015 Coffeescript (2).

Looking forward to hear your opinions.

BR, toovy

boris-petrov commented 7 years ago

+1 I would also love to see that - I want async/await!

@toovy - btw, you can drop the backticks even now - with CoffeeScript 1.12.5. :)

auvipy commented 7 years ago

can we test it in another branch?

auvipy commented 7 years ago

1.12.6 released

boris-petrov commented 7 years ago

@kimroen - can you help on this one? We all would like to use CoffeeScript 2!

nikdojo commented 6 years ago

Guys, do you have any updates?

kosmonaffft commented 6 years ago

Is this project still alive?