-
Notifications
You must be signed in to change notification settings - Fork 188
/
babel.config.js
46 lines (42 loc) · 1.06 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
/* eslint-disable import/no-commonjs, functional/immutable-data, functional/no-expression-statement, @typescript-eslint/no-var-requires */
const wrapWarningWithDevCheck = require('./scripts/babel/wrap-warning-with-dev-check');
module.exports = (api) => {
const isTest = api.env('test');
const modules = isTest ? 'commonjs' : false;
const targets = {};
if (isTest) {
targets.node = true;
}
return {
presets: [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
modules,
targets,
},
],
],
plugins: clean([
'@babel/plugin-proposal-nullish-coalescing-operator',
wrapWarningWithDevCheck,
[
'inline-replace-variables',
{
__DEV__: {
type: 'node',
replacement: "process.env.NODE_ENV !== 'production'",
},
__TEST__: {
type: 'node',
replacement: "process.env.NODE_ENV === 'test'",
},
},
],
]),
};
};
function clean(config) {
return config.filter(Boolean);
}