This guide is for developers who already know Ember, and who want to learn the new concepts introduced by Octane, Ember's first Edition, which was released in December 2019.
If you're new to Ember, we recommend starting with the Quick start and Tutorials.
Ember Octane introduced a programming model in Ember that brought major gains in productivity and performance, incrementally via a series of minor (non-breaking) releases. This allows for new apps to have the best features enabled automatically, while teams working on existing apps can migrate over time and continue updating their app's dependency versions.
Here are some of the core features in Octane:
async/await) for authoring asynchronous code....attributes.<AngleBracket> syntax for better readability.Just as important is what was removed from the Ember experience. These features below will keep working through the rest of Ember 4, but you won't have to use them if you don't want to.
These have been replaced or made optional in Octane:
extend(), create(), and mixins, and use Native Classes instead.@tracked.tagName, classNameBindings, etc. Now, there's no wrapping element.Again, note that these features will continue to work for apps that need them. An edition is not a breaking change, just a minor release. But for someone starting a new Ember app today, this is complexity they can safely skip learning.
To create a new app that has every Octane feature enabled, first make sure you have the latest Ember CLI version installed:
npm uninstall ember-cli
npm install -g ember-cli
Then, create your app:
ember new my-app-name
The remaining sections in this guide will go into details about how to upgrade each individual feature. There's a lot to learn here, but remember, you can gradually adopt these features in existing apps. Everything you used to do will also work all the way through the rest of Ember 3, since Ember follows SemVer strictly.
If you need any help, check out the chat and forums. If you spot something to improve in this guide, you can help out by filing an issue or a PR. Thank you!
There are two areas of focus for upgrading to Octane: learning, and implementing.
We recommend that all developers go through the Quick Start Tutorial to learn the fundamentals of Octane, and then the main Tutorial.
Along the way, you might need to study up on Native JavaScript Classes too. Otherwise, it may be confusing about which parts of code are special to Ember, and which are not.
If you work on a team of developers, it may be useful to have one developer go through the tutorials, try doing a small thing, and then demo that to the rest of the team. After everyone has had a chance for hands-on learning, schedule a meeting to plan how you want to proceed. By design, migrating to Octane can be done in pieces. It doesn't require a big-bang refactor. If you need advice, visit the forums or the Ember Discord (in Discord you can use the #topic-octane-migration channel).
These steps assume your app is on version 4.x of Ember. If you are on an older version, please choose it from the dropdown in the sidebar.
@glimmer/component and @glimmer/tracking installed in your app.ember g component will give you just a test and a template. Adding -gc to the command will generate the JavaScript class to go with it. Try adding a button with an action. If you need to generate a classic component, you can still make one with ember g component -cc
If you need help along the way, visit the Ember Community chat and forums.
Ember Octane introduces new syntax and patterns centered around using native JavaScript classes and templates that focus on HTML. While your older style components and templates will keep working, eventually you should refactor existing code so that your app follows one main programming model, not a mixture of Octane and Classic. Following a refactoring plan will help with onboarding new developers, and minimize flipping back and forth between different versions of the Ember Guides.
There's no one-size-fits-all strategy, but here is a checklist you can adapt, once you're familiar with what Octane has to offer:
ember generate component my-component -gc. They can coexist in the same app with older components. Meanwhile, go through the rest of the steps below.this in your templates, by running the ember-no-implicit-this-codemod. Component behavior should not change.{{my-component}}) to Angle Brackets (<MyComponent />), using the ember-angle-brackets-codemod. Angle Brackets are feature of Ember since 3.4 that does not change a component's behavior. Read the Angle Bracket Syntax guide for some examples and more in-depth information.ember-native-class-codemod on your non-component JavaScript files.ember-native-class-codemod for all remaining components. This will turn them into components that import from @ember/component, retaining all the same APIs that classic components have, but just represented in a Native Class syntax. Then, following a similar pattern as option number one, you could convert them to import from @glimmer/component as you work. The advantage is that everyone gets used to working with Native Classes right away. The disadvantage is that the visual differences between a Native Class @ember/component and a @glimmer/component are subtle, and time could easily be lost to mistakes like trying to use didInsertElement on the @glimmer/component.
© 2022 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://guides.emberjs.com/v4.9.0/upgrading/current-edition