-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.cjs
60 lines (52 loc) · 1.18 KB
/
index.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
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
const { declare } = require('@babel/helper-plugin-utils');
const { excludeIfMini } = require('./mini.cjs');
module.exports = declare((api, options = {}) => {
api.assertVersion(7);
const { polyfill = false } = options;
const presets = [
[
'@babel/env',
{
modules: false,
useBuiltIns: false,
shippedProposals: true,
spec: true,
bugfixes: true,
},
],
];
if (!polyfill) {
return { presets };
}
const {
usage = 'global',
include = [],
exclude = [],
mini = false,
} = polyfill;
const pkg = require('./package.json');
return {
presets,
plugins: [
[
'babel-plugin-polyfill-corejs3',
{
version: pkg.dependencies['core-js'],
proposals: true,
method: `usage-${usage}`,
include: mini ? [...include, 'web.url'] : include,
exclude: mini ? [...exclude, ...excludeIfMini] : exclude,
},
],
mini
? [
'@babel/plugin-transform-unicode-property-regex',
{
useUnicodeFlag: false,
},
]
: undefined,
].filter(Boolean),
};
});