-
Notifications
You must be signed in to change notification settings - Fork 36
/
babel.config.js
48 lines (45 loc) · 1.37 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 = function (api) {
api.cache(true);
const currentEnv =
process.env.BABEL_ENV || process.env.NODE_ENV || 'development';
const isTestEnv =
(!!process.env.SDKROOT &&
process.env.SDKROOT.includes('iPhoneSimulator')) ||
!!process.env.FOR_DETOX;
const presets = [
'module:@react-native/babel-preset',
'@babel/preset-typescript',
];
const plugins = [
[
'module-resolver',
{
alias: {
'@app': './src',
'@assets': './assets',
},
},
],
'react-native-reanimated/plugin',
];
if (currentEnv === 'production' && !isTestEnv) {
plugins.push(['react-remove-properties', {properties: ['testID']}]);
}
return {
presets,
plugins,
overrides: [
{
// Fix for "Class private methods are not enabled" after TronWeb installation.
// If enable `@babel/plugin-transform-private-methods` globally react-native app crashed:
// ERROR TypeError: Cannot read property 'getItem' of FlatList
test: /node_modules[\\/](more-problematic-package-names|tronweb)[\\/].*\.(js|ts|tsx)$/,
plugins: [
['@babel/plugin-proposal-class-properties', {loose: true}],
['@babel/plugin-proposal-private-methods', {loose: true}],
['@babel/plugin-proposal-private-property-in-object', {loose: true}],
],
},
],
};
};