Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
Last active September 29, 2015 13:45
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesarosen/c005cf384a62709edf82 to your computer and use it in GitHub Desktop.
Save jamesarosen/c005cf384a62709edf82 to your computer and use it in GitHub Desktop.
Upgrading to Ember-CLI 0.2.0

I upgraded a small app from ember-cli from 0.1.11 to 0.2.0 today. It took a couple hours. Here are some notes.

Prep

First, I read the release notes.

ember init

I recommend committing your changes right before running ember init. That way, you can accept all the overwrites and easily discard the ones you don't want. kellyselden maintains a repo called ember-cli-output that tracks the changes in what ember init generates over time. You can find the v0.2.0 changes here.

bower install

After selectively committing those changes, I had to also make the following changes to bower.json:

-    "ember": "v1.10.0-beta.4",
+    "ember": "v1.10.0",
-    "ember-data": "1.0.0-beta.14.1",
+    "ember-data": "1.0.0-beta.15",
-    "ember-qunit": "0.1.8",
+    "ember-qunit": "0.2.8",
-    "ember-qunit-notifications": "0.0.5",
+    "ember-qunit-notifications": "0.0.7",

Then I ran rm -rf bower_components && bower install to get the new versions.

Ember-Data Package Problems

Whenever you run ember build, ember serve, or ember test, you'll see

The package `ember-data` is not a properly formatted package, we have used a fallback lookup to resolve it at `/Users/jamesarosen/Code/Tango/node_modules/ember-data`. This is generally caused by an addon not having a `main` entry point (or `index.js`).

That's a known issue. You can safely ignore it for now.

JSHint

I found JSHint to be picker about unused variables after this upgrade. Thus, I had to change things like

import Ember from "ember";

 export default Ember.Route.extend({
-  beforeModel: function(transition) {
+  beforeModel: function() {
     if (this.get('session.signedIn')) {
       this.replaceWith('index');
     }
  }
});

Test Changes

The upgrade to ember-qunit comes with an upgrade to qunit itself. The most significant changes are that module, test, assert, and ok are no longer defined as globals.

For tests that aren't using moduleForModel or moduleForComponent, import module and test:

import { module, test } from "qunit";

assert and ok now hang off of an assert object, which is passed in to the test callback:

test('foo returns "bar"', function(assert) {
  assert.equal(subject.get('foo'), "bar");
});

Template Compilation in Tests

I had some component tests that did runtime template compilation:

var component;

moduleForComponent('popover-group', 'PopoverGroupComponent', {
  setup: function() {
    component = this.subject({
      template: Ember.Handlebars.compile('content')
    });
  }
});

ember-template-compiler.js is no longer included in the app by default. We don't use it in dev or when compiling for production. To add it just for the test environment, I added it in Brocfile.js:

+app.import({
+  test: 'bower_components/ember/ember-template-compiler.js'
+});

I've opened an issue about this. My approach isn't the best, but it works for now.

@domchristie
Copy link

Re: template compilation: I have been running into this issue in the development environment, too. So the fix was:

app.import('bower_components/ember/ember-template-compiler.js');

@samselikoff
Copy link

I believe if you set unused: "vars" in .jshint, you can define unused params without errors.

@jherdman
Copy link

I found JSHint to be picker about unused variables after this upgrade.

"Pickier" ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment