forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
37 lines (32 loc) · 1.18 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
const defaultPresets = ['@babel/preset-react', '@babel/preset-env', '@babel/preset-flow'];
const defaultPlugins = [
// Adding the commonjs: true option to react-native-web plugin can cause styling conflicts
['react-native-web'],
'@babel/transform-runtime',
'@babel/plugin-proposal-class-properties',
// We use `transform-class-properties` for transforming ReactNative libraries and do not use it for our own
// source code transformation as we do not use class property assignment.
'transform-class-properties',
];
const webpack = {
env: {
production: {
presets: defaultPresets,
plugins: [...defaultPlugins, 'transform-remove-console'],
},
development: {
presets: defaultPresets,
plugins: defaultPlugins,
},
},
};
const metro = {
presets: [require('metro-react-native-babel-preset')],
plugins: [],
};
module.exports = ({caller}) => {
// For `react-native` (iOS/Android) caller will be "metro"
// For `webpack` (Web) caller will be "@babel-loader"
const runningIn = caller(({name}) => name);
return ['metro', 'babel-jest'].includes(runningIn) ? metro : webpack;
};