From 7ff9f74918c4aa241d31b19ef922800daa0af6ee Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Fri, 5 Aug 2016 10:21:20 +0530 Subject: [PATCH] Use the default babel-config from CRA. (#354) * Use the default babel-config from CRA. * Fix lint issues --- dist/server/config/babel.js | 36 +++++++++++++++++++++++++++++--- dist/server/config/babel.prod.js | 36 +++++++++++++++++++++++++++++--- package.json | 7 ++++++- src/server/config/babel.js | 35 ++++++++++++++++++++++++++----- src/server/config/babel.prod.js | 35 +++++++++++++++++++++++++------ 5 files changed, 131 insertions(+), 18 deletions(-) diff --git a/dist/server/config/babel.js b/dist/server/config/babel.js index 25d95084d694..5f31e89ed0a8 100644 --- a/dist/server/config/babel.js +++ b/dist/server/config/babel.js @@ -1,12 +1,42 @@ 'use strict'; +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + module.exports = { + // Don't try to find .babelrc because we want to force this configuration. babelrc: false, + // This is a feature of `babel-loader` for webpack (not Babel itself). + // It enables caching results in OS temporary directory for faster rebuilds. cacheDirectory: true, - presets: ['babel-preset-es2015', 'babel-preset-es2016', 'babel-preset-stage-0', 'babel-preset-react'].map(require.resolve), - plugins: [].map(require.resolve).concat([[require.resolve('babel-plugin-transform-runtime'), { + presets: [ + // let, const, destructuring, classes, modules + 'babel-preset-es2015', + // exponentiation + 'babel-preset-es2016', + // JSX, Flow + 'babel-preset-react'], + plugins: [ + // function x(a, b, c,) { } + 'babel-plugin-syntax-trailing-function-commas', + // await fetch() + 'babel-plugin-syntax-async-functions', + // class { handleClick = () => { } } + 'babel-plugin-transform-class-properties', + // { ...todo, completed: true } + 'babel-plugin-transform-object-rest-spread', + // function* () { yield 42; yield 43; } + 'babel-plugin-transform-regenerator', + // Polyfills the runtime needed for async/await and generators + ['babel-plugin-transform-runtime', { helpers: false, polyfill: false, regenerator: true - }]]) + }]] }; \ No newline at end of file diff --git a/dist/server/config/babel.prod.js b/dist/server/config/babel.prod.js index 1ead8da4a596..f0c8efe3818c 100644 --- a/dist/server/config/babel.prod.js +++ b/dist/server/config/babel.prod.js @@ -1,11 +1,41 @@ 'use strict'; +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + module.exports = { + // Don't try to find .babelrc because we want to force this configuration. babelrc: false, - presets: ['babel-preset-es2015', 'babel-preset-es2016', 'babel-preset-stage-0', 'babel-preset-react'].map(require.resolve), - plugins: ['babel-plugin-transform-react-constant-elements'].map(require.resolve).concat([[require.resolve('babel-plugin-transform-runtime'), { + presets: [ + // let, const, destructuring, classes, modules + 'babel-preset-es2015', + // exponentiation + 'babel-preset-es2016', + // JSX, Flow + 'babel-preset-react'], + plugins: [ + // function x(a, b, c,) { } + 'babel-plugin-syntax-trailing-function-commas', + // await fetch() + 'babel-plugin-syntax-async-functions', + // class { handleClick = () => { } } + 'babel-plugin-transform-class-properties', + // { ...todo, completed: true } + 'babel-plugin-transform-object-rest-spread', + // function* () { yield 42; yield 43; } + 'babel-plugin-transform-regenerator', + // Polyfills the runtime needed for async/await and generators + ['babel-plugin-transform-runtime', { helpers: false, polyfill: false, regenerator: true - }]]) + }], + // Optimization: hoist JSX that never changes out of render() + 'babel-plugin-transform-react-constant-elements'] }; \ No newline at end of file diff --git a/package.json b/package.json index 89d87722fb50..c7027326fd43 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,14 @@ "babel-plugin-transform-react-constant-elements": "^6.9.1", "babel-plugin-transform-runtime": "^6.12.0", "babel-polyfill": "^6.9.1", + "babel-plugin-syntax-async-functions": "^6.8.0", + "babel-plugin-syntax-trailing-function-commas": "^6.8.0", + "babel-plugin-transform-class-properties": "^6.11.5", + "babel-plugin-transform-object-rest-spread": "^6.8.0", + "babel-plugin-transform-regenerator": "^6.11.4", "babel-preset-es2015": "^6.9.0", "babel-preset-es2016": "^6.11.3", "babel-preset-react": "^6.11.1", - "babel-preset-stage-0": "^6.5.0", "babel-runtime": "^6.9.2", "case-sensitive-paths-webpack-plugin": "^1.1.2", "cjson": "^0.4.0", @@ -71,6 +75,7 @@ "babel-cli": "^6.11.4", "babel-eslint": "^6.1.2", "babel-plugin-transform-runtime": "^6.9.0", + "babel-preset-stage-0": "^6.5.0", "chai": "^3.5.0", "deep-equal": "^1.0.1", "enzyme": "^2.2.0", diff --git a/src/server/config/babel.js b/src/server/config/babel.js index 7c14a68780cb..1a23f69bcaf1 100644 --- a/src/server/config/babel.js +++ b/src/server/config/babel.js @@ -1,17 +1,42 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + module.exports = { + // Don't try to find .babelrc because we want to force this configuration. babelrc: false, + // This is a feature of `babel-loader` for webpack (not Babel itself). + // It enables caching results in OS temporary directory for faster rebuilds. cacheDirectory: true, presets: [ + // let, const, destructuring, classes, modules 'babel-preset-es2015', + // exponentiation 'babel-preset-es2016', - 'babel-preset-stage-0', + // JSX, Flow 'babel-preset-react', - ].map(require.resolve), - plugins: [].map(require.resolve).concat([ - [require.resolve('babel-plugin-transform-runtime'), { + ], + plugins: [ + // function x(a, b, c,) { } + 'babel-plugin-syntax-trailing-function-commas', + // await fetch() + 'babel-plugin-syntax-async-functions', + // class { handleClick = () => { } } + 'babel-plugin-transform-class-properties', + // { ...todo, completed: true } + 'babel-plugin-transform-object-rest-spread', + // function* () { yield 42; yield 43; } + 'babel-plugin-transform-regenerator', + // Polyfills the runtime needed for async/await and generators + ['babel-plugin-transform-runtime', { helpers: false, polyfill: false, regenerator: true, }], - ]), + ], }; diff --git a/src/server/config/babel.prod.js b/src/server/config/babel.prod.js index a0d622a5a66b..8aa8a4e13787 100644 --- a/src/server/config/babel.prod.js +++ b/src/server/config/babel.prod.js @@ -1,18 +1,41 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + module.exports = { + // Don't try to find .babelrc because we want to force this configuration. babelrc: false, presets: [ + // let, const, destructuring, classes, modules 'babel-preset-es2015', + // exponentiation 'babel-preset-es2016', - 'babel-preset-stage-0', + // JSX, Flow 'babel-preset-react', - ].map(require.resolve), + ], plugins: [ - 'babel-plugin-transform-react-constant-elements', - ].map(require.resolve).concat([ - [require.resolve('babel-plugin-transform-runtime'), { + // function x(a, b, c,) { } + 'babel-plugin-syntax-trailing-function-commas', + // await fetch() + 'babel-plugin-syntax-async-functions', + // class { handleClick = () => { } } + 'babel-plugin-transform-class-properties', + // { ...todo, completed: true } + 'babel-plugin-transform-object-rest-spread', + // function* () { yield 42; yield 43; } + 'babel-plugin-transform-regenerator', + // Polyfills the runtime needed for async/await and generators + ['babel-plugin-transform-runtime', { helpers: false, polyfill: false, regenerator: true, }], - ]), + // Optimization: hoist JSX that never changes out of render() + 'babel-plugin-transform-react-constant-elements', + ], };