|  | 
|  | 1 | +/** | 
|  | 2 | + * Copyright (c) 2015-present, Facebook, Inc. | 
|  | 3 | + * All rights reserved. | 
|  | 4 | + * | 
|  | 5 | + * This source code is licensed under the BSD-style license found in the | 
|  | 6 | + * LICENSE file in the root directory of this source tree. An additional grant | 
|  | 7 | + * of patent rights can be found in the PATENTS file in the same directory. | 
|  | 8 | + */ | 
|  | 9 | +'use strict'; | 
|  | 10 | + | 
|  | 11 | +var path = require('path'); | 
|  | 12 | + | 
|  | 13 | +module.exports = { | 
|  | 14 | +  presets: [ | 
|  | 15 | +    // Latest stable ECMAScript features | 
|  | 16 | +    require.resolve('babel-preset-latest'), | 
|  | 17 | +    // JSX, Flow | 
|  | 18 | +    require.resolve('babel-preset-react') | 
|  | 19 | +  ], | 
|  | 20 | +  plugins: [ | 
|  | 21 | +    // class { handleClick = () => { } } | 
|  | 22 | +    require.resolve('babel-plugin-transform-class-properties'), | 
|  | 23 | +    // { ...todo, completed: true } | 
|  | 24 | +    require.resolve('babel-plugin-transform-object-rest-spread'), | 
|  | 25 | +    // function* () { yield 42; yield 43; } | 
|  | 26 | +    [require.resolve('babel-plugin-transform-regenerator'), { | 
|  | 27 | +      // Async functions are converted to generators by babel-preset-latest | 
|  | 28 | +      async: false | 
|  | 29 | +    }], | 
|  | 30 | +    // Polyfills the runtime needed for async/await and generators | 
|  | 31 | +    [require.resolve('babel-plugin-transform-runtime'), { | 
|  | 32 | +      helpers: false, | 
|  | 33 | +      polyfill: false, | 
|  | 34 | +      regenerator: true, | 
|  | 35 | +      // Resolve the Babel runtime relative to the config. | 
|  | 36 | +      moduleName: path.dirname(require.resolve('babel-runtime/package')) | 
|  | 37 | +    }] | 
|  | 38 | +  ], | 
|  | 39 | +  env: { | 
|  | 40 | +    production: { | 
|  | 41 | +      plugins: [ | 
|  | 42 | +        // Optimization: hoist JSX that never changes out of render() | 
|  | 43 | +        // Disabled because of issues: | 
|  | 44 | +        // * https://github.com/facebookincubator/create-react-app/issues/525 | 
|  | 45 | +        // * https://phabricator.babeljs.io/search/query/pCNlnC2xzwzx/ | 
|  | 46 | +        // * https://github.com/babel/babel/issues/4516 | 
|  | 47 | +        // TODO: Enable again when these issues are resolved. | 
|  | 48 | +        // require.resolve('babel-plugin-transform-react-constant-elements') | 
|  | 49 | +      ] | 
|  | 50 | +    } | 
|  | 51 | +  } | 
|  | 52 | +}; | 
0 commit comments