babel.dev.js 1.84 KB
Newer Older
1
// @remove-on-eject-begin
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
// @remove-on-eject-end
11

12
var path = require('path');
13
var findCacheDir = require('find-cache-dir');
14

15
module.exports = {
16
  // Don't try to find .babelrc because we want to force this configuration.
Dan Abramov's avatar
Dan Abramov committed
17
  babelrc: false,
18
  // This is a feature of `babel-loader` for webpack (not Babel itself).
19
  // It enables caching results in ./node_modules/.cache/react-scripts/
20
21
22
23
24
  // directory for faster rebuilds. We use findCacheDir() because of:
  // https://github.com/facebookincubator/create-react-app/issues/483
  cacheDirectory: findCacheDir({
    name: 'react-scripts'
  }),
25
  presets: [
26
27
    // Latest stable ECMAScript features
    require.resolve('babel-preset-latest'),
28
    // JSX, Flow
Dan Abramov's avatar
Dan Abramov committed
29
30
    require.resolve('babel-preset-react')
  ],
31
  plugins: [
32
    // class { handleClick = () => { } }
Dan Abramov's avatar
Dan Abramov committed
33
    require.resolve('babel-plugin-transform-class-properties'),
34
    // { ...todo, completed: true }
Dan Abramov's avatar
Dan Abramov committed
35
    require.resolve('babel-plugin-transform-object-rest-spread'),
36
    // function* () { yield 42; yield 43; }
37
38
39
40
    [require.resolve('babel-plugin-transform-regenerator'), {
      // Async functions are converted to generators by babel-preset-latest
      async: false
    }],
41
    // Polyfills the runtime needed for async/await and generators
Dan Abramov's avatar
Dan Abramov committed
42
43
44
    [require.resolve('babel-plugin-transform-runtime'), {
      helpers: false,
      polyfill: false,
45
46
47
48
      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'))
Dan Abramov's avatar
Dan Abramov committed
49
    }]
Dan Abramov's avatar
Dan Abramov committed
50
  ]
51
};