Debian Codegraph @

docs/migration.md

raw symbols SCIP
1 ## Migration from `preset-env` and `plugin-transform-runtime`
2
3 All the existig capabilities of `@babel/preset-env` and `@babel/plugin-transform-runtime` related to `core-js` are supported by the polyfill providers implemented in this repository.
4
5 ### `core-js@3`
6
7 <!-- prettier-ignore-start -->
8 <table>
9 <thead><tr>
10 <th align="center">Old configuration</th>
11 <th align="center">New configuration</th>
12 </tr></thead>
13 <tr>
14 <td>
15
16 ```json
17 {
18 "presets": [
19 ["@babel/preset-env", {
20 "targets": { "firefox": 42 },
21 "useBuiltIns": "usage",
22 "corejs": 3
23 }]
24 ]
25 }
26 ```
27
28 </td>
29 <td>
30
31 ```json
32 {
33 "targets": { "firefox": 42 },
34 "presets": ["@babel/preset-env"],
35 "plugins": [
36 ["polyfill-corejs3", {
37 "method": "usage-global"
38 }]
39 ]
40 }
41 ```
42
43 </td>
44 </tr>
45 </table>
46 <!-- prettier-ignore-end -->
47
48
49 <!-- prettier-ignore-start -->
50 <table>
51 <thead><tr>
52 <th align="center">Old configuration</th>
53 <th align="center">New configuration</th>
54 </tr></thead>
55 <tr>
56 <td>
57
58 ```json
59 {
60 "presets": [
61 ["@babel/preset-env", {
62 "targets": { "firefox": 42 },
63 "useBuiltIns": "entry",
64 "corejs": 3
65 }]
66 ]
67 }
68 ```
69
70 </td>
71 <td>
72
73 ```json
74 {
75 "targets": { "firefox": 42 },
76 "presets": ["@babel/preset-env"],
77 "plugins": [
78 ["polyfill-corejs3", {
79 "method": "entry-global"
80 }]
81 ]
82 }
83 ```
84
85 </td>
86 </tr>
87 </table>
88 <!-- prettier-ignore-end -->
89
90
91 <!-- prettier-ignore-start -->
92 <table>
93 <thead><tr>
94 <th align="center">Old configuration</th>
95 <th align="center">New configuration</th>
96 </tr></thead>
97 <tr>
98 <td>
99
100 ```json
101 {
102 "presets": [
103 ["@babel/preset-env", {
104 "targets": { "firefox": 42 }
105 }]
106 ],
107 "plugins": [
108 ["@babel/transform-runtime", {
109 "corejs": 3
110 }]
111 ]
112 }
113 ```
114
115 </td>
116 <td>
117
118 ```json
119 {
120 "presets": [
121 ["@babel/preset-env", {
122 "targets": { "firefox": 42 }
123 }]
124 ],
125 "plugins": [
126 "@babel/transform-runtime",
127 ["polyfill-corejs3", {
128 "method": "usage-pure"
129 }]
130 ]
131 }
132 ```
133
134 **NOTE**: The "Old" config doesn't support targets for polyfills, but you'll likely want to enable them by moving the `targets` option to the top-level.
135
136 </td>
137 </tr>
138 </table>
139 <!-- prettier-ignore-end -->
140
141 ### `es-shims`
142
143 <!-- prettier-ignore-start -->
144 <table>
145 <thead><tr>
146 <th align="center">Old configuration (with <code>core-js</code>)</th>
147 <th align="center">New configuration</th>
148 </tr></thead>
149 <tr>
150 <td>
151
152 ```json
153 {
154 "presets": [
155 ["@babel/preset-env", {
156 "targets": { "firefox": 42 },
157 "useBuiltIns": "usage",
158 "corejs": 3
159 }]
160 ]
161 }
162 ```
163
164 </td>
165 <td>
166
167 ```json
168 {
169 "targets": { "firefox": 42 },
170 "presets": ["@babel/preset-env"],
171 "plugins": [
172 ["polyfill-es-shims", {
173 "method": "usage-global"
174 }]
175 ]
176 }
177 ```
178
179 </td>
180 </tr>
181 </table>
182 <!-- prettier-ignore-end -->
183
184 <!-- prettier-ignore-start -->
185 <table>
186 <thead><tr>
187 <th align="center">Old configuration (with <code>core-js</code>)</th>
188 <th align="center">New configuration</th>
189 </tr></thead>
190 <tr>
191 <td>
192
193 ```json
194 {
195 "presets": [
196 ["@babel/preset-env", {
197 "targets": { "firefox": 42 }
198 }]
199 ],
200 "plugins": [
201 ["@babel/transform-runtime", {
202 "corejs": 3
203 }]
204 ]
205 }
206 ```
207
208 </td>
209 <td>
210
211 ```json
212 {
213 "presets": [
214 ["@babel/preset-env", {
215 "targets": { "firefox": 42 }
216 }]
217 ],
218 "plugins": [
219 "@babel/transform-runtime",
220 ["polyfill-es-shims", {
221 "method": "usage-pure",
222 }]
223 ]
224 }
225 ```
226
227 **NOTE**: The "Old" config doesn't support targets for polyfills, but you'll likely want to enable them by moving the `targets` option to the top-level.
228
229 </td>
230 </tr>
231 </table>
232 <!-- prettier-ignore-end -->
233
234 ### `core-js@2`
235
236 <!-- prettier-ignore-start -->
237 <table>
238 <thead><tr>
239 <th align="center">Old configuration</th>
240 <th align="center">New configuration</th>
241 </tr></thead>
242 <tr>
243 <td>
244
245 ```json
246 {
247 "presets": [
248 ["@babel/preset-env", {
249 "targets": { "firefox": 42 },
250 "useBuiltIns": "usage",
251 "corejs": 2
252 }]
253 ]
254 }
255 ```
256
257 </td>
258 <td>
259
260 ```json
261 {
262 "targets": { "firefox": 42 },
263 "presets": ["@babel/preset-env"],
264 "plugins": [
265 ["polyfill-corejs2", {
266 "method": "usage-global"
267 }]
268 ]
269 }
270 ```
271
272 </td>
273 </tr>
274 </table>
275 <!-- prettier-ignore-end -->
276
277
278 <!-- prettier-ignore-start -->
279 <table>
280 <thead><tr>
281 <th align="center">Old configuration</th>
282 <th align="center">New configuration</th>
283 </tr></thead>
284 <tr>
285 <td>
286
287 ```json
288 {
289 "presets": [
290 ["@babel/preset-env", {
291 "targets": { "firefox": 42 },
292 "useBuiltIns": "entry",
293 "corejs": 2
294 }]
295 ]
296 }
297 ```
298
299 </td>
300 <td>
301
302 ```json
303 {
304 "targets": { "firefox": 42 },
305 "presets": ["@babel/preset-env"],
306 "plugins": [
307 ["polyfill-corejs2", {
308 "method": "entry-global"
309 }]
310 ]
311 }
312 ```
313
314 </td>
315 </tr>
316 </table>
317 <!-- prettier-ignore-end -->
318
319 <!-- prettier-ignore-start -->
320 <table>
321 <thead><tr>
322 <th align="center">Old configuration</th>
323 <th align="center">New configuration</th>
324 </tr></thead>
325 <tr>
326 <td>
327
328 ```json
329 {
330 "presets": [
331 ["@babel/preset-env", {
332 "targets": { "firefox": 42 }
333 }]
334 ],
335 "plugins": [
336 ["@babel/transform-runtime", {
337 "corejs": 2
338 }]
339 ]
340 }
341 ```
342
343 </td>
344 <td>
345
346 ```json
347 {
348 "presets": [
349 ["@babel/preset-env", {
350 "targets": { "firefox": 42 }
351 }]
352 ],
353 "plugins": [
354 "@babel/transform-runtime",
355 ["polyfill-corejs2", {
356 "method": "usage-pure"
357 }]
358 ]
359 }
360 ```
361
362 **NOTE**: The "Old" config doesn't support targets for polyfills, but you'll likely want to enable them by moving the `targets` option to the top-level.
363
364 </td>
365 </tr>
366 </table>
367 <!-- prettier-ignore-end -->