|
8 | 8 | */ |
9 | 9 |
|
10 | 10 | module.exports = { |
| 11 | + // Don't try to find .babelrc because we want to force this configuration. |
11 | 12 | babelrc: false, |
12 | 13 | presets: [ |
13 | | - 'babel-preset-es2015', |
14 | | - 'babel-preset-es2016', |
15 | | - 'babel-preset-react' |
16 | | - ].map(require.resolve), |
| 14 | + // let, const, destructuring, classes, modules |
| 15 | + require.resolve('babel-preset-es2015'), |
| 16 | + // exponentiation |
| 17 | + require.resolve('babel-preset-es2016'), |
| 18 | + // JSX, Flow |
| 19 | + require.resolve('babel-preset-react') |
| 20 | + ], |
17 | 21 | plugins: [ |
18 | | - 'babel-plugin-syntax-trailing-function-commas', |
19 | | - 'babel-plugin-transform-class-properties', |
20 | | - 'babel-plugin-transform-object-rest-spread', |
21 | | - 'babel-plugin-transform-react-constant-elements', |
22 | | - ].map(require.resolve).concat([ |
| 22 | + // function x(a, b, c,) { } |
| 23 | + require.resolve('babel-plugin-syntax-trailing-function-commas'), |
| 24 | + // await fetch() |
| 25 | + require.resolve('babel-plugin-syntax-async-functions'), |
| 26 | + // class { handleClick = () => { } } |
| 27 | + require.resolve('babel-plugin-transform-class-properties'), |
| 28 | + // { ...todo, completed: true } |
| 29 | + require.resolve('babel-plugin-transform-object-rest-spread'), |
| 30 | + // function* () { yield 42; yield 43; } |
| 31 | + require.resolve('babel-plugin-transform-regenerator'), |
| 32 | + // Polyfills the runtime needed for async/await and generators |
23 | 33 | [require.resolve('babel-plugin-transform-runtime'), { |
24 | 34 | helpers: false, |
25 | 35 | polyfill: false, |
26 | 36 | regenerator: true |
27 | | - }] |
28 | | - ]) |
| 37 | + }], |
| 38 | + // Optimization: hoist JSX that never changes out of render() |
| 39 | + require.resolve('babel-plugin-transform-react-constant-elements') |
| 40 | + ] |
29 | 41 | }; |
0 commit comments