@atlaspack/transformer-babel 2.14.5-canary.49 → 2.14.5-canary.491

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +502 -0
  2. package/dist/BabelTransformer.js +85 -0
  3. package/dist/babel7.js +110 -0
  4. package/dist/babelErrorUtils.js +14 -0
  5. package/dist/config.js +328 -0
  6. package/dist/constants.js +4 -0
  7. package/dist/flow.js +43 -0
  8. package/dist/jsx.js +33 -0
  9. package/dist/remapAstLocations.js +49 -0
  10. package/dist/types.js +2 -0
  11. package/dist/utils.js +85 -0
  12. package/lib/BabelTransformer.js +4 -3
  13. package/lib/babel7.js +6 -3
  14. package/lib/config.js +8 -2
  15. package/lib/flow.js +3 -1
  16. package/lib/jsx.js +1 -1
  17. package/lib/remapAstLocations.js +8 -11
  18. package/lib/types/BabelTransformer.d.ts +3 -0
  19. package/lib/types/babel7.d.ts +11 -0
  20. package/lib/types/babelErrorUtils.d.ts +10 -0
  21. package/lib/types/config.d.ts +10 -0
  22. package/lib/types/constants.d.ts +1 -0
  23. package/lib/types/flow.d.ts +6 -0
  24. package/lib/types/jsx.d.ts +6 -0
  25. package/lib/types/remapAstLocations.d.ts +3 -0
  26. package/lib/types/types.d.ts +4 -0
  27. package/lib/types/utils.d.ts +3 -0
  28. package/lib/utils.js +4 -1
  29. package/package.json +15 -11
  30. package/src/{BabelTransformer.js → BabelTransformer.ts} +8 -7
  31. package/src/{babel7.js → babel7.ts} +15 -14
  32. package/src/{babelErrorUtils.js → babelErrorUtils.ts} +5 -8
  33. package/src/{config.js → config.ts} +49 -23
  34. package/src/{constants.js → constants.ts} +0 -2
  35. package/src/{flow.js → flow.ts} +3 -4
  36. package/src/{jsx.js → jsx.ts} +0 -2
  37. package/src/{remapAstLocations.js → remapAstLocations.ts} +6 -11
  38. package/src/types.ts +4 -0
  39. package/src/{utils.js → utils.ts} +4 -4
  40. package/tsconfig.json +24 -0
  41. package/tsconfig.tsbuildinfo +1 -0
  42. package/src/types.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,507 @@
1
1
  # @atlaspack/transformer-babel
2
2
 
