forked from callstack/linaria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
93 lines (90 loc) · 2.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
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
89
90
91
92
93
/*
* 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 10 and specific browsers.
* "test": Used by Jest, produces CommonJS output, targetting
* the current Node.js version.
*/
/*
* Configuration for the legacy build
*/
const commonJSTargets = {
browsers: ['last 2 versions', 'not op_mini all', 'not dead'],
node: '10',
};
module.exports = {
presets: ['@babel/preset-typescript'],
plugins: ['@babel/plugin-proposal-class-properties'],
env: {
legacy: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: commonJSTargets.node,
},
},
],
],
},
test: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: '10',
},
},
],
],
},
},
overrides: [
{
/**
* only react and core packages are targeted to be run in the browser
*/
test: /\/packages\/((react)|(core))\//,
presets: ['@babel/preset-react'],
env: {
legacy: {
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: 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\.(?:filter|for-each|index-of|join|reduce|slice)/,
'es.function.name',
'es.object.keys',
'web.dom-collections.for-each',
],
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__))\//,
presets: ['@babel/preset-react'],
},
],
};