Configure ember-cli version >= 3 to use native async/await and generators


#1

How to configure ember-cli version >= 3 to use native async/await and generators without babel regenerator polyfill and async/await transpiling


#2

If you change your config/targets.js to only include browsers with native async/await, it should do what you want.


#3

The default ember-cli@3+ blueprint already allows for native async/await without transpilation while in develoment (see config/targets.js of a ember new my-app output for ember-cli@3.1.0).

I also wrote a blog post about async/await configuration a little while back (back when configuration was not automatically setup for a new app by default) that you might find interesting: http://rwjblue.com/2017/10/30/async-await-configuration-adventure/.


#4

In order to better debug asynchrony in tests I have an environment flag in my config/targets.js that looks something like this:

let browsers = [
  '> 5%',
  'ie 11',
  'last 2 Edge versions',
  'last 2 Chrome versions',
  'last 2 Firefox versions',
  'last 2 Safari versions'
];

if (process.env.EMBER_TARGET_CHROME) {
  browsers = ['last 1 Chrome versions'];
}

module.exports = {
  browsers
};

Which allows me to set the flag EMBER_TARGET_CHROME which uses only latest Chrome (which has async/await natively).

Since my CI does not set this flag I’m still safe in the knowledge that the browsers I support are handled correctly. But I gain the advantage of seeing actual async/await in my test suite which is considerably easier to reason about.

I have a few aliases setup to automatically set that flag when I run commands (for example alias ets=EMBER_TARGET_CHROME=true ember test --serve).

Hope it helps!