Search code examples
ember.jsember-cliecmascript-6

Does ember-cli support object literal shorthands?


UPDATE 2

I've filed an issue at the ember-cli repo describing simple steps to reproduce the issue: https://github.com/ember-cli/ember-cli/issues/4015.


UPDATE

This is related to using in-repo-addons. The ember compiler does not choke when using this syntax in your regular app. I will be filing a bug report at http://github.com/ember-cli/ember-cli shortly with steps to reproduce and will link back to the issue here when it is ready.


I caught the bug for es6 and started using the object literal method shorthand:

import Ember from 'ember';

export default Ember.Component.extend({
    didInsertElement() {
        // stuff I want to do once we're in the DOM
    }
})

but it chokes when running ember build --environment production. Thoughts?

Build failed.
Unexpected token punc «(», expected punc «:»

Solution

  • In Repo Addons (currently) require ember-cli-babel as a dependency.

    $ cd lib/<your addon>
    $ npm install ember-cli-babel --save
    $ cd ../..
    $ ember build --environment production