Skip to content

Commit

Permalink
Transform async functions with regenerator (#332)
Browse files Browse the repository at this point in the history
* Transform async functions with regenerator

Remove `transform-async-to-generator`, which to my understanding is meant
to be used in environments that support generators natively.

Because we're compiling generators to ES5 anyway, we can simply use
`regenerator` to transform async functions too, which results in
slightly simpler output and only uses the regenerator runtime instead
regenerator runtime + _asyncToGenerator Babel helper.

* Add babel-plugin-transform-regenerator

* Use dependencies with an exact version
  • Loading branch information
fson authored and gaearon committed Aug 2, 2016
1 parent 01eeb61 commit 6ea7ec5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config/babel.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ module.exports = {
],
plugins: [
require.resolve('babel-plugin-syntax-trailing-function-commas'),
require.resolve('babel-plugin-transform-async-to-generator'),
require.resolve('babel-plugin-syntax-async-functions'),
require.resolve('babel-plugin-transform-class-properties'),
require.resolve('babel-plugin-transform-object-rest-spread'),
require.resolve('babel-plugin-transform-regenerator'),
[require.resolve('babel-plugin-transform-runtime'), {
helpers: false,
polyfill: false,
Expand Down
3 changes: 2 additions & 1 deletion config/babel.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ module.exports = {
],
plugins: [
require.resolve('babel-plugin-syntax-trailing-function-commas'),
require.resolve('babel-plugin-transform-async-to-generator'),
require.resolve('babel-plugin-syntax-async-functions'),
require.resolve('babel-plugin-transform-class-properties'),
require.resolve('babel-plugin-transform-object-rest-spread'),
require.resolve('babel-plugin-transform-react-constant-elements'),
require.resolve('babel-plugin-transform-regenerator'),
[require.resolve('babel-plugin-transform-runtime'), {
helpers: false,
polyfill: false,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
"babel-eslint": "6.1.2",
"babel-jest": "14.1.0",
"babel-loader": "6.2.4",
"babel-plugin-syntax-async-functions": "6.8.0",
"babel-plugin-syntax-trailing-function-commas": "6.8.0",
"babel-plugin-transform-async-to-generator": "6.8.0",
"babel-plugin-transform-class-properties": "6.11.5",
"babel-plugin-transform-object-rest-spread": "6.8.0",
"babel-plugin-transform-react-constant-elements": "6.9.1",
"babel-plugin-transform-regenerator": "6.11.4",
"babel-plugin-transform-runtime": "6.12.0",
"babel-preset-es2015": "6.9.0",
"babel-preset-es2016": "6.11.3",
Expand Down

0 comments on commit 6ea7ec5

Please sign in to comment.