-
Notifications
You must be signed in to change notification settings - Fork 252
/
babel.config.js
48 lines (43 loc) · 1.69 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
module.exports = api => {
// NB: This function can be called without an api argument, e.g. by bin/bundle
const presets = []
const plugins = []
const overrides = []
if (api && api.env('test')) {
presets.push('@babel/preset-typescript')
plugins.push(['@babel/plugin-proposal-class-properties', { loose: true }])
plugins.push('@babel/plugin-transform-modules-commonjs')
plugins.push('@babel/plugin-proposal-optional-chaining')
overrides.push({
test: 'node_modules/react-native/**/*',
presets: ['module:metro-react-native-babel-preset']
})
overrides.push({
test: './packages/plugin-react/**/*',
presets: ['@babel/preset-react']
})
overrides.push({
test: './packages/plugin-react-navigation/**/*',
presets: ['@babel/preset-react', 'module:metro-react-native-babel-preset']
})
}
plugins.push(
['@babel/plugin-transform-arrow-functions'],
['@babel/plugin-transform-block-scoping'],
['@babel/plugin-transform-classes', { loose: true }],
['@babel/plugin-transform-computed-properties', { loose: true }],
['@babel/plugin-transform-destructuring', { loose: true }],
['@babel/plugin-transform-member-expression-literals'],
['@babel/plugin-transform-property-literals'],
['@babel/plugin-transform-parameters', { loose: true }],
['@babel/plugin-transform-shorthand-properties'],
['@babel/plugin-transform-spread', { loose: true }],
['@babel/plugin-transform-template-literals', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { loose: true }],
['@babel/syntax-object-rest-spread']
)
if (api && !api.env('test')) {
api.cache(false)
}
return { presets, plugins, overrides }
}