-
Notifications
You must be signed in to change notification settings - Fork 229
/
babel.config.main.js
67 lines (62 loc) · 1.69 KB
/
babel.config.main.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
const plugins = [
'@babel/plugin-proposal-object-rest-spread', // allows ...spread notation
'@babel/plugin-syntax-dynamic-import', // allows `await import()` syntax
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-transform-runtime',
'@loadable/babel-plugin',
];
// allows dynamic `import()` in Node tests.
if (process.env.NODE_ENV === 'test') {
plugins.push('dynamic-import-node');
plugins.push('@babel/plugin-proposal-throw-expressions'); // allows `throw new Error();`
}
const overrides = [
{
test: /.*logger\..*/,
sourceType: 'script',
},
];
module.exports = api => {
const env = api.env();
const useModern = env === 'modern';
const presets = [
[
'@babel/preset-env',
{
targets: {
...(useModern
? {
browsers: ['safari > 12', 'supports es6-module'],
}
: {
browsers: [
'chrome >= 53',
'firefox >= 45.0',
'ie >= 11',
'edge >= 100',
'safari >= 10',
'opera >= 40',
'op_mini >= 18',
'Android >= 7',
'and_chr >= 53',
'and_ff >= 49',
'ios_saf >= 10',
],
}),
node: 'current',
},
// analyses code & polyfills only the features that are used, only for the targeted browsers
useBuiltIns: 'usage',
corejs: '3',
},
],
'@babel/preset-react', // transform JSX to JS
'@babel/preset-typescript',
'@emotion/babel-preset-css-prop',
];
return {
presets,
plugins,
overrides,
};
};