forked from algolia/react-instantsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
58 lines (53 loc) · 1.31 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
/* eslint-disable import/no-commonjs */
const isES = process.env.BABEL_ENV === 'es';
const isRollup = process.env.BABEL_ENV === 'rollup';
const clean = x => x.filter(Boolean);
module.exports = api => {
const isTest = api.env('test');
const targets = {};
if (!isTest) {
targets.browsers = ['last 2 versions', 'ie >= 9'];
} else {
targets.node = true;
}
return {
presets: [
[
'@babel/preset-env',
{
modules: !isES && !isRollup ? 'commonjs' : false,
targets,
},
],
'@babel/preset-react',
],
plugins: clean([
'@babel/plugin-proposal-class-properties',
isRollup && 'babel-plugin-transform-react-remove-prop-types',
]),
overrides: [
{
test: 'packages/*',
presets: ['@babel/preset-typescript'],
plugins: [
[
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: true,
regenerator: false,
useESModules: isES || isRollup,
},
],
],
},
{
test: 'packages/react-instantsearch-dom-maps',
plugins: clean([
'@babel/plugin-syntax-dynamic-import',
!isRollup && 'babel-plugin-dynamic-import-node',
]),
},
],
};
};