forked from algolia/react-instantsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
68 lines (63 loc) · 1.57 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
59
60
61
62
63
64
65
66
67
68
const wrapWarningWithDevCheck = require('./scripts/babel/wrap-warning-with-dev-check');
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-typescript',
[
'@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',
wrapWarningWithDevCheck,
[
'inline-replace-variables',
{
__DEV__: {
type: 'node',
replacement: "process.env.NODE_ENV !== 'production'",
},
},
],
]),
overrides: [
{
test: 'packages/*',
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',
]),
},
],
};
};