Skip to content

Commit d04201d

Browse files
committed
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.
1 parent 82de2ca commit d04201d

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["react", "es2015", "es2016", "es2017", "stage-2"]
2+
"presets": ["react", "es2015", "es2016"],
3+
"plugins": ["transform-class-properties", "transform-object-rest-spread", "transform-async-to-generator", "transform-runtime"]
34
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@
6666
"babel-core": "^6.14.0",
6767
"babel-eslint": "^6.1.0",
6868
"babel-loader": "^6.2.5",
69+
"babel-plugin-transform-async-to-generator": "^6.16.0",
70+
"babel-plugin-transform-class-properties": "^6.16.0",
71+
"babel-plugin-transform-object-rest-spread": "^6.16.0",
6972
"babel-plugin-transform-runtime": "^6.15.0",
70-
"babel-polyfill": "^6.5.0",
7173
"babel-preset-es2015": "^6.16.0",
7274
"babel-preset-es2016": "^6.16.0",
7375
"babel-preset-es2017": "^6.16.0",

src/vector/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ limitations under the License.
1818

1919
// for ES6 stuff like startsWith() that Safari doesn't handle
2020
// and babel doesn't do by default
21-
// Note we use this, not the babel transform-runtime plugin
21+
// Note we use this, as well as the babel transform-runtime plugin
2222
// since transform-runtime does not cover instance methods
2323
// such as "foobar".includes("foo") which bits of our library
24-
// code use.
24+
// code use, but the babel transform-runtime plugin allows the
25+
// regenerator runtime to be injected early enough in the process
26+
// (it can't be here as it's too late: the alternative is to put
27+
// the babel-polyfill as the first 'entry' in the webpack config).
2528
// https://babeljs.io/docs/plugins/transform-runtime/
2629
require('babel-polyfill');
2730

0 commit comments

Comments
 (0)