From 40ac80a3e9a2a87c6aabdcb04ace241bd36410f1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 14 Oct 2016 18:03:22 +0100 Subject: [PATCH] Replace stage & es2017 with specific plugins Also sort out regenerator runtime as it turns out importing babel-polyfill in your code is insufficient if using webpack because it's imported too late, so use both that and regenerator-runtime. Sigh. --- .babelrc | 3 ++- package.json | 4 +++- src/vector/index.js | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.babelrc b/.babelrc index fb2f03c450..ceeb850bea 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,4 @@ { - "presets": ["react", "es2015", "es2016", "es2017", "stage-2"] + "presets": ["react", "es2015", "es2016"], + "plugins": ["transform-class-properties", "transform-object-rest-spread", "transform-async-to-generator", "transform-runtime"] } diff --git a/package.json b/package.json index 417f0d775a..d666aa3596 100644 --- a/package.json +++ b/package.json @@ -66,8 +66,10 @@ "babel-core": "^6.14.0", "babel-eslint": "^6.1.0", "babel-loader": "^6.2.5", + "babel-plugin-transform-async-to-generator": "^6.16.0", + "babel-plugin-transform-class-properties": "^6.16.0", + "babel-plugin-transform-object-rest-spread": "^6.16.0", "babel-plugin-transform-runtime": "^6.15.0", - "babel-polyfill": "^6.5.0", "babel-preset-es2015": "^6.16.0", "babel-preset-es2016": "^6.16.0", "babel-preset-es2017": "^6.16.0", diff --git a/src/vector/index.js b/src/vector/index.js index bb33f656c5..b33693f6b4 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -18,10 +18,13 @@ limitations under the License. // for ES6 stuff like startsWith() that Safari doesn't handle // and babel doesn't do by default -// Note we use this, not the babel transform-runtime plugin +// Note we use this, as well as the babel transform-runtime plugin // since transform-runtime does not cover instance methods // such as "foobar".includes("foo") which bits of our library -// code use. +// code use, but the babel transform-runtime plugin allows the +// regenerator runtime to be injected early enough in the process +// (it can't be here as it's too late: the alternative is to put +// the babel-polyfill as the first 'entry' in the webpack config). // https://babeljs.io/docs/plugins/transform-runtime/ require('babel-polyfill');