From 6ea7ec5a4bd3cce0c4d1af01936738e9b7eb58f3 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Wed, 3 Aug 2016 00:44:09 +0100 Subject: [PATCH] Transform async functions with regenerator (#332) * 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 --- config/babel.dev.js | 3 ++- config/babel.prod.js | 3 ++- package.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/babel.dev.js b/config/babel.dev.js index 291698b886e..2c41ed9149a 100644 --- a/config/babel.dev.js +++ b/config/babel.dev.js @@ -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, diff --git a/config/babel.prod.js b/config/babel.prod.js index 7e112c4b55d..754302a20d9 100644 --- a/config/babel.prod.js +++ b/config/babel.prod.js @@ -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, diff --git a/package.json b/package.json index 4f49a5c89c2..15eaec52374 100644 --- a/package.json +++ b/package.json @@ -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",