-
Notifications
You must be signed in to change notification settings - Fork 417
/
babel.config.js
88 lines (85 loc) · 2.34 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
79
80
81
82
83
84
85
86
87
88
/*
* The following environments are supported:
*
* (unspecified): Produces ES module output, no language features
* (except non-standard ones) are transpiled.
* "legacy": Produces CommonJS output, uses @babel/preset-env to target
* Node.js 12 and specific browsers.
* "test": Used by Jest, produces CommonJS output, targetting
* the same version as legacy.
*/
/*
* Configuration for the legacy build
*/
const commonJSTargets = {
browsers: '> 0.25% and supports array-includes',
// browsers: 'chrome > 90',
node: '12',
};
module.exports = {
presets: ['@babel/preset-typescript'],
plugins: ['@babel/plugin-proposal-explicit-resource-management'],
env: {
legacy: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: commonJSTargets.node,
},
},
],
],
},
test: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: commonJSTargets.node,
},
},
],
'@babel/preset-typescript',
],
},
},
overrides: [
{
/**
* only react and core packages are targeted to be run in the browser
*/
test: /[\\/]packages[\\/](?:atomic|core|react)[\\/](?!src[\\/]processors[\\/])/,
presets: ['@babel/preset-react'],
env: {
legacy: {
presets: [
[
'@babel/preset-env',
{
targets: commonJSTargets.browsers,
loose: true,
// our styled component should not need to use any polyfill. We do not include core-js in dependencies. However, we leave this to detect if future changes would not introduce any need for polyfill
useBuiltIns: 'usage',
// Even core-js doesn't remember IE11
exclude: ['es.array.includes', 'web.dom-collections.iterator'],
corejs: 3,
// this is used to test if we do not introduced core-js polyfill
debug: process.env.DEBUG_CORE_JS === 'true',
},
],
],
},
},
},
{
/**
* we have to transpile JSX in tests
*/
test: /[\\/](__tests__|__fixtures__|packages[\\/]teskit[\\/]src)[\\/]/,
presets: ['@babel/preset-react'],
},
],
};