-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.cjs
48 lines (43 loc) · 1.08 KB
/
babel.config.cjs
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
module.exports = (api) => {
const useESModules = api.env(['esm', 'rollup']);
const modernJS = api.env(['esm', 'es']);
const basePresets = modernJS
? [
[
'@babel/env',
{
modules: useESModules ? false : 'commonjs',
},
],
]
: [
[
'@babel/env',
{
modules: useESModules ? false : 'commonjs',
targets: {
browsers: ['last 2 versions'],
},
},
],
];
const returnValue = {
presets: [...basePresets, '@babel/typescript', '@babel/react'],
plugins: [
[
'@babel/plugin-transform-typescript',
{
isTSX: true,
},
],
['@babel/plugin-proposal-class-properties', { loose: false }],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-optional-chaining',
],
};
if (!api.env(['rollup', 'test'])) {
returnValue.plugins.push(['babel-plugin-add-import-extension', { extension: useESModules ? 'js' : 'cjs' }]
);
}
return returnValue;
};