-
Notifications
You must be signed in to change notification settings - Fork 2
/
.devolutionrc.js
151 lines (133 loc) · 4.58 KB
/
.devolutionrc.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// devolution 🦎 -> 🦖
/**
what about shipping the BEST for the bleeding edge browsers?
(requires SSR or feature detection for proper shipping)
*/
const USE_MODERN = false;
module.exports = Promise.resolve({ // could be async
/**
* core-js version. Version 3 is more modern, while version 2 is more common
* this __must__ be synchoronized with corejs version visible to babel, and installed by you
* (if not installed, then it's v2)
*/
corejs: "3",
/**
* include proposals polyfills, core-js 3 only
*/
proposals: false,
/**
* if set to `false` it would SYMLINK files, effective keeping only one version for files
* not managed by devolution (read - non-js).
* If set to `true` - all files would be copied.
*/
copyFiles: false,
/**
* files to add could be RegExp or array
*/
match: /\.js$/,
/**
* these chunks expected to always be loaded, for example this could be your entry point(s)
*/
rootBundles: null,
/**
* are polyfills included in the baseline bundle? If yes no polyfills which "might be" required for esmodules target would be added
* IT'S BETTER TO INCLUDE THEM
* to prevent duplication among chunks
* (keep in mind - polyfills landed in the main bundle will not be duplicated)
*/
includesPolyfills: false,
/**
https://github.com/swc-project/swc
roughly TWICE faster than babel, used only for es5 target.
however, it produces a bit different code. PLEASE CHECK THE RESULT!
When to use: when babel is to slow, or failing our of memory
**/
useSWC: false,
/**
* the result bundle might be "prettied", so some light minification might be needed
*/
useTerser: true,
/**
* apply minification for the baseline bundle
*/
useTerserForBaseline: false,
/**
controls syntax and polyfill level
`esm` and `es5` are reserved keywords - `esm` means "no transformation required", and `es5` means - target is `es5`
the values inside are used to determine required polyfills
**/
targets: {
/**
* ESM controls ONLY polyfills. No code transformation to be made!
*/
esm: USE_MODERN
? {
"chrome": "70", // if baseline bundle used preset-modern use some "big" target, but ship only for this "big" target!
}
: {
// this controls polyfills for ESM bundle
// you might be surprised how many of them might be bundled
// core-js 3 : see https://github.com/zloirock/core-js/blob/master/packages/core-js-compat/src/data.js
// core-js 2 : see https://github.com/theKashey/devolution/blob/master/src/data/corejs2/built-ins.js
// if baseline bundle used preset-env+esmodules - https://github.com/babel/babel/blob/master/packages/babel-preset-env/data/built-in-modules.json
"edge": "16",
"firefox": "60",
"chrome": "61",
"safari": "10.1",
},
// es6: { something between IE5 and bleeding edge? }
/**
* the legacy target (you might need only it)
* it is roughly "just ES5". Target (ie11) controls polyfills
*/
es5: {
// list the lowest browser here, it would not affect the "language", only polyfills
"ie": "11", // do not support IE9, and IE10
},
},
/**
* plugins for the scan(detect polyfills) pass
*/
babelScan: [
'@babel/plugin-syntax-object-rest-spread',
'@babel/plugin-syntax-class-properties',
'@babel/plugin-syntax-dynamic-import',
],
/**
* plugins for transformation pass
*/
babelTransform: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
],
// some files might be excluded from polyfilling
dontPolyfill: [
/manifest/, // dont polyfill webpack manifest
],
// injects some target specific polyfills to the "main bundle"
addPolyfills: {
esm: [
// probably none?
],
es5: [
// which? what about a few "ignored" ones?
// or, like, regenerator runtime? (ignore it beforehand)
// 'regenerator-runtime',
]
},
/**
* Some polyfills might be "manually" bundled, or you just might dont need them - automatic detection is not perfect.
* Let's us know which...
*/
ignorePolyfills: [
// put a list of polyfills to ignore, they would be considered as already added
// WeakMap is defacto supported my IE11, but not listed compact table and would be included in any case
"es6.weak-map",
// almost any library has a failback for Symbol support
'es6.symbol',
'es7.symbol.async-iterator',
// and almost no library uses extra RegExp features
'es6.regexp.flags',
]
});