@atlaspack/transformer-js 3.3.9 → 3.3.11-typescript-08dcc1c9b.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2024 Atlassian US., Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -188,18 +188,25 @@ var _default = exports.default = new (_plugin().Transformer)({
188
188
  })) === null || _await$config$getConf === void 0 || (_await$config$getConf = _await$config$getConf.contents) === null || _await$config$getConf === void 0 ? void 0 : _await$config$getConf.compilerOptions;
189
189
 
190
190
  // Use explicitly defined JSX options in tsconfig.json over inferred values from dependencies.
191
- pragma = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFactory) || (reactLib ? JSX_PRAGMA[reactLib].pragma : undefined);
192
- pragmaFrag = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFragmentFactory) || (reactLib ? JSX_PRAGMA[reactLib].pragmaFrag : undefined);
191
+ pragma = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFactory) || (
192
+ // @ts-expect-error TS7053
193
+ reactLib ? JSX_PRAGMA[reactLib].pragma : undefined);
194
+ pragmaFrag = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFragmentFactory) || (
195
+ // @ts-expect-error TS7053
196
+ reactLib ? JSX_PRAGMA[reactLib].pragmaFrag : undefined);
193
197
  if ((compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsx) === 'react-jsx' || (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsx) === 'react-jsxdev' || compilerOptions !== null && compilerOptions !== void 0 && compilerOptions.jsxImportSource) {
194
198
  jsxImportSource = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxImportSource;
195
199
  automaticJSXRuntime = true;
196
200
  } else if (reactLib) {
197
201
  var _JSX_PRAGMA$effective, _packageJson$dependen3, _packageJson$devDepen3, _packageJson$peerDepe3, _semver$minVersion;
198
202
  let effectiveReactLib = packageJson !== null && packageJson !== void 0 && packageJson.alias && packageJson.alias['react'] === 'preact/compat' ? 'preact' : reactLib;
203
+ // @ts-expect-error TS7053
199
204
  let automaticVersion = (_JSX_PRAGMA$effective = JSX_PRAGMA[effectiveReactLib]) === null || _JSX_PRAGMA$effective === void 0 ? void 0 : _JSX_PRAGMA$effective.automatic;
200
205
  let reactLibVersion = (packageJson === null || packageJson === void 0 || (_packageJson$dependen3 = packageJson.dependencies) === null || _packageJson$dependen3 === void 0 ? void 0 : _packageJson$dependen3[effectiveReactLib]) || (packageJson === null || packageJson === void 0 || (_packageJson$devDepen3 = packageJson.devDependencies) === null || _packageJson$devDepen3 === void 0 ? void 0 : _packageJson$devDepen3[effectiveReactLib]) || (packageJson === null || packageJson === void 0 || (_packageJson$peerDepe3 = packageJson.peerDependencies) === null || _packageJson$peerDepe3 === void 0 ? void 0 : _packageJson$peerDepe3[effectiveReactLib]);
206
+ // @ts-expect-error TS2322
201
207
  reactLibVersion = reactLibVersion ? _semver().default.validRange(reactLibVersion) : null;
202
- let minReactLibVersion = reactLibVersion !== null && reactLibVersion !== '*' ? (_semver$minVersion = _semver().default.minVersion(reactLibVersion)) === null || _semver$minVersion === void 0 ? void 0 : _semver$minVersion.toString() : null;
208
+ let minReactLibVersion = reactLibVersion !== null && reactLibVersion !== '*' ? // @ts-expect-error TS2345
209
+ (_semver$minVersion = _semver().default.minVersion(reactLibVersion)) === null || _semver$minVersion === void 0 ? void 0 : _semver$minVersion.toString() : null;
203
210
  automaticJSXRuntime = automaticVersion && !(compilerOptions !== null && compilerOptions !== void 0 && compilerOptions.jsxFactory) && minReactLibVersion != null && _semver().default.satisfies(minReactLibVersion, automaticVersion, {
204
211
  includePrerelease: true
205
212
  });
@@ -242,10 +249,16 @@ var _default = exports.default = new (_plugin().Transformer)({
242
249
  },
243
250
  // FIXME
244
251
  '@atlaspack/transformer-js', 'Invalid config for @atlaspack/transformer-js');
252
+
253
+ // @ts-expect-error TS2339
245
254
  magicComments = ((_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.magicComments) ?? magicComments;
255
+ // @ts-expect-error TS2339
246
256
  inlineEnvironment = ((_conf$contents2 = conf.contents) === null || _conf$contents2 === void 0 ? void 0 : _conf$contents2.inlineEnvironment) ?? inlineEnvironment;
257
+ // @ts-expect-error TS2339
247
258
  inlineFS = ((_conf$contents3 = conf.contents) === null || _conf$contents3 === void 0 ? void 0 : _conf$contents3.inlineFS) ?? inlineFS;
248
- inlineConstants = ((_conf$contents4 = conf.contents) === null || _conf$contents4 === void 0 ? void 0 : _conf$contents4.unstable_inlineConstants) ?? inlineConstants;
259
+ inlineConstants =
260
+ // @ts-expect-error TS2339
261
+ ((_conf$contents4 = conf.contents) === null || _conf$contents4 === void 0 ? void 0 : _conf$contents4.unstable_inlineConstants) ?? inlineConstants;
249
262
  }
250
263
  return {
251
264
  isJSX,
@@ -288,17 +301,22 @@ var _default = exports.default = new (_plugin().Transformer)({
288
301
  for (let browser of browsers) {
289
302
  let [name, version] = browser.split(' ');
290
303
  if (BROWSER_MAPPING.hasOwnProperty(name)) {
304
+ // @ts-expect-error TS7053
291
305
  name = BROWSER_MAPPING[name];
292
306
  if (!name) {
293
307
  continue;
294
308
  }
295
309
  }
296
310
  let [major, minor = '0', patch = '0'] = version.split('-')[0].split('.');
311
+ // @ts-expect-error TS2345
297
312
  if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
298
313
  continue;
299
314
  }
300
315
  let semverVersion = `${major}.${minor}.${patch}`;
316
+
317
+ // @ts-expect-error TS2345
301
318
  if (targets[name] == null || _semver().default.gt(targets[name], semverVersion)) {
319
+ // @ts-expect-error TS7053
302
320
  targets[name] = semverVersion;
303
321
  }
304
322
  }
@@ -333,23 +351,37 @@ var _default = exports.default = new (_plugin().Transformer)({
333
351
  if (asset.type === 'ts') {
334
352
  isJSX = false;
335
353
  } else if (!isJSX) {
354
+ // @ts-expect-error TS7053
336
355
  isJSX = Boolean(JSX_EXTENSIONS[asset.type]);
337
356
  }
338
357
  }
339
358
  let macroAssets = [];
340
359
  let {
360
+ // @ts-expect-error TS2339
341
361
  dependencies,
362
+ // @ts-expect-error TS2339
342
363
  code: compiledCode,
364
+ // @ts-expect-error TS2339
343
365
  map,
366
+ // @ts-expect-error TS2339
344
367
  shebang,
368
+ // @ts-expect-error TS2339
345
369
  hoist_result,
370
+ // @ts-expect-error TS2339
346
371
  symbol_result,
372
+ // @ts-expect-error TS2339
347
373
  is_empty_or_empty_export,
374
+ // @ts-expect-error TS2339
348
375
  needs_esm_helpers,
376
+ // @ts-expect-error TS2339
349
377
  diagnostics,
378
+ // @ts-expect-error TS2339
350
379
  used_env,
380
+ // @ts-expect-error TS2339
351
381
  has_node_replacements,
382
+ // @ts-expect-error TS2339
352
383
  is_constant_module,
384
+ // @ts-expect-error TS2339
353
385
  conditions
354
386
  } = await (_rust().transformAsync || _rust().transform)({
355
387
  filename: asset.filePath,
@@ -394,9 +426,7 @@ var _default = exports.default = new (_plugin().Transformer)({
394
426
  mod = await options.packageManager.require(src, asset.filePath);
395
427
 
396
428
  // Default interop for CommonJS modules.
397
- if (exportName === 'default' && !mod.__esModule &&
398
- // $FlowFixMe
399
- Object.prototype.toString.call(config) !== '[object Module]') {
429
+ if (exportName === 'default' && !mod.__esModule && Object.prototype.toString.call(config) !== '[object Module]') {
400
430
  mod = {
401
431
  default: mod
402
432
  };
@@ -420,6 +450,7 @@ var _default = exports.default = new (_plugin().Transformer)({
420
450
  if (asset.env.sourceMap) {
421
451
  // Generate a source map that maps each line of the asset to the original macro call.
422
452
  map = new (_sourceMap().default)(options.projectRoot);
453
+ // @ts-expect-error TS2304
423
454
  let mappings = [];
424
455
  let line = 1;
425
456
  for (let i = 0; i <= a.content.length; i++) {
@@ -440,6 +471,7 @@ var _default = exports.default = new (_plugin().Transformer)({
440
471
  }
441
472
  map.addIndexedMappings(mappings);
442
473
  if (originalMap) {
474
+ // @ts-expect-error TS2345
443
475
  map.extends(originalMap);
444
476
  } else {
445
477
  map.setSourceContent(asset.filePath, code.toString());
@@ -494,7 +526,9 @@ var _default = exports.default = new (_plugin().Transformer)({
494
526
  } : null
495
527
  });
496
528
  if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi')) {
497
- asset.meta.conditions = conditions.map(c => ({
529
+ asset.meta.conditions = conditions.map(
530
+ // @ts-expect-error TS7006
531
+ c => ({
498
532
  key: c.key,
499
533
  ifTruePlaceholder: c.if_true_placeholder,
500
534
  ifFalsePlaceholder: c.if_false_placeholder
@@ -523,12 +557,17 @@ var _default = exports.default = new (_plugin().Transformer)({
523
557
  return location;
524
558
  };
525
559
  if (diagnostics) {
526
- let errors = diagnostics.filter(d => d.severity === 'Error' || d.severity === 'SourceError' && asset.isSource);
527
- let warnings = diagnostics.filter(d => d.severity === 'Warning' || d.severity === 'SourceError' && !asset.isSource);
560
+ let errors = diagnostics.filter(
561
+ // @ts-expect-error TS7006
562
+ d => d.severity === 'Error' || d.severity === 'SourceError' && asset.isSource);
563
+ let warnings = diagnostics.filter(
564
+ // @ts-expect-error TS7006
565
+ d => d.severity === 'Warning' || d.severity === 'SourceError' && !asset.isSource);
528
566
  let convertDiagnostic = diagnostic => {
529
567
  var _diagnostic$code_high;
530
568
  let message = diagnostic.message;
531
569
  if (message === 'SCRIPT_ERROR') {
570
+ // @ts-expect-error TS7053
532
571
  let err = SCRIPT_ERRORS[asset.env.context];
533
572
  message = (err === null || err === void 0 ? void 0 : err.message) || SCRIPT_ERRORS.browser.message;
534
573
  }
@@ -551,6 +590,8 @@ var _default = exports.default = new (_plugin().Transformer)({
551
590
  codeHighlights: [(0, _diagnostic().convertSourceLocationToHighlight)(asset.env.loc, 'The environment was originally created here')]
552
591
  });
553
592
  }
593
+
594
+ // @ts-expect-error TS7053
554
595
  let err = SCRIPT_ERRORS[asset.env.context];
555
596
  if (err) {
556
597
  if (!res.hints) {
@@ -595,6 +636,7 @@ var _default = exports.default = new (_plugin().Transformer)({
595
636
  env: {
596
637
  context: 'web-worker',
597
638
  sourceType: dep.source_type === 'Module' ? 'module' : 'script',
639
+ // @ts-expect-error TS2322
598
640
  outputFormat,
599
641
  loc
600
642
  },
@@ -717,6 +759,7 @@ var _default = exports.default = new (_plugin().Transformer)({
717
759
  idx = dep.specifier.indexOf('/', idx + 1);
718
760
  }
719
761
  let module = idx >= 0 ? dep.specifier.slice(0, idx) : dep.specifier;
762
+ // @ts-expect-error TS7053
720
763
  range = _package.default.dependencies[module];
721
764
  }
722
765
  asset.addDependency({
@@ -728,6 +771,7 @@ var _default = exports.default = new (_plugin().Transformer)({
728
771
  meta,
729
772
  resolveFrom: isHelper ? __filename : undefined,
730
773
  range,
774
+ // @ts-expect-error TS2322
731
775
  env
732
776
  });
733
777
  }
@@ -774,11 +818,14 @@ var _default = exports.default = new (_plugin().Transformer)({
774
818
  let dep = deps.get(source);
775
819
  if (!dep) continue;
776
820
  if (local === '*' && imported === '*') {
821
+ // @ts-expect-error TS2345
777
822
  dep.symbols.set('*', '*', convertLoc(loc), true);
778
823
  } else {
779
824
  var _dep$symbols$get;
780
825
  let reExportName = ((_dep$symbols$get = dep.symbols.get(imported)) === null || _dep$symbols$get === void 0 ? void 0 : _dep$symbols$get.local) ?? `$${asset.id}$re_export$${local}`;
826
+ // @ts-expect-error TS2345
781
827
  asset.symbols.set(local, reExportName);
828
+ // @ts-expect-error TS2345
782
829
  dep.symbols.set(imported, reExportName, convertLoc(loc), true);
783
830
  }
784
831
  }
@@ -796,7 +843,9 @@ var _default = exports.default = new (_plugin().Transformer)({
796
843
  let symbols = new Map();
797
844
  for (let name of hoist_result.self_references) {
798
845
  // Do not create a self-reference for the `default` symbol unless we have seen an __esModule flag.
799
- if (name === 'default' && !asset.symbols.hasExportSymbol('__esModule')) {
846
+ if (name === 'default' &&
847
+ // @ts-expect-error TS2345
848
+ !asset.symbols.hasExportSymbol('__esModule')) {
800
849
  continue;
801
850
  }
802
851
  let local = (0, _nullthrows().default)(asset.symbols.get(name)).local;
@@ -823,10 +872,13 @@ var _default = exports.default = new (_plugin().Transformer)({
823
872
  // Add * symbol if there are CJS exports, no imports/exports at all
824
873
  // (and the asset has side effects), or the asset is wrapped.
825
874
  // This allows accessing symbols that don't exist without errors in symbol propagation.
826
- if (hoist_result.has_cjs_exports || !hoist_result.is_esm && asset.sideEffects && deps.size === 0 && Object.keys(hoist_result.exported_symbols).length === 0 || hoist_result.should_wrap && !asset.symbols.hasExportSymbol('*')) {
875
+ if (hoist_result.has_cjs_exports || !hoist_result.is_esm && asset.sideEffects && deps.size === 0 && Object.keys(hoist_result.exported_symbols).length === 0 ||
876
+ // @ts-expect-error TS2345
877
+ hoist_result.should_wrap && !asset.symbols.hasExportSymbol('*')) {
827
878
  if (is_empty_or_empty_export) {
828
879
  asset.meta.emptyFileStarReexport = true;
829
880
  }
881
+ // @ts-expect-error TS2345
830
882
  asset.symbols.set('*', `$${asset.id}$exports`);
831
883
  }
832
884
  asset.meta.hasCJSExports = hoist_result.has_cjs_exports;
@@ -843,10 +895,14 @@ var _default = exports.default = new (_plugin().Transformer)({
843
895
  source
844
896
  } of symbol_result.exports) {
845
897
  let dep = source ? deps.get(source) : undefined;
846
- asset.symbols.set(exported, `${(dep === null || dep === void 0 ? void 0 : dep.id) ?? ''}$${local}`, convertLoc(loc));
898
+ asset.symbols.set(exported,
899
+ // @ts-expect-error TS2345
900
+ `${(dep === null || dep === void 0 ? void 0 : dep.id) ?? ''}$${local}`, convertLoc(loc));
847
901
  if (dep != null) {
848
902
  dep.symbols.ensure();
849
- dep.symbols.set(local, `${(dep === null || dep === void 0 ? void 0 : dep.id) ?? ''}$${local}`, convertLoc(loc), true);
903
+ dep.symbols.set(local,
904
+ // @ts-expect-error TS2345
905
+ `${(dep === null || dep === void 0 ? void 0 : dep.id) ?? ''}$${local}`, convertLoc(loc), true);
850
906
  }
851
907
  }
852
908
  for (let {
@@ -867,18 +923,23 @@ var _default = exports.default = new (_plugin().Transformer)({
867
923
  let dep = deps.get(source);
868
924
  if (!dep) continue;
869
925
  dep.symbols.ensure();
926
+ // @ts-expect-error TS2345
870
927
  dep.symbols.set('*', '*', convertLoc(loc), true);
871
928
  }
872
929
 
873
930
  // Add * symbol if there are CJS exports, no imports/exports at all, or the asset is wrapped.
874
931
  // This allows accessing symbols that don't exist without errors in symbol propagation.
875
- if (symbol_result.has_cjs_exports || !symbol_result.is_esm && deps.size === 0 && symbol_result.exports.length === 0 || symbol_result.should_wrap && !asset.symbols.hasExportSymbol('*')) {
932
+ if (symbol_result.has_cjs_exports || !symbol_result.is_esm && deps.size === 0 && symbol_result.exports.length === 0 ||
933
+ // @ts-expect-error TS2345
934
+ symbol_result.should_wrap && !asset.symbols.hasExportSymbol('*')) {
876
935
  asset.symbols.ensure();
936
+ // @ts-expect-error TS2345
877
937
  asset.symbols.set('*', `$${asset.id}$exports`);
878
938
  }
879
939
  } else {
880
940
  // If the asset is wrapped, add * as a fallback
881
941
  asset.symbols.ensure();
942
+ // @ts-expect-error TS2345
882
943
  asset.symbols.set('*', `$${asset.id}$exports`);
883
944
  }
884
945
 
@@ -887,6 +948,7 @@ var _default = exports.default = new (_plugin().Transformer)({
887
948
  for (let dep of asset.getDependencies()) {
888
949
  if (dep.symbols.isCleared) {
889
950
  dep.symbols.ensure();
951
+ // @ts-expect-error TS2345
890
952
  dep.symbols.set('*', `${dep.id}$`);
891
953
  }
892
954
  }
@@ -909,6 +971,7 @@ var _default = exports.default = new (_plugin().Transformer)({
909
971
  let sourceMap = new (_sourceMap().default)(options.projectRoot);
910
972
  sourceMap.addVLQMap(JSON.parse(map));
911
973
  if (originalMap) {
974
+ // @ts-expect-error TS2345
912
975
  sourceMap.extends(originalMap);
913
976
  }
914
977
  asset.setMap(sourceMap);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-js",
3
- "version": "3.3.9",
3
+ "version": "3.3.11-typescript-08dcc1c9b.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,9 +10,10 @@
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
12
  "main": "lib/JSTransformer.js",
13
- "source": "src/JSTransformer.js",
13
+ "source": "src/JSTransformer.ts",
14
14
  "scripts": {
15
- "test": "mocha"
15
+ "test": "mocha",
16
+ "check-ts": "tsc --noEmit"
16
17
  },
17
18
  "engines": {
18
19
  "node": ">= 16.0.0"
@@ -22,13 +23,13 @@
22
23
  "src"
23
24
  ],
24
25
  "dependencies": {
25
- "@atlaspack/diagnostic": "2.14.1",
26
- "@atlaspack/feature-flags": "2.19.1",
27
- "@atlaspack/plugin": "2.14.19",
28
- "@atlaspack/rust": "3.4.1",
26
+ "@atlaspack/diagnostic": "2.14.2-typescript-08dcc1c9b.0",
27
+ "@atlaspack/feature-flags": "2.19.3-typescript-08dcc1c9b.0",
28
+ "@atlaspack/plugin": "2.14.21-typescript-08dcc1c9b.0",
29
+ "@atlaspack/rust": "3.4.2-typescript-08dcc1c9b.0",
30
+ "@atlaspack/utils": "2.17.3-typescript-08dcc1c9b.0",
31
+ "@atlaspack/workers": "2.14.21-typescript-08dcc1c9b.0",
29
32
  "@parcel/source-map": "^2.1.1",
30
- "@atlaspack/utils": "2.17.1",
31
- "@atlaspack/workers": "2.14.19",
32
33
  "@swc/helpers": "^0.5.15",
33
34
  "browserslist": "^4.6.6",
34
35
  "nullthrows": "^1.1.1",
@@ -38,5 +39,7 @@
38
39
  "peerDependencies": {
39
40
  "@atlaspack/core": "^2.13.1"
40
41
  },
41
- "type": "commonjs"
42
+ "type": "commonjs",
43
+ "types": "src/JSTransformer.ts",
44
+ "gitHead": "08dcc1c9bcdc6ab931d55e05ccc0f45669de2f22"
42
45
  }
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import type {
3
2
  JSONObject,
4
3
  EnvMap,
@@ -27,7 +26,7 @@ import {getFeatureFlag} from '@atlaspack/feature-flags';
27
26
  const JSX_EXTENSIONS = {
28
27
  jsx: true,
29
28
  tsx: true,
30
- };
29
+ } as const;
31
30
 
32
31
  const JSX_PRAGMA = {
33
32
  react: {
@@ -50,7 +49,7 @@ const JSX_PRAGMA = {
50
49
  pragmaFrag: undefined,
51
50
  automatic: undefined,
52
51
  },
53
- };
52
+ } as const;
54
53
 
55
54
  const BROWSER_MAPPING = {
56
55
  and_chr: 'chrome',
@@ -64,7 +63,7 @@ const BROWSER_MAPPING = {
64
63
  bb: null,
65
64
  kaios: null,
66
65
  op_mini: null,
67
- };
66
+ } as const;
68
67
 
69
68
  // List of browsers to exclude when the esmodule target is specified.
70
69
  // Based on https://caniuse.com/#feat=es6-module
@@ -134,45 +133,43 @@ const SCRIPT_ERRORS = {
134
133
  'Service workers cannot have imports or exports without the `type: "module"` option.',
135
134
  hint: "Add {type: 'module'} as a second argument to the navigator.serviceWorker.register() call.",
136
135
  },
137
- };
136
+ } as const;
138
137
 
139
138
  type TSConfig = {
140
139
  compilerOptions?: {
141
140
  // https://www.typescriptlang.org/tsconfig#jsx
142
- jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve' | 'react-native',
141
+ jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve' | 'react-native';
143
142
  // https://www.typescriptlang.org/tsconfig#jsxFactory
144
- jsxFactory?: string,
143
+ jsxFactory?: string;
145
144
  // https://www.typescriptlang.org/tsconfig#jsxFragmentFactory
146
- jsxFragmentFactory?: string,
145
+ jsxFragmentFactory?: string;
147
146
  // https://www.typescriptlang.org/tsconfig#jsxImportSource
148
- jsxImportSource?: string,
147
+ jsxImportSource?: string;
149
148
  // https://www.typescriptlang.org/tsconfig#experimentalDecorators
150
- experimentalDecorators?: boolean,
149
+ experimentalDecorators?: boolean;
151
150
  // https://www.typescriptlang.org/tsconfig#useDefineForClassFields
152
- useDefineForClassFields?: boolean,
151
+ useDefineForClassFields?: boolean;
153
152
  // https://www.typescriptlang.org/tsconfig#target
154
- target?: string, // 'es3' | 'es5' | 'es6' | 'es2015' | ... |'es2022' | ... | 'esnext'
155
- ...
156
- },
157
- ...
153
+ target?: string; // 'es3' | 'es5' | 'es6' | 'es2015' | ... |'es2022' | ... | 'esnext';
154
+ };
158
155
  };
159
156
 
160
- type MacroAsset = {|
161
- type: string,
162
- content: string,
163
- |};
157
+ type MacroAsset = {
158
+ type: string;
159
+ content: string;
160
+ };
164
161
 
165
162
  // NOTE: Make sure this is in sync with the TypeScript definition in the @atlaspack/macros package.
166
- type MacroContext = {|
167
- addAsset(asset: MacroAsset): void,
168
- invalidateOnFileChange(FilePath): void,
169
- invalidateOnFileCreate(FileCreateInvalidation): void,
170
- invalidateOnEnvChange(string): void,
171
- invalidateOnStartup(): void,
172
- invalidateOnBuild(): void,
173
- |};
174
-
175
- export default (new Transformer({
163
+ type MacroContext = {
164
+ addAsset(asset: MacroAsset): void;
165
+ invalidateOnFileChange(arg1: FilePath): void;
166
+ invalidateOnFileCreate(arg1: FileCreateInvalidation): void;
167
+ invalidateOnEnvChange(arg1: string): void;
168
+ invalidateOnStartup(): void;
169
+ invalidateOnBuild(): void;
170
+ };
171
+
172
+ export default new Transformer({
176
173
  async loadConfig({config, options}) {
177
174
  let packageJson = await config.getPackage();
178
175
  let isJSX,
@@ -220,9 +217,11 @@ export default (new Transformer({
220
217
  // Use explicitly defined JSX options in tsconfig.json over inferred values from dependencies.
221
218
  pragma =
222
219
  compilerOptions?.jsxFactory ||
220
+ // @ts-expect-error TS7053
223
221
  (reactLib ? JSX_PRAGMA[reactLib].pragma : undefined);
224
222
  pragmaFrag =
225
223
  compilerOptions?.jsxFragmentFactory ||
224
+ // @ts-expect-error TS7053
226
225
  (reactLib ? JSX_PRAGMA[reactLib].pragmaFrag : undefined);
227
226
 
228
227
  if (
@@ -237,17 +236,20 @@ export default (new Transformer({
237
236
  packageJson?.alias && packageJson.alias['react'] === 'preact/compat'
238
237
  ? 'preact'
239
238
  : reactLib;
239
+ // @ts-expect-error TS7053
240
240
  let automaticVersion = JSX_PRAGMA[effectiveReactLib]?.automatic;
241
241
  let reactLibVersion =
242
242
  packageJson?.dependencies?.[effectiveReactLib] ||
243
243
  packageJson?.devDependencies?.[effectiveReactLib] ||
244
244
  packageJson?.peerDependencies?.[effectiveReactLib];
245
+ // @ts-expect-error TS2322
245
246
  reactLibVersion = reactLibVersion
246
247
  ? semver.validRange(reactLibVersion)
247
248
  : null;
248
249
  let minReactLibVersion =
249
250
  reactLibVersion !== null && reactLibVersion !== '*'
250
- ? semver.minVersion(reactLibVersion)?.toString()
251
+ ? // @ts-expect-error TS2345
252
+ semver.minVersion(reactLibVersion)?.toString()
251
253
  : null;
252
254
 
253
255
  automaticJSXRuntime =
@@ -312,10 +314,14 @@ export default (new Transformer({
312
314
  'Invalid config for @atlaspack/transformer-js',
313
315
  );
314
316
 
317
+ // @ts-expect-error TS2339
315
318
  magicComments = conf.contents?.magicComments ?? magicComments;
319
+ // @ts-expect-error TS2339
316
320
  inlineEnvironment = conf.contents?.inlineEnvironment ?? inlineEnvironment;
321
+ // @ts-expect-error TS2339
317
322
  inlineFS = conf.contents?.inlineFS ?? inlineFS;
318
323
  inlineConstants =
324
+ // @ts-expect-error TS2339
319
325
  conf.contents?.unstable_inlineConstants ?? inlineConstants;
320
326
  }
321
327
 
@@ -362,6 +368,7 @@ export default (new Transformer({
362
368
  for (let browser of browsers) {
363
369
  let [name, version] = browser.split(' ');
364
370
  if (BROWSER_MAPPING.hasOwnProperty(name)) {
371
+ // @ts-expect-error TS7053
365
372
  name = BROWSER_MAPPING[name];
366
373
  if (!name) {
367
374
  continue;
@@ -371,12 +378,15 @@ export default (new Transformer({
371
378
  let [major, minor = '0', patch = '0'] = version
372
379
  .split('-')[0]
373
380
  .split('.');
381
+ // @ts-expect-error TS2345
374
382
  if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
375
383
  continue;
376
384
  }
377
385
  let semverVersion = `${major}.${minor}.${patch}`;
378
386
 
387
+ // @ts-expect-error TS2345
379
388
  if (targets[name] == null || semver.gt(targets[name], semverVersion)) {
389
+ // @ts-expect-error TS7053
380
390
  targets[name] = semverVersion;
381
391
  }
382
392
  }
@@ -416,24 +426,44 @@ export default (new Transformer({
416
426
  if (asset.type === 'ts') {
417
427
  isJSX = false;
418
428
  } else if (!isJSX) {
429
+ // @ts-expect-error TS7053
419
430
  isJSX = Boolean(JSX_EXTENSIONS[asset.type]);
420
431
  }
421
432
  }
422
433
 
423
- let macroAssets = [];
434
+ let macroAssets: Array<{
435
+ content: string;
436
+ // @ts-expect-error TS2552
437
+ map: undefined | NodeSourceMap;
438
+ type: string;
439
+ uniqueKey: string;
440
+ }> = [];
424
441
  let {
442
+ // @ts-expect-error TS2339
425
443
  dependencies,
444
+ // @ts-expect-error TS2339
426
445
  code: compiledCode,
446
+ // @ts-expect-error TS2339
427
447
  map,
448
+ // @ts-expect-error TS2339
428
449
  shebang,
450
+ // @ts-expect-error TS2339
429
451
  hoist_result,
452
+ // @ts-expect-error TS2339
430
453
  symbol_result,
454
+ // @ts-expect-error TS2339
431
455
  is_empty_or_empty_export,
456
+ // @ts-expect-error TS2339
432
457
  needs_esm_helpers,
458
+ // @ts-expect-error TS2339
433
459
  diagnostics,
460
+ // @ts-expect-error TS2339
434
461
  used_env,
462
+ // @ts-expect-error TS2339
435
463
  has_node_replacements,
464
+ // @ts-expect-error TS2339
436
465
  is_constant_module,
466
+ // @ts-expect-error TS2339
437
467
  conditions,
438
468
  } = await (transformAsync || transform)({
439
469
  filename: asset.filePath,
@@ -480,7 +510,7 @@ export default (new Transformer({
480
510
  computed_properties_fix: options.featureFlags.unusedComputedPropertyFix,
481
511
  magic_comments: Boolean(config?.magicComments),
482
512
  callMacro: asset.isSource
483
- ? async (err, src, exportName, args, loc) => {
513
+ ? async (err: any, src: any, exportName: any, args: any, loc: any) => {
484
514
  let mod;
485
515
  try {
486
516
  mod = await options.packageManager.require(src, asset.filePath);
@@ -489,7 +519,6 @@ export default (new Transformer({
489
519
  if (
490
520
  exportName === 'default' &&
491
521
  !mod.__esModule &&
492
- // $FlowFixMe
493
522
  Object.prototype.toString.call(config) !== '[object Module]'
494
523
  ) {
495
524
  mod = {default: mod};
@@ -498,7 +527,7 @@ export default (new Transformer({
498
527
  if (!Object.hasOwnProperty.call(mod, exportName)) {
499
528
  throw new Error(`"${src}" does not export "${exportName}".`);
500
529
  }
501
- } catch (err) {
530
+ } catch (err: any) {
502
531
  throw {
503
532
  kind: 1,
504
533
  message: err.message,
@@ -515,7 +544,8 @@ export default (new Transformer({
515
544
  if (asset.env.sourceMap) {
516
545
  // Generate a source map that maps each line of the asset to the original macro call.
517
546
  map = new SourceMap(options.projectRoot);
518
- let mappings = [];
547
+ // @ts-expect-error TS2304
548
+ let mappings: Array<IndexedMapping<string>> = [];
519
549
  let line = 1;
520
550
  for (let i = 0; i <= a.content.length; i++) {
521
551
  if (i === a.content.length || a.content[i] === '\n') {
@@ -536,6 +566,7 @@ export default (new Transformer({
536
566
 
537
567
  map.addIndexedMappings(mappings);
538
568
  if (originalMap) {
569
+ // @ts-expect-error TS2345
539
570
  map.extends(originalMap);
540
571
  } else {
541
572
  map.setSourceContent(asset.filePath, code.toString());
@@ -554,13 +585,13 @@ export default (new Transformer({
554
585
  specifierType: 'esm',
555
586
  });
556
587
  },
557
- invalidateOnFileChange(filePath) {
588
+ invalidateOnFileChange(filePath: FilePath) {
558
589
  asset.invalidateOnFileChange(filePath);
559
590
  },
560
- invalidateOnFileCreate(invalidation) {
591
+ invalidateOnFileCreate(invalidation: FileCreateInvalidation) {
561
592
  asset.invalidateOnFileCreate(invalidation);
562
593
  },
563
- invalidateOnEnvChange(env) {
594
+ invalidateOnEnvChange(env: string) {
564
595
  asset.invalidateOnEnvChange(env);
565
596
  },
566
597
  invalidateOnStartup() {
@@ -577,7 +608,7 @@ export default (new Transformer({
577
608
  `"${exportName}" in "${src}" is not a function.`,
578
609
  );
579
610
  }
580
- } catch (err) {
611
+ } catch (err: any) {
581
612
  // Remove atlaspack core from stack and build string so Rust can process errors more easily.
582
613
  let stack = (err.stack || '').split('\n').slice(1);
583
614
  let message = err.message;
@@ -597,18 +628,21 @@ export default (new Transformer({
597
628
  });
598
629
 
599
630
  if (getFeatureFlag('conditionalBundlingApi')) {
600
- asset.meta.conditions = conditions.map((c): ConditionMeta => ({
601
- key: c.key,
602
- ifTruePlaceholder: c.if_true_placeholder,
603
- ifFalsePlaceholder: c.if_false_placeholder,
604
- }));
631
+ asset.meta.conditions = conditions.map(
632
+ // @ts-expect-error TS7006
633
+ (c): ConditionMeta => ({
634
+ key: c.key,
635
+ ifTruePlaceholder: c.if_true_placeholder,
636
+ ifFalsePlaceholder: c.if_false_placeholder,
637
+ }),
638
+ );
605
639
  }
606
640
 
607
641
  if (is_constant_module) {
608
642
  asset.meta.isConstantModule = true;
609
643
  }
610
644
 
611
- let convertLoc = (loc): SourceLocation => {
645
+ let convertLoc = (loc: any): SourceLocation => {
612
646
  let location = {
613
647
  filePath: asset.filePath,
614
648
  start: {
@@ -631,19 +665,22 @@ export default (new Transformer({
631
665
 
632
666
  if (diagnostics) {
633
667
  let errors = diagnostics.filter(
668
+ // @ts-expect-error TS7006
634
669
  (d) =>
635
670
  d.severity === 'Error' ||
636
671
  (d.severity === 'SourceError' && asset.isSource),
637
672
  );
638
673
  let warnings = diagnostics.filter(
674
+ // @ts-expect-error TS7006
639
675
  (d) =>
640
676
  d.severity === 'Warning' ||
641
677
  (d.severity === 'SourceError' && !asset.isSource),
642
678
  );
643
- let convertDiagnostic = (diagnostic) => {
679
+ let convertDiagnostic = (diagnostic: any) => {
644
680
  let message = diagnostic.message;
645
681
  if (message === 'SCRIPT_ERROR') {
646
- let err = SCRIPT_ERRORS[(asset.env.context: string)];
682
+ // @ts-expect-error TS7053
683
+ let err = SCRIPT_ERRORS[asset.env.context as string];
647
684
  message = err?.message || SCRIPT_ERRORS.browser.message;
648
685
  }
649
686
 
@@ -652,11 +689,12 @@ export default (new Transformer({
652
689
  codeFrames: [
653
690
  {
654
691
  filePath: asset.filePath,
655
- codeHighlights: diagnostic.code_highlights?.map((highlight) =>
656
- convertSourceLocationToHighlight(
657
- convertLoc(highlight.loc),
658
- highlight.message ?? undefined,
659
- ),
692
+ codeHighlights: diagnostic.code_highlights?.map(
693
+ (highlight: any) =>
694
+ convertSourceLocationToHighlight(
695
+ convertLoc(highlight.loc),
696
+ highlight.message ?? undefined,
697
+ ),
660
698
  ),
661
699
  },
662
700
  ],
@@ -680,7 +718,8 @@ export default (new Transformer({
680
718
  });
681
719
  }
682
720
 
683
- let err = SCRIPT_ERRORS[(asset.env.context: string)];
721
+ // @ts-expect-error TS7053
722
+ let err = SCRIPT_ERRORS[asset.env.context as string];
684
723
  if (err) {
685
724
  if (!res.hints) {
686
725
  res.hints = [err.hint];
@@ -737,6 +776,7 @@ export default (new Transformer({
737
776
  env: {
738
777
  context: 'web-worker',
739
778
  sourceType: dep.source_type === 'Module' ? 'module' : 'script',
779
+ // @ts-expect-error TS2322
740
780
  outputFormat,
741
781
  loc,
742
782
  },
@@ -878,6 +918,7 @@ export default (new Transformer({
878
918
  idx = dep.specifier.indexOf('/', idx + 1);
879
919
  }
880
920
  let module = idx >= 0 ? dep.specifier.slice(0, idx) : dep.specifier;
921
+ // @ts-expect-error TS7053
881
922
  range = pkg.dependencies[module];
882
923
  }
883
924
 
@@ -889,12 +930,13 @@ export default (new Transformer({
889
930
  dep.kind === 'DynamicImport'
890
931
  ? 'lazy'
891
932
  : dep.kind === 'ConditionalImport'
892
- ? 'conditional'
893
- : 'sync',
933
+ ? 'conditional'
934
+ : 'sync',
894
935
  isOptional: dep.is_optional,
895
936
  meta,
896
937
  resolveFrom: isHelper ? __filename : undefined,
897
938
  range,
939
+ // @ts-expect-error TS2322
898
940
  env,
899
941
  });
900
942
  }
@@ -941,12 +983,15 @@ export default (new Transformer({
941
983
  let dep = deps.get(source);
942
984
  if (!dep) continue;
943
985
  if (local === '*' && imported === '*') {
986
+ // @ts-expect-error TS2345
944
987
  dep.symbols.set('*', '*', convertLoc(loc), true);
945
988
  } else {
946
989
  let reExportName =
947
990
  dep.symbols.get(imported)?.local ??
948
991
  `$${asset.id}$re_export$${local}`;
992
+ // @ts-expect-error TS2345
949
993
  asset.symbols.set(local, reExportName);
994
+ // @ts-expect-error TS2345
950
995
  dep.symbols.set(imported, reExportName, convertLoc(loc), true);
951
996
  }
952
997
  }
@@ -969,6 +1014,7 @@ export default (new Transformer({
969
1014
  // Do not create a self-reference for the `default` symbol unless we have seen an __esModule flag.
970
1015
  if (
971
1016
  name === 'default' &&
1017
+ // @ts-expect-error TS2345
972
1018
  !asset.symbols.hasExportSymbol('__esModule')
973
1019
  ) {
974
1020
  continue;
@@ -1004,11 +1050,13 @@ export default (new Transformer({
1004
1050
  asset.sideEffects &&
1005
1051
  deps.size === 0 &&
1006
1052
  Object.keys(hoist_result.exported_symbols).length === 0) ||
1053
+ // @ts-expect-error TS2345
1007
1054
  (hoist_result.should_wrap && !asset.symbols.hasExportSymbol('*'))
1008
1055
  ) {
1009
1056
  if (is_empty_or_empty_export) {
1010
1057
  asset.meta.emptyFileStarReexport = true;
1011
1058
  }
1059
+ // @ts-expect-error TS2345
1012
1060
  asset.symbols.set('*', `$${asset.id}$exports`);
1013
1061
  }
1014
1062
 
@@ -1028,6 +1076,7 @@ export default (new Transformer({
1028
1076
  let dep = source ? deps.get(source) : undefined;
1029
1077
  asset.symbols.set(
1030
1078
  exported,
1079
+ // @ts-expect-error TS2345
1031
1080
  `${dep?.id ?? ''}$${local}`,
1032
1081
  convertLoc(loc),
1033
1082
  );
@@ -1035,6 +1084,7 @@ export default (new Transformer({
1035
1084
  dep.symbols.ensure();
1036
1085
  dep.symbols.set(
1037
1086
  local,
1087
+ // @ts-expect-error TS2345
1038
1088
  `${dep?.id ?? ''}$${local}`,
1039
1089
  convertLoc(loc),
1040
1090
  true,
@@ -1053,6 +1103,7 @@ export default (new Transformer({
1053
1103
  let dep = deps.get(source);
1054
1104
  if (!dep) continue;
1055
1105
  dep.symbols.ensure();
1106
+ // @ts-expect-error TS2345
1056
1107
  dep.symbols.set('*', '*', convertLoc(loc), true);
1057
1108
  }
1058
1109
 
@@ -1063,14 +1114,17 @@ export default (new Transformer({
1063
1114
  (!symbol_result.is_esm &&
1064
1115
  deps.size === 0 &&
1065
1116
  symbol_result.exports.length === 0) ||
1117
+ // @ts-expect-error TS2345
1066
1118
  (symbol_result.should_wrap && !asset.symbols.hasExportSymbol('*'))
1067
1119
  ) {
1068
1120
  asset.symbols.ensure();
1121
+ // @ts-expect-error TS2345
1069
1122
  asset.symbols.set('*', `$${asset.id}$exports`);
1070
1123
  }
1071
1124
  } else {
1072
1125
  // If the asset is wrapped, add * as a fallback
1073
1126
  asset.symbols.ensure();
1127
+ // @ts-expect-error TS2345
1074
1128
  asset.symbols.set('*', `$${asset.id}$exports`);
1075
1129
  }
1076
1130
 
@@ -1079,6 +1133,7 @@ export default (new Transformer({
1079
1133
  for (let dep of asset.getDependencies()) {
1080
1134
  if (dep.symbols.isCleared) {
1081
1135
  dep.symbols.ensure();
1136
+ // @ts-expect-error TS2345
1082
1137
  dep.symbols.set('*', `${dep.id}$`);
1083
1138
  }
1084
1139
  }
@@ -1104,6 +1159,7 @@ export default (new Transformer({
1104
1159
  let sourceMap = new SourceMap(options.projectRoot);
1105
1160
  sourceMap.addVLQMap(JSON.parse(map));
1106
1161
  if (originalMap) {
1162
+ // @ts-expect-error TS2345
1107
1163
  sourceMap.extends(originalMap);
1108
1164
  }
1109
1165
  asset.setMap(sourceMap);
@@ -1111,4 +1167,4 @@ export default (new Transformer({
1111
1167
 
1112
1168
  return [asset, ...macroAssets];
1113
1169
  },
1114
- }): Transformer);
1170
+ }) as Transformer<unknown>;