babel.dev.js 1.73 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
20
21
  // It enables caching results in ./node_modules/.cache/react-scripts/
  // directory for faster rebuilds.
  cacheDirectory: findCacheDir({ name: 'react-scripts' }),
22
  presets: [
23
24
    // Latest stable ECMAScript features
    require.resolve('babel-preset-latest'),
25
    // JSX, Flow
Dan Abramov's avatar
Dan Abramov committed
26
27
    require.resolve('babel-preset-react')
  ],
28
  plugins: [
29
    // class { handleClick = () => { } }
Dan Abramov's avatar
Dan Abramov committed
30
    require.resolve('babel-plugin-transform-class-properties'),
31
    // { ...todo, completed: true }
Dan Abramov's avatar
Dan Abramov committed
32
    require.resolve('babel-plugin-transform-object-rest-spread'),
33
    // function* () { yield 42; yield 43; }
34
35
36
37
    [require.resolve('babel-plugin-transform-regenerator'), {
      // Async functions are converted to generators by babel-preset-latest
      async: false
    }],
38
    // Polyfills the runtime needed for async/await and generators
Dan Abramov's avatar
Dan Abramov committed
39
40
41
    [require.resolve('babel-plugin-transform-runtime'), {
      helpers: false,
      polyfill: false,
42
43
44
45
      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
46
    }]
Dan Abramov's avatar
Dan Abramov committed
47
  ]
48
};