-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbabel.config.js
133 lines (121 loc) · 4.45 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
'use strict'
module.exports = function (api) {
//api.cache(true)
api.cache.invalidate(() => process.env.NODE_ENV)
const isProduction = api.env('production')
return {
babelrc: false,
comments: !isProduction,
plugins: isProduction
? [
[
'@babel/plugin-transform-runtime',
{
absoluteRuntime: false,
useESModules: true,
version: '^7.14.0',
},
],
// Stage 0
//require('@babel/plugin-proposal-function-bind',
// Stage 1
'@babel/plugin-proposal-export-default-from',
//'@babel/plugin-proposal-logical-assignment-operators',
['@babel/plugin-proposal-optional-chaining', { loose: true }],
//['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: true }],
//'@babel/plugin-proposal-do-expressions',
// Stage 2
['@babel/plugin-proposal-decorators', { legacy: true }],
//'@babel/plugin-proposal-function-sent',
'@babel/plugin-proposal-export-namespace-from',
//'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-throw-expressions',
'@babel/plugin-proposal-unicode-property-regex',
// Stage 3
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-proposal-json-strings',
[
'babel-plugin-transform-imports',
{
reactstrap: {
preventFullImport: true,
transform: 'reactstrap/lib/${member}',
},
},
],
[
'babel-plugin-transform-react-remove-prop-types',
{
additionalLibraries: ['react-immutable-proptypes'],
removeImport: true,
},
],
'babel-plugin-transform-react-pure-class-to-function',
['@babel/plugin-transform-react-jsx', { runtime: 'automatic', importSource: 'preact', useBuiltIns: true, useSpread: true }], // @todo runtime: 'automatic',
'babel-plugin-optimize-react',
'babel-plugin-react-local',
'babel-plugin-optimize-clsx',
//'@babel/plugin-transform-react-constant-elements', // see https://github.com/facebookincubator/create-react-app/issues/553#issuecomment-359196326
//['babel-plugin-transform-hoist-nested-functions', { methods: true }], // see ^^^
//'babel-plugin-closure-elimination', // @TODO: Benchmark w/ & w/o, see ^^^ // broken collections portal navigation 21/11/2020
// 'module:fast-async', - enabled from Chrome 55
'babel-plugin-annotate-pure-calls',
'./pure-plugin.js',
['@babel/plugin-transform-strict-mode', { strict: true }],
'babel-plugin-loop-optimizer',
// 'emotion/babel'
]
: [
// Stage 0
//'@babel/plugin-proposal-function-bind',
// Stage 1
'@babel/plugin-proposal-export-default-from',
//'@babel/plugin-proposal-logical-assignment-operators',
['@babel/plugin-proposal-optional-chaining', { loose: true }],
//['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: true }],
//'@babel/plugin-proposal-do-expressions',
// Stage 2
['@babel/plugin-proposal-decorators', { legacy: true }],
//'@babel/plugin-proposal-function-sent',
'@babel/plugin-proposal-export-namespace-from',
//'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-throw-expressions',
'@babel/plugin-proposal-unicode-property-regex',
// Stage 3
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-proposal-json-strings',
['@babel/plugin-transform-react-jsx', { pragma: 'h', pragmaFrag: 'Fragment', useBuiltIns: true }],
// '@babel/plugin-transform-react-jsx-source', not useful for preact 06/04/2020
'babel-plugin-transform-console-log-variable-names',
'babel-plugin-console-groupify',
['@babel/plugin-transform-strict-mode', { strict: true }],
// 'emotion/babel'
// 'runtyper'
],
presets: [
[
'@babel/preset-env',
{
bugfixes: true,
exclude: ['transform-typeof-symbol'],
loose: true,
modules: 'auto',
shippedProposals: true,
targets: isProduction
? undefined // -> reads .browserlistrc
: {
browsers: 'unreleased Chrome versions',
},
useBuiltIns: false,
},
//'babel-preset-minify',
],
],
}
}