-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
babel.config.js
58 lines (52 loc) · 1.41 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
import Module from 'node:module';
const require = Module.createRequire(import.meta.url);
// From: https://github.com/babel/babel-polyfills/blob/a5db9c31c5b5474b4018e6178bc40882fc3eb5bf/packages/babel-plugin-polyfill-corejs3/README.md#version
const {
version: babelruntimeVersion
} = require('@babel/runtime-corejs3/package.json');
const { version: corejspureVersion } = require('core-js-pure/package.json');
/** @type {import('@babel/core').ConfigFunction} */
function makeConfig(api) {
api.cache.invalidate(() => babelruntimeVersion + corejspureVersion);
return {
// Fixes "TypeError: __webpack_require__(...) is not a function"
// https://github.com/webpack/webpack/issues/9379#issuecomment-509628205
// https://babel.dev/docs/options#sourcetype
sourceType: 'unambiguous',
// https://babel.dev/docs/assumptions
assumptions: {
noNewArrows: true
},
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: false,
version: babelruntimeVersion
}
],
[
'polyfill-corejs3',
{
method: 'usage-pure',
version: corejspureVersion
}
],
[
'polyfill-regenerator',
{
method: 'usage-pure'
}
]
],
presets: [
[
'@babel/preset-env',
{
bugfixes: true
}
]
]
};
}
export default makeConfig;