@atlaspack/transformer-typescript-types 2.14.5-canary.34 → 2.14.5-canary.340
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.
- package/CHANGELOG.md +359 -0
- package/dist/TSModule.js +40 -0
- package/dist/TSModuleGraph.js +233 -0
- package/dist/TSTypesTransformer.js +185 -0
- package/dist/collect.js +137 -0
- package/dist/shake.js +219 -0
- package/dist/utils.js +29 -0
- package/dist/wrappers.js +71 -0
- package/lib/TSModuleGraph.js +13 -0
- package/lib/TSTypesTransformer.js +7 -5
- package/lib/collect.js +28 -4
- package/lib/shake.js +24 -6
- package/lib/types/TSModule.d.ts +25 -0
- package/lib/types/TSModuleGraph.d.ts +33 -0
- package/lib/types/TSTypesTransformer.d.ts +3 -0
- package/lib/types/collect.d.ts +2 -0
- package/lib/types/shake.d.ts +2 -0
- package/lib/types/utils.d.ts +2 -0
- package/lib/types/wrappers.d.ts +8 -0
- package/lib/utils.js +4 -0
- package/lib/wrappers.js +5 -4
- package/package.json +14 -10
- package/src/{TSModule.js → TSModule.ts} +13 -6
- package/src/{TSModuleGraph.js → TSModuleGraph.ts} +48 -9
- package/src/{TSTypesTransformer.js → TSTypesTransformer.ts} +11 -11
- package/src/{collect.js → collect.ts} +22 -5
- package/src/{shake.js → shake.ts} +19 -6
- package/src/{utils.js → utils.ts} +3 -2
- package/src/{wrappers.js → wrappers.ts} +95 -58
- package/tsconfig.json +24 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,364 @@
|
|
|
1
1
|
# @atlaspack/transformer-typescript-types
|
|
2
2
|
|
|
3
|
+
## 2.15.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atlaspack/source-map@3.2.2
|
|
9
|
+
- @atlaspack/utils@3.2.8
|
|
10
|
+
- @atlaspack/plugin@2.14.47
|
|
11
|
+
- @atlaspack/ts-utils@2.14.26
|
|
12
|
+
|
|
13
|
+
## 2.15.7
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies []:
|
|
18
|
+
- @atlaspack/source-map@3.2.1
|
|
19
|
+
- @atlaspack/utils@3.2.7
|
|
20
|
+
- @atlaspack/plugin@2.14.46
|
|
21
|
+
- @atlaspack/ts-utils@2.14.25
|
|
22
|
+
|
|
23
|
+
## 2.15.6
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies []:
|
|
28
|
+
- @atlaspack/utils@3.2.6
|
|
29
|
+
- @atlaspack/plugin@2.14.45
|
|
30
|
+
- @atlaspack/ts-utils@2.14.24
|
|
31
|
+
|
|
32
|
+
## 2.15.5
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`c81b368`](https://github.com/atlassian-labs/atlaspack/commit/c81b368db20af701d9e019a11272b138f9cfe080)]:
|
|
37
|
+
- @atlaspack/source-map@3.2.0
|
|
38
|
+
- @atlaspack/utils@3.2.5
|
|
39
|
+
- @atlaspack/plugin@2.14.44
|
|
40
|
+
- @atlaspack/ts-utils@2.14.23
|
|
41
|
+
|
|
42
|
+
## 2.15.4
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies []:
|
|
47
|
+
- @atlaspack/plugin@2.14.43
|
|
48
|
+
- @atlaspack/utils@3.2.4
|
|
49
|
+
- @atlaspack/ts-utils@2.14.22
|
|
50
|
+
|
|
51
|
+
## 2.15.3
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies []:
|
|
56
|
+
- @atlaspack/source-map@3.1.3
|
|
57
|
+
- @atlaspack/utils@3.2.3
|
|
58
|
+
- @atlaspack/plugin@2.14.42
|
|
59
|
+
- @atlaspack/ts-utils@2.14.21
|
|
60
|
+
|
|
61
|
+
## 2.15.2
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [[`f6fc5e2`](https://github.com/atlassian-labs/atlaspack/commit/f6fc5e2acc30720f9a9676dfbc02bf780066653b)]:
|
|
66
|
+
- @atlaspack/source-map@3.1.2
|
|
67
|
+
- @atlaspack/utils@3.2.2
|
|
68
|
+
- @atlaspack/plugin@2.14.41
|
|
69
|
+
- @atlaspack/ts-utils@2.14.20
|
|
70
|
+
|
|
71
|
+
## 2.15.1
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Updated dependencies []:
|
|
76
|
+
- @atlaspack/source-map@3.1.1
|
|
77
|
+
- @atlaspack/utils@3.2.1
|
|
78
|
+
- @atlaspack/plugin@2.14.40
|
|
79
|
+
- @atlaspack/ts-utils@2.14.19
|
|
80
|
+
|
|
81
|
+
## 2.15.0
|
|
82
|
+
|
|
83
|
+
### Minor Changes
|
|
84
|
+
|
|
85
|
+
- [#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
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [[`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13)]:
|
|
90
|
+
- @atlaspack/source-map@3.1.0
|
|
91
|
+
- @atlaspack/utils@3.2.0
|
|
92
|
+
- @atlaspack/plugin@2.14.39
|
|
93
|
+
- @atlaspack/ts-utils@2.14.18
|
|
94
|
+
|
|
95
|
+
## 2.14.38
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- Updated dependencies [[`7d7a55d`](https://github.com/atlassian-labs/atlaspack/commit/7d7a55dd6395ec391a2e4c33b3dec0d1ea477d4c)]:
|
|
100
|
+
- @atlaspack/utils@3.1.2
|
|
101
|
+
- @atlaspack/plugin@2.14.38
|
|
102
|
+
- @atlaspack/ts-utils@2.14.17
|
|
103
|
+
|
|
104
|
+
## 2.14.37
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies []:
|
|
109
|
+
- @atlaspack/utils@3.1.1
|
|
110
|
+
- @atlaspack/plugin@2.14.37
|
|
111
|
+
- @atlaspack/ts-utils@2.14.16
|
|
112
|
+
|
|
113
|
+
## 2.14.36
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- Updated dependencies [[`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
|
|
118
|
+
- @atlaspack/utils@3.1.0
|
|
119
|
+
- @atlaspack/plugin@2.14.36
|
|
120
|
+
- @atlaspack/ts-utils@2.14.15
|
|
121
|
+
|
|
122
|
+
## 2.14.35
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- Updated dependencies [[`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10)]:
|
|
127
|
+
- @atlaspack/utils@3.0.3
|
|
128
|
+
- @atlaspack/plugin@2.14.35
|
|
129
|
+
- @atlaspack/ts-utils@2.14.14
|
|
130
|
+
|
|
131
|
+
## 2.14.34
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies []:
|
|
136
|
+
- @atlaspack/utils@3.0.2
|
|
137
|
+
- @atlaspack/plugin@2.14.34
|
|
138
|
+
- @atlaspack/ts-utils@2.14.13
|
|
139
|
+
|
|
140
|
+
## 2.14.33
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e)]:
|
|
145
|
+
- @atlaspack/utils@3.0.1
|
|
146
|
+
- @atlaspack/plugin@2.14.33
|
|
147
|
+
- @atlaspack/ts-utils@2.14.12
|
|
148
|
+
|
|
149
|
+
## 2.14.32
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [[`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
|
|
154
|
+
- @atlaspack/utils@3.0.0
|
|
155
|
+
- @atlaspack/plugin@2.14.32
|
|
156
|
+
- @atlaspack/ts-utils@2.14.11
|
|
157
|
+
|
|
158
|
+
## 2.14.31
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- [#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.
|
|
163
|
+
|
|
164
|
+
- Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
|
|
165
|
+
- @atlaspack/diagnostic@2.14.4
|
|
166
|
+
- @atlaspack/plugin@2.14.31
|
|
167
|
+
- @atlaspack/utils@2.19.3
|
|
168
|
+
- @atlaspack/ts-utils@2.14.10
|
|
169
|
+
|
|
170
|
+
## 2.14.30
|
|
171
|
+
|
|
172
|
+
### Patch Changes
|
|
173
|
+
|
|
174
|
+
- Updated dependencies []:
|
|
175
|
+
- @atlaspack/utils@2.19.2
|
|
176
|
+
- @atlaspack/plugin@2.14.30
|
|
177
|
+
- @atlaspack/ts-utils@2.14.9
|
|
178
|
+
|
|
179
|
+
## 2.14.29
|
|
180
|
+
|
|
181
|
+
### Patch Changes
|
|
182
|
+
|
|
183
|
+
- Updated dependencies []:
|
|
184
|
+
- @atlaspack/utils@2.19.1
|
|
185
|
+
- @atlaspack/plugin@2.14.29
|
|
186
|
+
- @atlaspack/ts-utils@2.14.8
|
|
187
|
+
|
|
188
|
+
## 2.14.28
|
|
189
|
+
|
|
190
|
+
### Patch Changes
|
|
191
|
+
|
|
192
|
+
- Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
|
|
193
|
+
- @atlaspack/utils@2.19.0
|
|
194
|
+
- @atlaspack/plugin@2.14.28
|
|
195
|
+
- @atlaspack/ts-utils@2.14.7
|
|
196
|
+
|
|
197
|
+
## 2.14.27
|
|
198
|
+
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- Updated dependencies []:
|
|
202
|
+
- @atlaspack/utils@2.18.4
|
|
203
|
+
- @atlaspack/plugin@2.14.27
|
|
204
|
+
- @atlaspack/ts-utils@2.14.6
|
|
205
|
+
|
|
206
|
+
## 2.14.26
|
|
207
|
+
|
|
208
|
+
### Patch Changes
|
|
209
|
+
|
|
210
|
+
- [#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
|
|
211
|
+
|
|
212
|
+
- Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
|
|
213
|
+
- @atlaspack/diagnostic@2.14.3
|
|
214
|
+
- @atlaspack/ts-utils@2.14.5
|
|
215
|
+
- @atlaspack/plugin@2.14.26
|
|
216
|
+
- @atlaspack/utils@2.18.3
|
|
217
|
+
|
|
218
|
+
## 2.14.25
|
|
219
|
+
|
|
220
|
+
### Patch Changes
|
|
221
|
+
|
|
222
|
+
- Updated dependencies []:
|
|
223
|
+
- @atlaspack/utils@2.18.2
|
|
224
|
+
- @atlaspack/plugin@2.14.25
|
|
225
|
+
- @atlaspack/ts-utils@2.14.4
|
|
226
|
+
|
|
227
|
+
## 2.14.24
|
|
228
|
+
|
|
229
|
+
### Patch Changes
|
|
230
|
+
|
|
231
|
+
- Updated dependencies []:
|
|
232
|
+
- @atlaspack/utils@2.18.1
|
|
233
|
+
- @atlaspack/plugin@2.14.24
|
|
234
|
+
- @atlaspack/ts-utils@2.14.3
|
|
235
|
+
|
|
236
|
+
## 2.14.23
|
|
237
|
+
|
|
238
|
+
### Patch Changes
|
|
239
|
+
|
|
240
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
241
|
+
- @atlaspack/utils@2.18.0
|
|
242
|
+
- @atlaspack/plugin@2.14.23
|
|
243
|
+
|
|
244
|
+
## 2.14.22
|
|
245
|
+
|
|
246
|
+
### Patch Changes
|
|
247
|
+
|
|
248
|
+
- [#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
|
|
249
|
+
|
|
250
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
251
|
+
- @atlaspack/diagnostic@2.14.2
|
|
252
|
+
- @atlaspack/ts-utils@2.14.2
|
|
253
|
+
- @atlaspack/plugin@2.14.22
|
|
254
|
+
- @atlaspack/utils@2.17.4
|
|
255
|
+
|
|
256
|
+
## 2.14.21
|
|
257
|
+
|
|
258
|
+
### Patch Changes
|
|
259
|
+
|
|
260
|
+
- Updated dependencies []:
|
|
261
|
+
- @atlaspack/utils@2.17.3
|
|
262
|
+
- @atlaspack/plugin@2.14.21
|
|
263
|
+
|
|
264
|
+
## 2.14.20
|
|
265
|
+
|
|
266
|
+
### Patch Changes
|
|
267
|
+
|
|
268
|
+
- [#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
|
|
269
|
+
|
|
270
|
+
- Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
|
|
271
|
+
- @atlaspack/plugin@2.14.20
|
|
272
|
+
- @atlaspack/utils@2.17.2
|
|
273
|
+
|
|
274
|
+
## 2.14.19
|
|
275
|
+
|
|
276
|
+
### Patch Changes
|
|
277
|
+
|
|
278
|
+
- Updated dependencies []:
|
|
279
|
+
- @atlaspack/utils@2.17.1
|
|
280
|
+
- @atlaspack/plugin@2.14.19
|
|
281
|
+
|
|
282
|
+
## 2.14.18
|
|
283
|
+
|
|
284
|
+
### Patch Changes
|
|
285
|
+
|
|
286
|
+
- 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)]:
|
|
287
|
+
- @atlaspack/utils@2.17.0
|
|
288
|
+
- @atlaspack/plugin@2.14.18
|
|
289
|
+
|
|
290
|
+
## 2.14.17
|
|
291
|
+
|
|
292
|
+
### Patch Changes
|
|
293
|
+
|
|
294
|
+
- Updated dependencies []:
|
|
295
|
+
- @atlaspack/utils@2.16.1
|
|
296
|
+
- @atlaspack/plugin@2.14.17
|
|
297
|
+
|
|
298
|
+
## 2.14.16
|
|
299
|
+
|
|
300
|
+
### Patch Changes
|
|
301
|
+
|
|
302
|
+
- Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
|
|
303
|
+
- @atlaspack/utils@2.16.0
|
|
304
|
+
- @atlaspack/plugin@2.14.16
|
|
305
|
+
|
|
306
|
+
## 2.14.15
|
|
307
|
+
|
|
308
|
+
### Patch Changes
|
|
309
|
+
|
|
310
|
+
- Updated dependencies []:
|
|
311
|
+
- @atlaspack/utils@2.15.3
|
|
312
|
+
- @atlaspack/plugin@2.14.15
|
|
313
|
+
|
|
314
|
+
## 2.14.14
|
|
315
|
+
|
|
316
|
+
### Patch Changes
|
|
317
|
+
|
|
318
|
+
- Updated dependencies []:
|
|
319
|
+
- @atlaspack/utils@2.15.2
|
|
320
|
+
- @atlaspack/plugin@2.14.14
|
|
321
|
+
|
|
322
|
+
## 2.14.13
|
|
323
|
+
|
|
324
|
+
### Patch Changes
|
|
325
|
+
|
|
326
|
+
- Updated dependencies []:
|
|
327
|
+
- @atlaspack/utils@2.15.1
|
|
328
|
+
- @atlaspack/plugin@2.14.13
|
|
329
|
+
|
|
330
|
+
## 2.14.12
|
|
331
|
+
|
|
332
|
+
### Patch Changes
|
|
333
|
+
|
|
334
|
+
- Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
335
|
+
- @atlaspack/utils@2.15.0
|
|
336
|
+
- @atlaspack/plugin@2.14.12
|
|
337
|
+
|
|
338
|
+
## 2.14.11
|
|
339
|
+
|
|
340
|
+
### Patch Changes
|
|
341
|
+
|
|
342
|
+
- Updated dependencies []:
|
|
343
|
+
- @atlaspack/utils@2.14.11
|
|
344
|
+
- @atlaspack/plugin@2.14.11
|
|
345
|
+
|
|
346
|
+
## 2.14.10
|
|
347
|
+
|
|
348
|
+
### Patch Changes
|
|
349
|
+
|
|
350
|
+
- Updated dependencies []:
|
|
351
|
+
- @atlaspack/plugin@2.14.10
|
|
352
|
+
- @atlaspack/utils@2.14.10
|
|
353
|
+
|
|
354
|
+
## 2.14.9
|
|
355
|
+
|
|
356
|
+
### Patch Changes
|
|
357
|
+
|
|
358
|
+
- Updated dependencies []:
|
|
359
|
+
- @atlaspack/utils@2.14.9
|
|
360
|
+
- @atlaspack/plugin@2.14.9
|
|
361
|
+
|
|
3
362
|
## 2.14.8
|
|
4
363
|
|
|
5
364
|
### Patch Changes
|
package/dist/TSModule.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TSModule = void 0;
|
|
4
|
+
class TSModule {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.imports = new Map();
|
|
7
|
+
this.exports = [];
|
|
8
|
+
this.bindings = new Map();
|
|
9
|
+
this.names = new Map();
|
|
10
|
+
this.used = new Set();
|
|
11
|
+
}
|
|
12
|
+
addImport(local, specifier, imported) {
|
|
13
|
+
this.imports.set(local, { specifier, imported });
|
|
14
|
+
if (imported !== '*' && imported !== 'default') {
|
|
15
|
+
this.names.set(local, local);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// if not a reexport: imported = local, name = exported
|
|
19
|
+
addExport(name, imported, specifier) {
|
|
20
|
+
this.exports.push({ name, specifier, imported });
|
|
21
|
+
}
|
|
22
|
+
addWildcardExport(specifier) {
|
|
23
|
+
this.exports.push({ specifier });
|
|
24
|
+
}
|
|
25
|
+
addLocal(name, node) {
|
|
26
|
+
const bindings = this.bindings.get(name) ?? new Set();
|
|
27
|
+
bindings.add(node);
|
|
28
|
+
this.bindings.set(name, bindings);
|
|
29
|
+
if (name !== 'default') {
|
|
30
|
+
this.names.set(name, name);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
getName(name) {
|
|
34
|
+
return this.names.get(name) || name;
|
|
35
|
+
}
|
|
36
|
+
hasBinding(name) {
|
|
37
|
+
return this.bindings.has(name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.TSModule = TSModule;
|
|
@@ -0,0 +1,233 @@
|
|
|
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.TSModuleGraph = void 0;
|
|
7
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
8
|
+
const assert_1 = __importDefault(require("assert"));
|
|
9
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
10
|
+
class TSModuleGraph {
|
|
11
|
+
constructor(mainModuleName) {
|
|
12
|
+
this.modules = new Map();
|
|
13
|
+
this.mainModuleName = mainModuleName;
|
|
14
|
+
this.mainModule = null;
|
|
15
|
+
this.syntheticImportCount = 0;
|
|
16
|
+
}
|
|
17
|
+
addModule(name, module) {
|
|
18
|
+
this.modules.set(name, module);
|
|
19
|
+
if (name === this.mainModuleName) {
|
|
20
|
+
this.mainModule = module;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
getModule(name) {
|
|
24
|
+
return this.modules.get(name);
|
|
25
|
+
}
|
|
26
|
+
markUsed(module, name, context) {
|
|
27
|
+
// If name is imported, mark used in the original module
|
|
28
|
+
if (module.imports.has(name)) {
|
|
29
|
+
module.used.add(name);
|
|
30
|
+
let resolved = this.resolveImport(module, name);
|
|
31
|
+
// Missing or external
|
|
32
|
+
if (!resolved || resolved.module === module) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
return this.markUsed(resolved.module, resolved.imported, context);
|
|
36
|
+
}
|
|
37
|
+
if (module.used.has(name)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
module.used.add(name);
|
|
41
|
+
// Visit all child nodes of the original binding and mark any referenced types as used.
|
|
42
|
+
let visit = (node) => {
|
|
43
|
+
if (typescript_1.default.isQualifiedName(node) && typescript_1.default.isIdentifier(node.left)) {
|
|
44
|
+
let resolved = this.resolveImport(module, node.left.text, node.right.text);
|
|
45
|
+
if (resolved) {
|
|
46
|
+
this.markUsed(resolved.module, resolved.imported, context);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (typescript_1.default.isIdentifier(node)) {
|
|
50
|
+
this.markUsed(module, node.text, context);
|
|
51
|
+
}
|
|
52
|
+
return typescript_1.default.visitEachChild(node, visit, context);
|
|
53
|
+
};
|
|
54
|
+
let bindings = module.bindings.get(name);
|
|
55
|
+
if (bindings) {
|
|
56
|
+
for (let node of bindings) {
|
|
57
|
+
typescript_1.default.visitEachChild(node, visit, context);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getExport(m, e) {
|
|
62
|
+
// @ts-expect-error TS2339
|
|
63
|
+
(0, assert_1.default)(e.name != null);
|
|
64
|
+
// @ts-expect-error TS2339
|
|
65
|
+
let exportName = e.name;
|
|
66
|
+
// Re-export
|
|
67
|
+
// @ts-expect-error TS2339
|
|
68
|
+
if (e.specifier && e.imported) {
|
|
69
|
+
let m = this.getModule(e.specifier);
|
|
70
|
+
if (!m) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
// @ts-expect-error TS2339
|
|
74
|
+
let exp = this.resolveExport(m, e.imported);
|
|
75
|
+
if (!exp) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
module: exp.module,
|
|
80
|
+
imported: exp.imported || exp.name,
|
|
81
|
+
name: exportName,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Import and then export
|
|
85
|
+
if (m.imports.has(exportName)) {
|
|
86
|
+
let imp = this.resolveImport(m, exportName);
|
|
87
|
+
if (!imp) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return { module: imp.module, imported: imp.name, name: exportName };
|
|
91
|
+
}
|
|
92
|
+
// Named export
|
|
93
|
+
return {
|
|
94
|
+
module: m,
|
|
95
|
+
name: exportName,
|
|
96
|
+
// @ts-expect-error TS2339
|
|
97
|
+
imported: e.imported != null ? m.getName(e.imported) : exportName,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
resolveImport(module, local, imported) {
|
|
101
|
+
let i = module.imports.get(local);
|
|
102
|
+
if (!i) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
let m = this.getModule(i.specifier);
|
|
106
|
+
if (!m) {
|
|
107
|
+
// External module. pass through the import.
|
|
108
|
+
return { module, name: local, imported: imported || i.imported };
|
|
109
|
+
}
|
|
110
|
+
return this.resolveExport(m, imported || i.imported);
|
|
111
|
+
}
|
|
112
|
+
resolveExport(module, name) {
|
|
113
|
+
for (let e of module.exports) {
|
|
114
|
+
// @ts-expect-error TS2339
|
|
115
|
+
if (e.name === name) {
|
|
116
|
+
return this.getExport(module, e);
|
|
117
|
+
}
|
|
118
|
+
else if (e.specifier) {
|
|
119
|
+
const m = this.resolveExport((0, nullthrows_1.default)(this.getModule(e.specifier)), name);
|
|
120
|
+
if (m) {
|
|
121
|
+
return m;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
getAllExports(module = (0, nullthrows_1.default)(this.mainModule), excludeDefault = false) {
|
|
127
|
+
let res = [];
|
|
128
|
+
for (let e of module.exports) {
|
|
129
|
+
// @ts-expect-error TS2339
|
|
130
|
+
if (e.name && (!excludeDefault || e.name !== 'default')) {
|
|
131
|
+
let exp = this.getExport(module, e);
|
|
132
|
+
if (exp) {
|
|
133
|
+
res.push(exp);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else if (e.specifier) {
|
|
137
|
+
let m = this.getModule(e.specifier);
|
|
138
|
+
if (m) {
|
|
139
|
+
res.push(...this.getAllExports(m, true));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return res;
|
|
144
|
+
}
|
|
145
|
+
getAllImports() {
|
|
146
|
+
// Build a map of all imports for external modules
|
|
147
|
+
let importsBySpecifier = new Map();
|
|
148
|
+
for (let module of this.modules.values()) {
|
|
149
|
+
for (let [name, imp] of module.imports) {
|
|
150
|
+
if (module.used.has(name) && !this.modules.has(imp.specifier)) {
|
|
151
|
+
let importMap = importsBySpecifier.get(imp.specifier);
|
|
152
|
+
if (!importMap) {
|
|
153
|
+
importMap = new Map();
|
|
154
|
+
importsBySpecifier.set(imp.specifier, importMap);
|
|
155
|
+
}
|
|
156
|
+
name = module.getName(name);
|
|
157
|
+
importMap.set(name, imp.imported);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return importsBySpecifier;
|
|
162
|
+
}
|
|
163
|
+
propagate(context) {
|
|
164
|
+
// Resolve all exported values, and mark them as used.
|
|
165
|
+
let names = Object.create(null);
|
|
166
|
+
let exportedNames = new Map();
|
|
167
|
+
for (let e of this.getAllExports()) {
|
|
168
|
+
this.markUsed(e.module, e.imported, context);
|
|
169
|
+
e.module.names.set(e.imported, e.name);
|
|
170
|
+
names[e.name] = 1;
|
|
171
|
+
exportedNames.set(e.name, e.module);
|
|
172
|
+
}
|
|
173
|
+
let importedSymbolsToUpdate = [];
|
|
174
|
+
// Assign unique names across all modules
|
|
175
|
+
for (let m of this.modules.values()) {
|
|
176
|
+
for (let [orig, name] of m.names) {
|
|
177
|
+
if (exportedNames.has(name) && exportedNames.get(name) === m) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (!m.used.has(orig)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (m.imports.has(orig)) {
|
|
184
|
+
// Update imports after all modules's local variables have been renamed
|
|
185
|
+
importedSymbolsToUpdate.push([m, orig]);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (names[name]) {
|
|
189
|
+
m.names.set(name, `_${name}${names[name]++}`);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
names[name] = 1;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Map of imported specifiers -> map of imported names to local names
|
|
197
|
+
let imports = new Map();
|
|
198
|
+
for (let [m, orig] of importedSymbolsToUpdate) {
|
|
199
|
+
// @ts-expect-error TS2339
|
|
200
|
+
let imp = (0, nullthrows_1.default)(m.imports.get(orig));
|
|
201
|
+
// @ts-expect-error TS2345
|
|
202
|
+
let imported = (0, nullthrows_1.default)(this.resolveImport(m, orig));
|
|
203
|
+
// If the module is bundled, map the local name to the original exported name.
|
|
204
|
+
if (this.modules.has(imp.specifier)) {
|
|
205
|
+
// @ts-expect-error TS2339
|
|
206
|
+
m.names.set(orig, imported.imported);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
// If it's external, then we need to dedup duplicate imported names, and ensure
|
|
210
|
+
// that they do not conflict with any exported or local names.
|
|
211
|
+
let importedNames = imports.get(imp.specifier);
|
|
212
|
+
if (!importedNames) {
|
|
213
|
+
importedNames = new Map();
|
|
214
|
+
imports.set(imp.specifier, importedNames);
|
|
215
|
+
}
|
|
216
|
+
let name = importedNames.get(imported.imported);
|
|
217
|
+
if (!name) {
|
|
218
|
+
if (names[imported.imported]) {
|
|
219
|
+
name = `_${imported.imported}${names[imported.imported]++}`;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
name = imported.imported;
|
|
223
|
+
names[imported.imported] = 1;
|
|
224
|
+
}
|
|
225
|
+
importedNames.set(imported.imported, name);
|
|
226
|
+
}
|
|
227
|
+
// @ts-expect-error TS2339
|
|
228
|
+
m.names.set(orig, name);
|
|
229
|
+
}
|
|
230
|
+
return exportedNames;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.TSModuleGraph = TSModuleGraph;
|