|
| 1 | +var path = require('path'); |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + // Don't try to find .babelrc because we want to force this configuration. |
| 5 | + babelrc: false, |
| 6 | + presets: [ |
| 7 | + // Latest stable ECMAScript features |
| 8 | + require.resolve('babel-preset-latest'), |
| 9 | + // JSX, Flow |
| 10 | + require.resolve('babel-preset-react') |
| 11 | + ], |
| 12 | + plugins: [ |
| 13 | + // To split lodash modules |
| 14 | + require.resolve('babel-plugin-lodash'), |
| 15 | + // class { handleClick = () => { } } |
| 16 | + require.resolve('babel-plugin-transform-class-properties'), |
| 17 | + // { ...todo, completed: true } |
| 18 | + require.resolve('babel-plugin-transform-object-rest-spread'), |
| 19 | + // function* () { yield 42; yield 43; } |
| 20 | + [require.resolve('babel-plugin-transform-regenerator'), { |
| 21 | + // Async functions are converted to generators by babel-preset-latest |
| 22 | + async: false |
| 23 | + }], |
| 24 | + // Polyfills the runtime needed for async/await and generators |
| 25 | + [require.resolve('babel-plugin-transform-runtime'), { |
| 26 | + helpers: false, |
| 27 | + polyfill: false, |
| 28 | + regenerator: true, |
| 29 | + // Resolve the Babel runtime relative to the config. |
| 30 | + // You can safely remove this after ejecting: |
| 31 | + moduleName: path.dirname(require.resolve('babel-runtime/package')) |
| 32 | + }], |
| 33 | + // Optimization: hoist JSX that never changes out of render() |
| 34 | + // Disabled because of issues: |
| 35 | + // * https://github.com/facebookincubator/create-react-app/issues/525 |
| 36 | + // * https://phabricator.babeljs.io/search/query/pCNlnC2xzwzx/ |
| 37 | + // TODO: Enable again when these issues are resolved. |
| 38 | + // require.resolve('babel-plugin-transform-react-constant-elements') |
| 39 | + ] |
| 40 | +}; |
0 commit comments