-
Notifications
You must be signed in to change notification settings - Fork 602
/
babel.config.js
88 lines (87 loc) · 2.43 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 plugins = [
[
'@babel/plugin-transform-runtime',
{
helpers: true,
// regenerator: true,
},
],
[
'@babel/plugin-transform-modules-commonjs',
{
loose: true, // improves speed & code size; unlikely to be a problem
strict: false,
strictMode: true,
allowTopLevelThis: true,
// this would improve speed&code size but breaks 3rd party code. can we apply it to our paths only?
// (same with struct: true)
// noInterop: true,
},
],
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-transform-flow-strip-types',
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'@babel/plugin-transform-classes',
{
loose: true, // spits out cleaner and faster output
},
],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-block-scoping',
'@babel/plugin-proposal-json-strings',
'@babel/plugin-proposal-unicode-property-regex',
// See http://incaseofstairs.com/six-speed/ for speed comparison between native and transpiled ES6
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-transform-template-literals',
'@babel/plugin-transform-literals',
'@babel/plugin-transform-function-name',
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-transform-shorthand-properties',
'@babel/plugin-transform-spread',
[
'@babel/plugin-proposal-object-rest-spread',
{
// use fast Object.assign
loose: true,
},
],
'@babel/plugin-transform-react-jsx',
[
'@babel/plugin-transform-computed-properties',
{
// 2-3x faster, unlikely to be an issue
loose: true,
},
],
'@babel/plugin-transform-sticky-regex',
'@babel/plugin-transform-unicode-regex',
// TODO: fast-async is faster and cleaner, but causes a weird issue on older Android RN targets without jsc-android
// '@babel/plugin-transform-async-to-generator',
[
// TODO: We can get this faster by tweaking with options, but have to test thoroughly...
'module:fast-async',
{
spec: true,
},
],
]
module.exports = {
env: {
development: {
plugins,
},
production: {
plugins: [
...plugins,
'minify-flip-comparisons',
'minify-guarded-expressions',
'minify-dead-code-elimination',
],
},
test: {
plugins: [...plugins, '@babel/plugin-syntax-jsx'],
},
},
}