-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel.config.js
88 lines (87 loc) · 2.19 KB
/
babel.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const isProduction = process.env.NODE_ENV === 'buildProduction';
const isTest = process.env.NODE_ENV === 'test';
module.exports = {
ignore: isProduction
? [
'**/*.css.d.ts',
'**/__tests__/*',
'**/__stories__/*',
'**/__stand__/*',
'**/__tests__/*',
'**/__mocks__/*',
'**/src/stand/*',
'**/src/docs/*',
]
: [],
comments: false,
presets: [
[
'@babel/preset-env',
{
// Allow importing core-js in entrypoint and use browserlist to select polyfills
useBuiltIns: 'entry',
// Set the corejs version we are using to avoid warnings in console
// This will need to change once we upgrade to corejs@3
corejs: 3,
// Transform modules to CJS only for jest
modules: isTest ? 'cjs' : false,
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
},
],
[
'@babel/preset-react',
{
// Adds component stack to warning messages
// Adds __self attribute to JSX which React will use for some warnings
development: !isProduction,
// Will use the native built-in instead of trying to polyfill
// behavior for any plugins that require one.
useBuiltIns: true,
},
],
['@babel/preset-typescript'],
...(isProduction
? [
[
'minify',
{
builtIns: false,
},
],
]
: []),
],
plugins: [
['@babel/plugin-proposal-class-properties'],
[
'@babel/plugin-proposal-object-rest-spread',
{
useBuiltIns: true,
},
],
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: true,
regenerator: true,
},
],
...(isProduction
? [
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: {
'##': './src',
},
},
],
]
: []),
],
};