-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.babelrc.cts
55 lines (51 loc) · 1.14 KB
/
.babelrc.cts
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
import { Options } from '@babel/preset-env';
import { TransformOptions } from '@babel/core';
const browsers = [
'>1%',
'last 4 versions',
'Firefox ESR'
];
const getPresets = ({
modules,
targets = { browsers }
}: Partial<Options> = {}) => [
require.resolve('@babel/preset-typescript'),
[require.resolve('@babel/preset-env'), {
modules,
targets,
loose: true,
exclude: ['@babel/plugin-transform-regenerator']
}]
];
const config: TransformOptions = {
plugins: [
[require.resolve('@babel/plugin-proposal-object-rest-spread'), {
useBuiltIns: true
}]
],
presets: getPresets(),
env: {
cjs: {
presets: getPresets({ modules: 'commonjs' }),
plugins: [
[require.resolve('babel-plugin-module-extension-resolver'), {
dstExtension: '.cjs'
}]
]
},
mjs: {
presets: getPresets({ modules: false }),
plugins: [
[require.resolve('babel-plugin-module-extension-resolver'), {
dstExtension: '.mjs'
}]
]
},
test: {
presets: getPresets({
targets: { node: 'current' }
})
}
}
};
export default config;