forked from DestinyItemManager/DIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
78 lines (73 loc) · 2.02 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
69
70
71
72
73
74
75
76
77
78
module.exports = function (api) {
const isProduction = api.env('production');
const isTest = api.env('test');
const plugins = [
'lodash',
'babel-plugin-optimize-clsx',
'object-to-json-parse',
[
'@babel/plugin-transform-runtime',
{
useESModules: !isTest,
},
],
[
'transform-imports',
{
'@fortawesome/free-brands-svg-icons': {
transform: (member) => `@fortawesome/free-brands-svg-icons/${member}`,
preventFullImport: true,
skipDefaultConversion: true,
},
'@fortawesome/free-solid-svg-icons': {
transform: (member) => `@fortawesome/free-solid-svg-icons/${member}`,
preventFullImport: true,
skipDefaultConversion: true,
},
'@fortawesome/free-regular-svg-icons': {
transform: (member) => `@fortawesome/free-regular-svg-icons/${member}`,
preventFullImport: true,
skipDefaultConversion: true,
},
},
],
];
if (isProduction) {
plugins.push(
'@babel/plugin-transform-react-constant-elements',
'@babel/plugin-transform-react-inline-elements'
);
} else {
if (!isTest) {
plugins.push('react-refresh/babel');
}
// In dev, compile TS with babel
plugins.push(['@babel/plugin-transform-typescript', { isTSX: true, optimizeConstEnums: true }]);
}
const presetEnvOptions = {
bugfixes: true,
modules: false,
loose: true,
useBuiltIns: 'usage',
corejs: 3,
shippedProposals: true,
};
if (isTest) {
presetEnvOptions.targets = { node: 'current' };
presetEnvOptions.modules = 'auto';
}
return {
presets: [
['@babel/preset-env', presetEnvOptions],
['@babel/preset-react', { useBuiltIns: true, loose: true, corejs: 3, runtime: 'automatic' }],
],
plugins,
// https://babeljs.io/docs/en/assumptions
assumptions: {
noDocumentAll: true,
noClassCalls: true,
setPublicClassFields: true,
setSpreadProperties: true,
},
};
};