babel.prod.js 1.77 KB
Newer Older
1
2
3
4
5
6
7
8
9
/**
 * 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.
 */

10
11
var path = require('path');

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