3
+ ## 2.15.25
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/source-map@3.3.8
9
+ - @atlaspack/utils@3.4.6
10
+ - @atlaspack/plugin@2.14.64
11
+
12
+ ## 2.15.24
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies []:
17
+ - @atlaspack/utils@3.4.5
18
+ - @atlaspack/source-map@3.3.7
19
+ - @atlaspack/plugin@2.14.63
20
+
21
+ ## 2.15.23
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies []:
26
+ - @atlaspack/utils@3.4.4
27
+ - @atlaspack/source-map@3.3.6
28
+ - @atlaspack/plugin@2.14.62
29
+
30
+ ## 2.15.22
31
+
32
+ ### Patch Changes
33
+
34
+ - [#1065](https://github.com/atlassian-labs/atlaspack/pull/1065) [`e898fda`](https://github.com/atlassian-labs/atlaspack/commit/e898fda7511d98e5597d847c4a32c028a8a24d6c) Thanks [@at-nathan](https://github.com/at-nathan)! - Update third-party dependencies to align with AFM
35
+
36
+ - Updated dependencies [[`e898fda`](https://github.com/atlassian-labs/atlaspack/commit/e898fda7511d98e5597d847c4a32c028a8a24d6c)]:
37
+ - @atlaspack/utils@3.4.3
38
+ - @atlaspack/source-map@3.3.5
39
+ - @atlaspack/plugin@2.14.61
40
+
41
+ ## 2.15.21
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies []:
46
+ - @atlaspack/source-map@3.3.4
47
+ - @atlaspack/utils@3.4.2
48
+ - @atlaspack/plugin@2.14.60
49
+
50
+ ## 2.15.20
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies []:
55
+ - @atlaspack/source-map@3.3.3
56
+ - @atlaspack/utils@3.4.1
57
+ - @atlaspack/plugin@2.14.59
58
+
59
+ ## 2.15.19
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies [[`71981ea`](https://github.com/atlassian-labs/atlaspack/commit/71981eac258f7e6dfb40ec4b202d194f71c64ff1)]:
64
+ - @atlaspack/utils@3.4.0
65
+ - @atlaspack/source-map@3.3.2
66
+ - @atlaspack/plugin@2.14.58
67
+
68
+ ## 2.15.18
69
+
70
+ ### Patch Changes
71
+
72
+ - Updated dependencies []:
73
+ - @atlaspack/utils@3.3.9
74
+ - @atlaspack/source-map@3.3.1
75
+ - @atlaspack/plugin@2.14.57
76
+
77
+ ## 2.15.17
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies [[`de388ff`](https://github.com/atlassian-labs/atlaspack/commit/de388ff76d39dece97ad475fcccdb6efb6283bfc)]:
82
+ - @atlaspack/source-map@3.3.0
83
+ - @atlaspack/utils@3.3.8
84
+ - @atlaspack/plugin@2.14.56
85
+
86
+ ## 2.15.16
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies []:
91
+ - @atlaspack/source-map@3.2.10
92
+ - @atlaspack/utils@3.3.7
93
+ - @atlaspack/plugin@2.14.55
94
+
95
+ ## 2.15.15
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [[`d8e984b`](https://github.com/atlassian-labs/atlaspack/commit/d8e984b7f6d04fa03707fa299bfd8b8bf9f58280)]:
100
+ - @atlaspack/utils@3.3.6
101
+ - @atlaspack/source-map@3.2.9
102
+ - @atlaspack/plugin@2.14.54
103
+
104
+ ## 2.15.14
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies []:
109
+ - @atlaspack/source-map@3.2.8
110
+ - @atlaspack/utils@3.3.5
111
+ - @atlaspack/plugin@2.14.53
112
+
113
+ ## 2.15.13
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies []:
118
+ - @atlaspack/plugin@2.14.52
119
+ - @atlaspack/utils@3.3.4
120
+ - @atlaspack/source-map@3.2.7
121
+
122
+ ## 2.15.12
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies []:
127
+ - @atlaspack/source-map@3.2.6
128
+ - @atlaspack/utils@3.3.3
129
+ - @atlaspack/plugin@2.14.51
130
+
131
+ ## 2.15.11
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies []:
136
+ - @atlaspack/source-map@3.2.5
137
+ - @atlaspack/utils@3.3.2
138
+ - @atlaspack/plugin@2.14.50
139
+
140
+ ## 2.15.10
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies []:
145
+ - @atlaspack/source-map@3.2.4
146
+ - @atlaspack/utils@3.3.1
147
+ - @atlaspack/plugin@2.14.49
148
+
149
+ ## 2.15.9
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [[`47aa84e`](https://github.com/atlassian-labs/atlaspack/commit/47aa84e44c61066072a5bf3d57678565b9d2c5a3)]:
154
+ - @atlaspack/utils@3.3.0
155
+ - @atlaspack/source-map@3.2.3
156
+ - @atlaspack/plugin@2.14.48
157
+
158
+ ## 2.15.8
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies []:
163
+ - @atlaspack/source-map@3.2.2
164
+ - @atlaspack/utils@3.2.8
165
+ - @atlaspack/plugin@2.14.47
166
+
167
+ ## 2.15.7
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies []:
172
+ - @atlaspack/source-map@3.2.1
173
+ - @atlaspack/utils@3.2.7
174
+ - @atlaspack/plugin@2.14.46
175
+
176
+ ## 2.15.6
177
+
178
+ ### Patch Changes
179
+
180
+ - Updated dependencies []:
181
+ - @atlaspack/utils@3.2.6
182
+ - @atlaspack/plugin@2.14.45
183
+
184
+ ## 2.15.5
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies [[`c81b368`](https://github.com/atlassian-labs/atlaspack/commit/c81b368db20af701d9e019a11272b138f9cfe080)]:
189
+ - @atlaspack/source-map@3.2.0
190
+ - @atlaspack/utils@3.2.5
191
+ - @atlaspack/plugin@2.14.44
192
+
193
+ ## 2.15.4
194
+
195
+ ### Patch Changes
196
+
197
+ - Updated dependencies []:
198
+ - @atlaspack/plugin@2.14.43
199
+ - @atlaspack/utils@3.2.4
200
+
201
+ ## 2.15.3
202
+
203
+ ### Patch Changes
204
+
205
+ - Updated dependencies []:
206
+ - @atlaspack/source-map@3.1.3
207
+ - @atlaspack/utils@3.2.3
208
+ - @atlaspack/plugin@2.14.42
209
+
210
+ ## 2.15.2
211
+
212
+ ### Patch Changes
213
+
214
+ - Updated dependencies [[`f6fc5e2`](https://github.com/atlassian-labs/atlaspack/commit/f6fc5e2acc30720f9a9676dfbc02bf780066653b)]:
215
+ - @atlaspack/source-map@3.1.2
216
+ - @atlaspack/utils@3.2.2
217
+ - @atlaspack/plugin@2.14.41
218
+
219
+ ## 2.15.1
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies []:
224
+ - @atlaspack/source-map@3.1.1
225
+ - @atlaspack/utils@3.2.1
226
+ - @atlaspack/plugin@2.14.40
227
+
228
+ ## 2.15.0
229
+
230
+ ### Minor Changes
231
+
232
+ - [#789](https://github.com/atlassian-labs/atlaspack/pull/789) [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0) Thanks [@marcins](https://github.com/marcins)! - Use an in-sourced version of @parcel/source-map, as @atlaspack/source-map
233
+
234
+ ### Patch Changes
235
+
236
+ - Updated dependencies [[`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13)]:
237
+ - @atlaspack/source-map@3.1.0
238
+ - @atlaspack/utils@3.2.0
239
+ - @atlaspack/plugin@2.14.39
240
+
241
+ ## 2.14.38
242
+
243
+ ### Patch Changes
244
+
245
+ - Updated dependencies [[`7d7a55d`](https://github.com/atlassian-labs/atlaspack/commit/7d7a55dd6395ec391a2e4c33b3dec0d1ea477d4c)]:
246
+ - @atlaspack/utils@3.1.2
247
+ - @atlaspack/plugin@2.14.38
248
+
249
+ ## 2.14.37
250
+
251
+ ### Patch Changes
252
+
253
+ - Updated dependencies []:
254
+ - @atlaspack/utils@3.1.1
255
+ - @atlaspack/plugin@2.14.37
256
+
257
+ ## 2.14.36
258
+
259
+ ### Patch Changes
260
+
261
+ - Updated dependencies [[`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
262
+ - @atlaspack/utils@3.1.0
263
+ - @atlaspack/plugin@2.14.36
264
+
265
+ ## 2.14.35
266
+
267
+ ### Patch Changes
268
+
269
+ - Updated dependencies [[`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10)]:
270
+ - @atlaspack/utils@3.0.3
271
+ - @atlaspack/plugin@2.14.35
272
+
273
+ ## 2.14.34
274
+
275
+ ### Patch Changes
276
+
277
+ - [#782](https://github.com/atlassian-labs/atlaspack/pull/782) [`25cbee6`](https://github.com/atlassian-labs/atlaspack/commit/25cbee625fb47ac20423fe34ff37bc818a807245) Thanks [@yamadapc](https://github.com/yamadapc)! - Initial atlaspack-inspector release
278
+
279
+ - Updated dependencies []:
280
+ - @atlaspack/utils@3.0.2
281
+ - @atlaspack/plugin@2.14.34
282
+
283
+ ## 2.14.33
284
+
285
+ ### Patch Changes
286
+
287
+ - [#803](https://github.com/atlassian-labs/atlaspack/pull/803) [`f07351a`](https://github.com/atlassian-labs/atlaspack/commit/f07351a2398b6a8e5155a2daad77e69b7dcb2b4b) Thanks [@shanshrew](https://github.com/shanshrew)! - feat(core, transformers): add feature-flag to omit sourcesContent from memory; reduce peak memory during builds
288
+ - Introduce `omitSourcesContentInMemory` feature flag to stop retaining full source text in `sourcesContent` throughout transforms. Default OFF; behavior unchanged unless enabled.
289
+ - Guard `asset.sourceContent` initialization and `setSourceContent`/`sourcesContent` copies behind the flag.
290
+ - Mappings and source paths remain correct; packager still inlines or references sources per config.
291
+
292
+ Memory (three-js benchmark, V3, 1 run):
293
+ - Baseline OFF: later, larger compactions near end of build (e.g. `~44.2s Mark-Compact 20.4 (50.2) -> 12.5 (53.5) MB`).
294
+ - Flag ON: earlier compactions during transform/packaging, keeping old space ≈10–11 MB (e.g. `~17.7s Mark-Compact 11.5 (28.0) -> 9.6 (27.5) MB`).
295
+
296
+ Sourcemaps: unchanged by default; with flag ON, only the in-memory retention is removed.
297
+
298
+ - Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e)]:
299
+ - @atlaspack/utils@3.0.1
300
+ - @atlaspack/plugin@2.14.33
301
+
302
+ ## 2.14.32
303
+
304
+ ### Patch Changes
305
+
306
+ - Updated dependencies [[`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
307
+ - @atlaspack/utils@3.0.0
308
+ - @atlaspack/plugin@2.14.32
309
+
310
+ ## 2.14.31
311
+
312
+ ### Patch Changes
313
+
314
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
315
+
316
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
317
+ - @atlaspack/diagnostic@2.14.4
318
+ - @atlaspack/plugin@2.14.31
319
+ - @atlaspack/utils@2.19.3
320
+
321
+ ## 2.14.30
322
+
323
+ ### Patch Changes
324
+
325
+ - Updated dependencies []:
326
+ - @atlaspack/utils@2.19.2
327
+ - @atlaspack/plugin@2.14.30
328
+
329
+ ## 2.14.29
330
+
331
+ ### Patch Changes
332
+
333
+ - Updated dependencies []:
334
+ - @atlaspack/utils@2.19.1
335
+ - @atlaspack/plugin@2.14.29
336
+
337
+ ## 2.14.28
338
+
339
+ ### Patch Changes
340
+
341
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
342
+ - @atlaspack/utils@2.19.0
343
+ - @atlaspack/plugin@2.14.28
344
+
345
+ ## 2.14.27
346
+
347
+ ### Patch Changes
348
+
349
+ - Updated dependencies []:
350
+ - @atlaspack/utils@2.18.4
351
+ - @atlaspack/plugin@2.14.27
352
+
353
+ ## 2.14.26
354
+
355
+ ### Patch Changes
356
+
357
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
358
+
359
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
360
+ - @atlaspack/diagnostic@2.14.3
361
+ - @atlaspack/plugin@2.14.26
362
+ - @atlaspack/utils@2.18.3
363
+
364
+ ## 2.14.25
365
+
366
+ ### Patch Changes
367
+
368
+ - Updated dependencies []:
369
+ - @atlaspack/utils@2.18.2
370
+ - @atlaspack/plugin@2.14.25
371
+
372
+ ## 2.14.24
373
+
374
+ ### Patch Changes
375
+
376
+ - Updated dependencies []:
377
+ - @atlaspack/utils@2.18.1
378
+ - @atlaspack/plugin@2.14.24
379
+
380
+ ## 2.14.23
381
+
382
+ ### Patch Changes
383
+
384
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
385
+ - @atlaspack/utils@2.18.0
386
+ - @atlaspack/plugin@2.14.23
387
+
388
+ ## 2.14.22
389
+
390
+ ### Patch Changes
391
+
392
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
393
+
394
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
395
+ - @atlaspack/diagnostic@2.14.2
396
+ - @atlaspack/plugin@2.14.22
397
+ - @atlaspack/utils@2.17.4
398
+
399
+ ## 2.14.21
400
+
401
+ ### Patch Changes
402
+
403
+ - Updated dependencies []:
404
+ - @atlaspack/utils@2.17.3
405
+ - @atlaspack/plugin@2.14.21
406
+
407
+ ## 2.14.20
408
+
409
+ ### Patch Changes
410
+
411
+ - [#702](https://github.com/atlassian-labs/atlaspack/pull/702) [`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa) Thanks [@alshdavid](https://github.com/alshdavid)! - Fixes to Flow types
412
+
413
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
414
+ - @atlaspack/plugin@2.14.20
415
+ - @atlaspack/utils@2.17.2
416
+
417
+ ## 2.14.19
418
+
419
+ ### Patch Changes
420
+
421
+ - Updated dependencies []:
422
+ - @atlaspack/utils@2.17.1
423
+ - @atlaspack/plugin@2.14.19
424
+
425
+ ## 2.14.18
426
+
427
+ ### Patch Changes
428
+
429
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
430
+ - @atlaspack/utils@2.17.0
431
+ - @atlaspack/plugin@2.14.18
432
+
433
+ ## 2.14.17
434
+
435
+ ### Patch Changes
436
+
437
+ - Updated dependencies []:
438
+ - @atlaspack/utils@2.16.1
439
+ - @atlaspack/plugin@2.14.17
440
+
441
+ ## 2.14.16
442
+
443
+ ### Patch Changes
444
+
445
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
446
+ - @atlaspack/utils@2.16.0
447
+ - @atlaspack/plugin@2.14.16
448
+
449
+ ## 2.14.15
450
+
451
+ ### Patch Changes
452
+
453
+ - Updated dependencies []:
454
+ - @atlaspack/utils@2.15.3
455
+ - @atlaspack/plugin@2.14.15
456
+
457
+ ## 2.14.14
458
+
459
+ ### Patch Changes
460
+
461
+ - Updated dependencies []:
462
+ - @atlaspack/utils@2.15.2
463
+ - @atlaspack/plugin@2.14.14
464
+
465
+ ## 2.14.13
466
+
467
+ ### Patch Changes
468
+
469
+ - Updated dependencies []:
470
+ - @atlaspack/utils@2.15.1
471
+ - @atlaspack/plugin@2.14.13
472
+
473
+ ## 2.14.12
474
+
475
+ ### Patch Changes
476
+
477
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
478
+ - @atlaspack/utils@2.15.0
479
+ - @atlaspack/plugin@2.14.12
480
+
481
+ ## 2.14.11
482
+
483
+ ### Patch Changes
484
+
485
+ - Updated dependencies []:
486
+ - @atlaspack/utils@2.14.11
487
+ - @atlaspack/plugin@2.14.11
488
+
489
+ ## 2.14.10
490
+
491
+ ### Patch Changes
492
+
493
+ - Updated dependencies []:
494
+ - @atlaspack/plugin@2.14.10
495
+ - @atlaspack/utils@2.14.10
496
+
497
+ ## 2.14.9
498
+
499
+ ### Patch Changes
500
+
501
+ - Updated dependencies []:
502
+ - @atlaspack/utils@2.14.9
503
+ - @atlaspack/plugin@2.14.9
504
+
3
505
  ## 2.14.8
4
506
 
5
507
  ### Patch Changes
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const babelErrorUtils_1 = require("./babelErrorUtils");
7
+ const plugin_1 = require("@atlaspack/plugin");
8
+ const utils_1 = require("@atlaspack/utils");
9
+ const source_map_1 = __importDefault(require("@atlaspack/source-map"));
10
+ const semver_1 = __importDefault(require("semver"));
11
+ const babel7_1 = __importDefault(require("./babel7"));
12
+ const config_1 = require("./config");
13
+ exports.default = new plugin_1.Transformer({
14
+ loadConfig({ config, options, logger }) {
15
+ return (0, config_1.load)(config, options, logger);
16
+ },
17
+ canReuseAST({ ast }) {
18
+ return ast.type === 'babel' && semver_1.default.satisfies(ast.version, '^7.0.0');
19
+ },
20
+ async transform({ asset, config, logger, options, tracer }) {
21
+ try {
22
+ if (config?.config) {
23
+ if (asset.meta.babelPlugins != null &&
24
+ Array.isArray(asset.meta.babelPlugins)) {
25
+ await (0, babel7_1.default)({
26
+ asset,
27
+ options,
28
+ logger,
29
+ babelOptions: config,
30
+ additionalPlugins: asset.meta.babelPlugins,
31
+ tracer,
32
+ });
33
+ }
34
+ else {
35
+ await (0, babel7_1.default)({
36
+ asset,
37
+ options,
38
+ logger,
39
+ babelOptions: config,
40
+ tracer,
41
+ });
42
+ }
43
+ }
44
+ return [asset];
45
+ }
46
+ catch (e) {
47
+ throw await (0, babelErrorUtils_1.babelErrorEnhancer)(e, asset);
48
+ }
49
+ },
50
+ async generate({ asset, ast, options }) {
51
+ let originalSourceMap = await asset.getMap();
52
+ let sourceFileName = (0, utils_1.relativeUrl)(options.projectRoot, asset.filePath);
53
+ const babelCorePath = await options.packageManager.resolve('@babel/core', asset.filePath, {
54
+ range: '^7.12.0',
55
+ saveDev: true,
56
+ shouldAutoInstall: options.shouldAutoInstall,
57
+ });
58
+ const { default: generate } = await options.packageManager.require('@babel/generator', babelCorePath.resolved);
59
+ let { code, rawMappings } = generate(ast.program, {
60
+ sourceFileName,
61
+ sourceMaps: !!asset.env.sourceMap,
62
+ comments: true,
63
+ });
64
+ let map = new source_map_1.default(options.projectRoot);
65
+ if (rawMappings) {
66
+ map.addIndexedMappings(rawMappings);
67
+ }
68
+ if (originalSourceMap &&
69
+ options.featureFlags?.omitSourcesContentInMemory !== true) {
70
+ // The babel AST already contains the correct mappings, but not the source contents.
71
+ // We need to copy over the source contents from the original map.
72
+ let sourcesContent = originalSourceMap.getSourcesContentMap();
73
+ for (let filePath in sourcesContent) {
74
+ let content = sourcesContent[filePath];
75
+ if (content != null) {
76
+ map.setSourceContent(filePath, content);
77
+ }
78
+ }
79
+ }
80
+ return {
81
+ content: code,
82
+ map,
83
+ };
84
+ },
85
+ });
package/dist/babel7.js ADDED
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = babel7;
7
+ const assert_1 = __importDefault(require("assert"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const diagnostic_1 = require("@atlaspack/diagnostic");
10
+ const utils_1 = require("@atlaspack/utils");
11
+ const remapAstLocations_1 = require("./remapAstLocations");
12
+ const package_json_1 = __importDefault(require("../package.json"));
13
+ const transformerVersion = package_json_1.default.version;
14
+ (0, assert_1.default)(typeof transformerVersion === 'string');
15
+ async function babel7(opts) {
16
+ let { asset, options, babelOptions, additionalPlugins = [], tracer } = opts;
17
+ // @ts-expect-error TS2709
18
+ const babelCore = await options.packageManager.require('@babel/core', asset.filePath, {
19
+ range: '^7.12.0',
20
+ saveDev: true,
21
+ shouldAutoInstall: options.shouldAutoInstall,
22
+ });
23
+ let config = {
24
+ ...babelOptions.config,
25
+ plugins: additionalPlugins.concat(babelOptions.config.plugins),
26
+ code: false,
27
+ ast: true,
28
+ filename: asset.filePath,
29
+ babelrc: false,
30
+ configFile: false,
31
+ parserOpts: {
32
+ ...babelOptions.config.parserOpts,
33
+ sourceFilename: (0, utils_1.relativeUrl)(options.projectRoot, asset.filePath),
34
+ allowReturnOutsideFunction: true,
35
+ strictMode: false,
36
+ sourceType: 'module',
37
+ plugins: [
38
+ ...(babelOptions.config.parserOpts?.plugins ?? []),
39
+ ...(babelOptions.syntaxPlugins ?? []),
40
+ // Applied by preset-env
41
+ 'classProperties',
42
+ 'classPrivateProperties',
43
+ 'classPrivateMethods',
44
+ 'exportDefaultFrom',
45
+ // 'topLevelAwait'
46
+ ],
47
+ },
48
+ caller: {
49
+ name: 'parcel',
50
+ version: transformerVersion,
51
+ targets: JSON.stringify(babelOptions.targets),
52
+ outputFormat: asset.env.outputFormat,
53
+ },
54
+ };
55
+ if (tracer.enabled) {
56
+ config.wrapPluginVisitorMethod = (key, nodeType, fn) => {
57
+ return function () {
58
+ let pluginKey = key;
59
+ if (pluginKey.startsWith(options.projectRoot)) {
60
+ pluginKey = path_1.default.relative(options.projectRoot, pluginKey);
61
+ }
62
+ const measurement = tracer.createMeasurement(pluginKey, nodeType, path_1.default.relative(options.projectRoot, asset.filePath));
63
+ // @ts-expect-error TS2683
64
+ fn.apply(this, arguments);
65
+ measurement && measurement.end();
66
+ };
67
+ };
68
+ }
69
+ let ast = await asset.getAST();
70
+ let res;
71
+ if (ast) {
72
+ res = await babelCore.transformFromAstAsync(ast.program, asset.isASTDirty() ? undefined : await asset.getCode(), config);
73
+ }
74
+ else {
75
+ res = await babelCore.transformAsync(await asset.getCode(), config);
76
+ if (res.ast) {
77
+ let map = await asset.getMap();
78
+ if (map) {
79
+ (0, remapAstLocations_1.remapAstLocations)(babelCore.types, res.ast, map);
80
+ }
81
+ }
82
+ if (res.externalDependencies) {
83
+ for (let f of res.externalDependencies) {
84
+ if (!path_1.default.isAbsolute(f)) {
85
+ opts.logger.warn({
86
+ message: (0, diagnostic_1.md) `Ignoring non-absolute Babel external dependency: ${f}`,
87
+ hints: [
88
+ 'Please report this to the corresponding Babel plugin and/or to Parcel.',
89
+ ],
90
+ });
91
+ }
92
+ else {
93
+ if (await options.inputFS.exists(f)) {
94
+ asset.invalidateOnFileChange(f);
95
+ }
96
+ else {
97
+ asset.invalidateOnFileCreate({ filePath: f });
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ if (res.ast) {
104
+ asset.setAST({
105
+ type: 'babel',
106
+ version: '7.0.0',
107
+ program: res.ast,
108
+ });
109
+ }
110
+ }