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

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 +493 -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,498 @@
1
1
  # @atlaspack/transformer-babel
2
2
 
3
+ ## 2.15.24
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/utils@3.4.5
9
+ - @atlaspack/source-map@3.3.7
10
+ - @atlaspack/plugin@2.14.63
11
+
12
+ ## 2.15.23
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies []:
17
+ - @atlaspack/utils@3.4.4
18
+ - @atlaspack/source-map@3.3.6
19
+ - @atlaspack/plugin@2.14.62
20
+
21
+ ## 2.15.22
22
+
23
+ ### Patch Changes
24
+
25
+ - [#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
26
+
27
+ - Updated dependencies [[`e898fda`](https://github.com/atlassian-labs/atlaspack/commit/e898fda7511d98e5597d847c4a32c028a8a24d6c)]:
28
+ - @atlaspack/utils@3.4.3
29
+ - @atlaspack/source-map@3.3.5
30
+ - @atlaspack/plugin@2.14.61
31
+
32
+ ## 2.15.21
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies []:
37
+ - @atlaspack/source-map@3.3.4
38
+ - @atlaspack/utils@3.4.2
39
+ - @atlaspack/plugin@2.14.60
40
+
41
+ ## 2.15.20
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies []:
46
+ - @atlaspack/source-map@3.3.3
47
+ - @atlaspack/utils@3.4.1
48
+ - @atlaspack/plugin@2.14.59
49
+
50
+ ## 2.15.19
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [[`71981ea`](https://github.com/atlassian-labs/atlaspack/commit/71981eac258f7e6dfb40ec4b202d194f71c64ff1)]:
55
+ - @atlaspack/utils@3.4.0
56
+ - @atlaspack/source-map@3.3.2
57
+ - @atlaspack/plugin@2.14.58
58
+
59
+ ## 2.15.18
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies []:
64
+ - @atlaspack/utils@3.3.9
65
+ - @atlaspack/source-map@3.3.1
66
+ - @atlaspack/plugin@2.14.57
67
+
68
+ ## 2.15.17
69
+
70
+ ### Patch Changes
71
+
72
+ - Updated dependencies [[`de388ff`](https://github.com/atlassian-labs/atlaspack/commit/de388ff76d39dece97ad475fcccdb6efb6283bfc)]:
73
+ - @atlaspack/source-map@3.3.0
74
+ - @atlaspack/utils@3.3.8
75
+ - @atlaspack/plugin@2.14.56
76
+
77
+ ## 2.15.16
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies []:
82
+ - @atlaspack/source-map@3.2.10
83
+ - @atlaspack/utils@3.3.7
84
+ - @atlaspack/plugin@2.14.55
85
+
86
+ ## 2.15.15
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [[`d8e984b`](https://github.com/atlassian-labs/atlaspack/commit/d8e984b7f6d04fa03707fa299bfd8b8bf9f58280)]:
91
+ - @atlaspack/utils@3.3.6
92
+ - @atlaspack/source-map@3.2.9
93
+ - @atlaspack/plugin@2.14.54
94
+
95
+ ## 2.15.14
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies []:
100
+ - @atlaspack/source-map@3.2.8
101
+ - @atlaspack/utils@3.3.5
102
+ - @atlaspack/plugin@2.14.53
103
+
104
+ ## 2.15.13
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies []:
109
+ - @atlaspack/plugin@2.14.52
110
+ - @atlaspack/utils@3.3.4
111
+ - @atlaspack/source-map@3.2.7
112
+
113
+ ## 2.15.12
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies []:
118
+ - @atlaspack/source-map@3.2.6
119
+ - @atlaspack/utils@3.3.3
120
+ - @atlaspack/plugin@2.14.51
121
+
122
+ ## 2.15.11
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies []:
127
+ - @atlaspack/source-map@3.2.5
128
+ - @atlaspack/utils@3.3.2
129
+ - @atlaspack/plugin@2.14.50
130
+
131
+ ## 2.15.10
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies []:
136
+ - @atlaspack/source-map@3.2.4
137
+ - @atlaspack/utils@3.3.1
138
+ - @atlaspack/plugin@2.14.49
139
+
140
+ ## 2.15.9
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies [[`47aa84e`](https://github.com/atlassian-labs/atlaspack/commit/47aa84e44c61066072a5bf3d57678565b9d2c5a3)]:
145
+ - @atlaspack/utils@3.3.0
146
+ - @atlaspack/source-map@3.2.3
147
+ - @atlaspack/plugin@2.14.48
148
+
149
+ ## 2.15.8
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies []:
154
+ - @atlaspack/source-map@3.2.2
155
+ - @atlaspack/utils@3.2.8
156
+ - @atlaspack/plugin@2.14.47
157
+
158
+ ## 2.15.7
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies []:
163
+ - @atlaspack/source-map@3.2.1
164
+ - @atlaspack/utils@3.2.7
165
+ - @atlaspack/plugin@2.14.46
166
+
167
+ ## 2.15.6
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies []:
172
+ - @atlaspack/utils@3.2.6
173
+ - @atlaspack/plugin@2.14.45
174
+
175
+ ## 2.15.5
176
+
177
+ ### Patch Changes
178
+
179
+ - Updated dependencies [[`c81b368`](https://github.com/atlassian-labs/atlaspack/commit/c81b368db20af701d9e019a11272b138f9cfe080)]:
180
+ - @atlaspack/source-map@3.2.0
181
+ - @atlaspack/utils@3.2.5
182
+ - @atlaspack/plugin@2.14.44
183
+
184
+ ## 2.15.4
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies []:
189
+ - @atlaspack/plugin@2.14.43
190
+ - @atlaspack/utils@3.2.4
191
+
192
+ ## 2.15.3
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies []:
197
+ - @atlaspack/source-map@3.1.3
198
+ - @atlaspack/utils@3.2.3
199
+ - @atlaspack/plugin@2.14.42
200
+
201
+ ## 2.15.2
202
+
203
+ ### Patch Changes
204
+
205
+ - Updated dependencies [[`f6fc5e2`](https://github.com/atlassian-labs/atlaspack/commit/f6fc5e2acc30720f9a9676dfbc02bf780066653b)]:
206
+ - @atlaspack/source-map@3.1.2
207
+ - @atlaspack/utils@3.2.2
208
+ - @atlaspack/plugin@2.14.41
209
+
210
+ ## 2.15.1
211
+
212
+ ### Patch Changes
213
+
214
+ - Updated dependencies []:
215
+ - @atlaspack/source-map@3.1.1
216
+ - @atlaspack/utils@3.2.1
217
+ - @atlaspack/plugin@2.14.40
218
+
219
+ ## 2.15.0
220
+
221
+ ### Minor Changes
222
+
223
+ - [#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
224
+
225
+ ### Patch Changes
226
+
227
+ - Updated dependencies [[`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13)]:
228
+ - @atlaspack/source-map@3.1.0
229
+ - @atlaspack/utils@3.2.0
230
+ - @atlaspack/plugin@2.14.39
231
+
232
+ ## 2.14.38
233
+
234
+ ### Patch Changes
235
+
236
+ - Updated dependencies [[`7d7a55d`](https://github.com/atlassian-labs/atlaspack/commit/7d7a55dd6395ec391a2e4c33b3dec0d1ea477d4c)]:
237
+ - @atlaspack/utils@3.1.2
238
+ - @atlaspack/plugin@2.14.38
239
+
240
+ ## 2.14.37
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies []:
245
+ - @atlaspack/utils@3.1.1
246
+ - @atlaspack/plugin@2.14.37
247
+
248
+ ## 2.14.36
249
+
250
+ ### Patch Changes
251
+
252
+ - Updated dependencies [[`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
253
+ - @atlaspack/utils@3.1.0
254
+ - @atlaspack/plugin@2.14.36
255
+
256
+ ## 2.14.35
257
+
258
+ ### Patch Changes
259
+
260
+ - Updated dependencies [[`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10)]:
261
+ - @atlaspack/utils@3.0.3
262
+ - @atlaspack/plugin@2.14.35
263
+
264
+ ## 2.14.34
265
+
266
+ ### Patch Changes
267
+
268
+ - [#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
269
+
270
+ - Updated dependencies []:
271
+ - @atlaspack/utils@3.0.2
272
+ - @atlaspack/plugin@2.14.34
273
+
274
+ ## 2.14.33
275
+
276
+ ### Patch Changes
277
+
278
+ - [#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
279
+ - Introduce `omitSourcesContentInMemory` feature flag to stop retaining full source text in `sourcesContent` throughout transforms. Default OFF; behavior unchanged unless enabled.
280
+ - Guard `asset.sourceContent` initialization and `setSourceContent`/`sourcesContent` copies behind the flag.
281
+ - Mappings and source paths remain correct; packager still inlines or references sources per config.
282
+
283
+ Memory (three-js benchmark, V3, 1 run):
284
+ - Baseline OFF: later, larger compactions near end of build (e.g. `~44.2s Mark-Compact 20.4 (50.2) -> 12.5 (53.5) MB`).
285
+ - 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`).
286
+
287
+ Sourcemaps: unchanged by default; with flag ON, only the in-memory retention is removed.
288
+
289
+ - Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e)]:
290
+ - @atlaspack/utils@3.0.1
291
+ - @atlaspack/plugin@2.14.33
292
+
293
+ ## 2.14.32
294
+
295
+ ### Patch Changes
296
+
297
+ - Updated dependencies [[`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
298
+ - @atlaspack/utils@3.0.0
299
+ - @atlaspack/plugin@2.14.32
300
+
301
+ ## 2.14.31
302
+
303
+ ### Patch Changes
304
+
305
+ - [#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.
306
+
307
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
308
+ - @atlaspack/diagnostic@2.14.4
309
+ - @atlaspack/plugin@2.14.31
310
+ - @atlaspack/utils@2.19.3
311
+
312
+ ## 2.14.30
313
+
314
+ ### Patch Changes
315
+
316
+ - Updated dependencies []:
317
+ - @atlaspack/utils@2.19.2
318
+ - @atlaspack/plugin@2.14.30
319
+
320
+ ## 2.14.29
321
+
322
+ ### Patch Changes
323
+
324
+ - Updated dependencies []:
325
+ - @atlaspack/utils@2.19.1
326
+ - @atlaspack/plugin@2.14.29
327
+
328
+ ## 2.14.28
329
+
330
+ ### Patch Changes
331
+
332
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
333
+ - @atlaspack/utils@2.19.0
334
+ - @atlaspack/plugin@2.14.28
335
+
336
+ ## 2.14.27
337
+
338
+ ### Patch Changes
339
+
340
+ - Updated dependencies []:
341
+ - @atlaspack/utils@2.18.4
342
+ - @atlaspack/plugin@2.14.27
343
+
344
+ ## 2.14.26
345
+
346
+ ### Patch Changes
347
+
348
+ - [#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
349
+
350
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
351
+ - @atlaspack/diagnostic@2.14.3
352
+ - @atlaspack/plugin@2.14.26
353
+ - @atlaspack/utils@2.18.3
354
+
355
+ ## 2.14.25
356
+
357
+ ### Patch Changes
358
+
359
+ - Updated dependencies []:
360
+ - @atlaspack/utils@2.18.2
361
+ - @atlaspack/plugin@2.14.25
362
+
363
+ ## 2.14.24
364
+
365
+ ### Patch Changes
366
+
367
+ - Updated dependencies []:
368
+ - @atlaspack/utils@2.18.1
369
+ - @atlaspack/plugin@2.14.24
370
+
371
+ ## 2.14.23
372
+
373
+ ### Patch Changes
374
+
375
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
376
+ - @atlaspack/utils@2.18.0
377
+ - @atlaspack/plugin@2.14.23
378
+
379
+ ## 2.14.22
380
+
381
+ ### Patch Changes
382
+
383
+ - [#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
384
+
385
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
386
+ - @atlaspack/diagnostic@2.14.2
387
+ - @atlaspack/plugin@2.14.22
388
+ - @atlaspack/utils@2.17.4
389
+
390
+ ## 2.14.21
391
+
392
+ ### Patch Changes
393
+
394
+ - Updated dependencies []:
395
+ - @atlaspack/utils@2.17.3
396
+ - @atlaspack/plugin@2.14.21
397
+
398
+ ## 2.14.20
399
+
400
+ ### Patch Changes
401
+
402
+ - [#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
403
+
404
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
405
+ - @atlaspack/plugin@2.14.20
406
+ - @atlaspack/utils@2.17.2
407
+
408
+ ## 2.14.19
409
+
410
+ ### Patch Changes
411
+
412
+ - Updated dependencies []:
413
+ - @atlaspack/utils@2.17.1
414
+ - @atlaspack/plugin@2.14.19
415
+
416
+ ## 2.14.18
417
+
418
+ ### Patch Changes
419
+
420
+ - 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)]:
421
+ - @atlaspack/utils@2.17.0
422
+ - @atlaspack/plugin@2.14.18
423
+
424
+ ## 2.14.17
425
+
426
+ ### Patch Changes
427
+
428
+ - Updated dependencies []:
429
+ - @atlaspack/utils@2.16.1
430
+ - @atlaspack/plugin@2.14.17
431
+
432
+ ## 2.14.16
433
+
434
+ ### Patch Changes
435
+
436
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
437
+ - @atlaspack/utils@2.16.0
438
+ - @atlaspack/plugin@2.14.16
439
+
440
+ ## 2.14.15
441
+
442
+ ### Patch Changes
443
+
444
+ - Updated dependencies []:
445
+ - @atlaspack/utils@2.15.3
446
+ - @atlaspack/plugin@2.14.15
447
+
448
+ ## 2.14.14
449
+
450
+ ### Patch Changes
451
+
452
+ - Updated dependencies []:
453
+ - @atlaspack/utils@2.15.2
454
+ - @atlaspack/plugin@2.14.14
455
+
456
+ ## 2.14.13
457
+
458
+ ### Patch Changes
459
+
460
+ - Updated dependencies []:
461
+ - @atlaspack/utils@2.15.1
462
+ - @atlaspack/plugin@2.14.13
463
+
464
+ ## 2.14.12
465
+
466
+ ### Patch Changes
467
+
468
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
469
+ - @atlaspack/utils@2.15.0
470
+ - @atlaspack/plugin@2.14.12
471
+
472
+ ## 2.14.11
473
+
474
+ ### Patch Changes
475
+
476
+ - Updated dependencies []:
477
+ - @atlaspack/utils@2.14.11
478
+ - @atlaspack/plugin@2.14.11
479
+
480
+ ## 2.14.10
481
+
482
+ ### Patch Changes
483
+
484
+ - Updated dependencies []:
485
+ - @atlaspack/plugin@2.14.10
486
+ - @atlaspack/utils@2.14.10
487
+
488
+ ## 2.14.9
489
+
490
+ ### Patch Changes
491
+
492
+ - Updated dependencies []:
493
+ - @atlaspack/utils@2.14.9
494
+ - @atlaspack/plugin@2.14.9
495
+
3
496
  ## 2.14.8
4
497
 
5
498
  ### 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
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.babelErrorEnhancer = babelErrorEnhancer;
4
+ async function babelErrorEnhancer(error, asset) {
5
+ if (error.loc) {
6
+ let start = error.message.startsWith(asset.filePath)
7
+ ? asset.filePath.length + 1
8
+ : 0;
9
+ error.message = error.message.slice(start).split('\n')[0].trim();
10
+ }
11
+ error.source = await asset.getCode();
12
+ error.filePath = asset.filePath;
13
+ return error;
14
+ }