Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preferred way of working with ES6 modules and CoffeeScript

I have been playing around with the ember-app-kit project and I was running into some issues with ES6 modules and CoffeeScript keywords.

An example of the javascript I'm talking about is:

import Resolver from 'resolver';

and

export default App;

I have been able to bypass the coffeescript compiler errors by escaping lines with "export" and "import" with '`' backticks.

I was getting confused as to how to escape js like this:

export default Ember.Component.extend({
  classNames: ['pretty-color'],
  attributeBindings: ['style'],
  style: function(){
    return 'color: ' + this.get('name') + ';';
  }.property('name')
});

Does anyone know if there is a preferred way of working with CoffeeScript and ES6 modules?

like image 356
Sean McCleary Avatar asked Jan 13 '14 16:01

Sean McCleary


1 Answers

You can assign the component to a var and then escape the export of this var. Like this:

MyComponent = Ember.Component.extend
  classNames: ['pretty-color']
  attributeBindings: ['style']
  style: (->
    "color: #{@get('name')};"
  ).property('name')

`export default MyComponent`
like image 60
bazzel Avatar answered Oct 24 '22 00:10

bazzel