4
votes

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 «:»
2
Can you post a gist of your package.json to see what versions of dependencies there are? Also try naming the function something different from didInsertElement and then add the event like this: somethingOnDidInsertElement(){ }.on('didInsertElement');Michael Benin
huh. testing on a blank install. it might be related to the code being in an in-repo-addon. standbyeBrian Whitton
What version of npm/node are you using?Michael Benin
Also could you could give a gist of your brocfile?Michael Benin
Try calling this._super() inside the didInsertElement()Michael Benin

2 Answers

0
votes

Ember-cli uses babel which does support object literal shorthands.

See:

https://babeljs.io/docs/learn-es6/

0
votes

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