@atlaspack/packager-js 2.18.3-typescript-5b4d3ad41.0 → 2.19.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.
@@ -1,3 +1,5 @@
1
+ // @flow
2
+
1
3
  import type {
2
4
  Asset,
3
5
  BundleGraph,
@@ -39,6 +41,7 @@ import {
39
41
 
40
42
  // General regex used to replace imports with the resolved code, references with resolutions,
41
43
  // and count the number of newlines in the file for source maps.
44
+ //
42
45
  // For conditional bundling the only difference in this regex is adding `importCond` where we have `importAsync` etc..
43
46
  const REPLACEMENT_RE_CONDITIONAL =
44
47
  /\n|import\s+"([0-9a-f]{16,20}:.+?)";|(?:\$[0-9a-f]{16,20}\$exports)|(?:\$[0-9a-f]{16,20}\$(?:import|importAsync|require|importCond)\$[0-9a-f]+(?:\$[0-9a-f]+)?)/g;
@@ -61,13 +64,13 @@ const GLOBALS_BY_CONTEXT = {
61
64
  ...Object.keys(globals.node),
62
65
  ...Object.keys(globals.browser),
63
66
  ]),
64
- } as const;
67
+ };
65
68
 
66
69
  const OUTPUT_FORMATS = {
67
70
  esmodule: ESMOutputFormat,
68
71
  commonjs: CJSOutputFormat,
69
72
  global: GlobalOutputFormat,
70
- } as const;
73
+ };
71
74
 
72
75
  export interface OutputFormat {
73
76
  buildBundlePrelude(): [string, number];
@@ -82,23 +85,16 @@ export class ScopeHoistingPackager {
82
85
  useAsyncBundleRuntime: boolean;
83
86
  outputFormat: OutputFormat;
84
87
  isAsyncBundle: boolean;
85
- globalNames: ReadonlySet<string>;
86
- // @ts-expect-error TS2564
87
- assetOutputs: Map<
88
- string,
89
- {
90
- code: string;
91
- map: Buffer | null | undefined;
92
- }
93
- >;
88
+ globalNames: $ReadOnlySet<string>;
89
+ assetOutputs: Map<string, {|code: string, map: ?Buffer|}>;
94
90
  exportedSymbols: Map<
95
91
  string,
96
- {
97
- asset: Asset;
98
- exportSymbol: string;
99
- local: string;
100
- exportAs: Array<string>;
101
- }
92
+ {|
93
+ asset: Asset,
94
+ exportSymbol: string,
95
+ local: string,
96
+ exportAs: Array<string>,
97
+ |},
102
98
  > = new Map();
103
99
  externals: Map<string, Map<string, string>> = new Map();
104
100
  topLevelNames: Map<string, number> = new Map();
@@ -136,10 +132,7 @@ export class ScopeHoistingPackager {
136
132
  this.globalNames = GLOBALS_BY_CONTEXT[bundle.env.context];
137
133
  }
138
134
 
139
- async package(): Promise<{
140
- contents: string;
141
- map: SourceMap | null | undefined;
142
- }> {
135
+ async package(): Promise<{|contents: string, map: ?SourceMap|}> {
143
136
  let {wrapped: wrappedAssets, constant: constantAssets} =
144
137
  await this.loadAssets();
145
138
  this.buildExportedSymbols();
@@ -162,11 +155,9 @@ export class ScopeHoistingPackager {
162
155
 
163
156
  let res = '';
164
157
  let lineCount = 0;
165
- // @ts-expect-error TS7034
166
158
  let sourceMap = null;
167
- let processAsset = (asset: Asset) => {
159
+ let processAsset = (asset) => {
168
160
  let [content, map, lines] = this.visitAsset(asset);
169
- // @ts-expect-error TS7005
170
161
  if (sourceMap && map) {
171
162
  sourceMap.addSourceMap(map, lineCount);
172
163
  } else if (this.bundle.env.sourceMap) {
@@ -212,7 +203,6 @@ export class ScopeHoistingPackager {
212
203
  let [prelude, preludeLines] = this.buildBundlePrelude();
213
204
  res = prelude + res;
214
205
  lineCount += preludeLines;
215
- // @ts-expect-error TS2339
216
206
  sourceMap?.offsetLines(1, preludeLines);
217
207
 
218
208
  let entries = this.bundle.getEntryAssets();
@@ -220,7 +210,11 @@ export class ScopeHoistingPackager {
220
210
  if (this.isAsyncBundle) {
221
211
  // In async bundles we don't want the main entry to execute until we require it
222
212
  // as there might be dependencies in a sibling bundle that hasn't loaded yet.
223
- entries = entries.filter((a) => a.id !== mainEntry?.id);
213
+ if (getFeatureFlag('supportWebpackChunkName')) {
214
+ entries = [];
215
+ } else {
216
+ entries = entries.filter((a) => a.id !== mainEntry?.id);
217
+ }
224
218
  mainEntry = null;
225
219
  }
226
220
 
@@ -233,20 +227,17 @@ export class ScopeHoistingPackager {
233
227
  this.bundleGraph.getAssetPublicId(entry),
234
228
  )});\n`;
235
229
 
236
- // @ts-expect-error TS2345
237
230
  let entryExports = entry.symbols.get('*')?.local;
238
231
 
239
232
  if (
240
233
  entryExports &&
241
234
  entry === mainEntry &&
242
- // @ts-expect-error TS2345
243
235
  this.exportedSymbols.has(entryExports)
244
236
  ) {
245
237
  invariant(
246
238
  !needsBundleQueue,
247
239
  'Entry exports are not yet compaitble with async bundles',
248
240
  );
249
- // @ts-expect-error TS2731
250
241
  res += `\nvar ${entryExports} = ${parcelRequire}`;
251
242
  } else {
252
243
  if (needsBundleQueue) {
@@ -290,7 +281,6 @@ export class ScopeHoistingPackager {
290
281
  this.parcelRequireName,
291
282
  );
292
283
  if (sourceMap && map) {
293
- // @ts-expect-error TS2339
294
284
  sourceMap.addSourceMap(map, lineCount);
295
285
  }
296
286
  }
@@ -332,7 +322,7 @@ export class ScopeHoistingPackager {
332
322
  .filter((b) => this.shouldBundleQueue(b))
333
323
  .map((b) => b.publicId);
334
324
 
335
- const conditions: Array<string> = [];
325
+ const conditions = [];
336
326
  if (getFeatureFlag('conditionalBundlingApi')) {
337
327
  const conditionSet = this.bundleGraph
338
328
  .getConditionalBundleMapping()
@@ -374,13 +364,13 @@ export class ScopeHoistingPackager {
374
364
  return `$parcel$global.rwr(${params.join(', ')});`;
375
365
  }
376
366
 
377
- async loadAssets(): Promise<{
378
- wrapped: Array<Asset>;
379
- constant: Array<Asset>;
380
- }> {
367
+ async loadAssets(): Promise<{|
368
+ wrapped: Array<Asset>,
369
+ constant: Array<Asset>,
370
+ |}> {
381
371
  let queue = new PromiseQueue({maxConcurrent: 32});
382
- let wrapped: Array<Asset> = [];
383
- let constant: Array<Asset> = [];
372
+ let wrapped = [];
373
+ let constant = [];
384
374
  this.bundle.traverseAssets((asset) => {
385
375
  queue.add(async () => {
386
376
  let [code, map] = await Promise.all([
@@ -467,7 +457,6 @@ export class ScopeHoistingPackager {
467
457
  }
468
458
  }
469
459
 
470
- // @ts-expect-error TS2769
471
460
  this.assetOutputs = new Map(await queue.run());
472
461
  return {wrapped, constant};
473
462
  }
@@ -503,7 +492,6 @@ export class ScopeHoistingPackager {
503
492
  // TODO: handle ESM exports of wrapped entry assets...
504
493
  let entry = this.bundle.getMainEntry();
505
494
  if (entry && !this.wrappedAssets.has(entry.id)) {
506
- // @ts-expect-error TS2345
507
495
  let hasNamespace = entry.symbols.hasExportSymbol('*');
508
496
 
509
497
  for (let {
@@ -521,7 +509,6 @@ export class ScopeHoistingPackager {
521
509
  }
522
510
 
523
511
  let symbols = this.exportedSymbols.get(
524
- // @ts-expect-error TS2345
525
512
  symbol === '*' ? nullthrows(entry.symbols.get('*')?.local) : symbol,
526
513
  )?.exportAs;
527
514
 
@@ -529,7 +516,6 @@ export class ScopeHoistingPackager {
529
516
  symbols = [];
530
517
  this.exportedSymbols.set(symbol, {
531
518
  asset,
532
- // @ts-expect-error TS2322
533
519
  exportSymbol,
534
520
  local: symbol,
535
521
  exportAs: symbols,
@@ -540,7 +526,6 @@ export class ScopeHoistingPackager {
540
526
  exportAs = 'default';
541
527
  }
542
528
 
543
- // @ts-expect-error TS2345
544
529
  symbols.push(exportAs);
545
530
  } else if (symbol === null) {
546
531
  // TODO `meta.exportsIdentifier[exportSymbol]` should be exported
@@ -586,7 +571,7 @@ export class ScopeHoistingPackager {
586
571
  return `${obj}[${JSON.stringify(property)}]`;
587
572
  }
588
573
 
589
- visitAsset(asset: Asset): [string, SourceMap | null | undefined, number] {
574
+ visitAsset(asset: Asset): [string, ?SourceMap, number] {
590
575
  invariant(!this.seenAssets.has(asset.id), 'Already visited asset');
591
576
  this.seenAssets.add(asset.id);
592
577
 
@@ -601,8 +586,8 @@ export class ScopeHoistingPackager {
601
586
  buildAsset(
602
587
  asset: Asset,
603
588
  code: string,
604
- map?: Buffer | null,
605
- ): [string, SourceMap | null | undefined, number] {
589
+ map: ?Buffer,
590
+ ): [string, ?SourceMap, number] {
606
591
  let shouldWrap = this.wrappedAssets.has(asset.id);
607
592
  let deps = this.bundleGraph.getDependencies(asset);
608
593
 
@@ -637,7 +622,6 @@ export class ScopeHoistingPackager {
637
622
  let [code, map, lines] = this.visitAsset(resolved);
638
623
  depCode += code + '\n';
639
624
  if (sourceMap && map) {
640
- // @ts-expect-error TS2551
641
625
  sourceMap.addSourceMap(map, lineCount);
642
626
  }
643
627
  lineCount += lines + 1;
@@ -674,9 +658,7 @@ export class ScopeHoistingPackager {
674
658
  code += append;
675
659
 
676
660
  let lineCount = 0;
677
- // @ts-expect-error TS2552
678
- let depContent: Array<[string, NodeSourceMap | null | undefined, number]> =
679
- [];
661
+ let depContent = [];
680
662
  if (depMap.size === 0 && replacements.size === 0) {
681
663
  // If there are no dependencies or replacements, use a simple function to count the number of lines.
682
664
  lineCount = countLines(code) - 1;
@@ -778,7 +760,6 @@ export class ScopeHoistingPackager {
778
760
  }
779
761
 
780
762
  if (map) {
781
- // @ts-expect-error TS2551
782
763
  sourceMap.addSourceMap(map, lineCount);
783
764
  }
784
765
  }
@@ -835,7 +816,6 @@ ${code}
835
816
  if (!depCode) continue;
836
817
  code += depCode + '\n';
837
818
  if (sourceMap && map) {
838
- // @ts-expect-error TS2551
839
819
  sourceMap.addSourceMap(map, lineCount);
840
820
  }
841
821
  lineCount += lines + 1;
@@ -918,12 +898,10 @@ ${code}
918
898
  }
919
899
 
920
900
  for (let [imported, {local}] of dep.symbols) {
921
- // @ts-expect-error TS2367
922
901
  if (local === '*') {
923
902
  continue;
924
903
  }
925
904
 
926
- // @ts-expect-error TS2345
927
905
  let symbol = this.getSymbolResolution(asset, resolved, imported, dep);
928
906
  replacements.set(
929
907
  local,
@@ -960,7 +938,6 @@ ${code}
960
938
  (this.bundle.env.outputFormat === 'commonjs' &&
961
939
  asset === this.bundle.getMainEntry())
962
940
  ) {
963
- // @ts-expect-error TS2345
964
941
  let exportsName = asset.symbols.get('*')?.local || `$${assetId}$exports`;
965
942
  replacements.set(exportsName, 'module.exports');
966
943
  }
@@ -1004,11 +981,8 @@ ${code}
1004
981
 
1005
982
  for (let [imported, {local}] of dep.symbols) {
1006
983
  // If already imported, just add the already renamed variable to the mapping.
1007
- // @ts-expect-error TS2345
1008
984
  let renamed = external.get(imported);
1009
- // @ts-expect-error TS2367
1010
985
  if (renamed && local !== '*' && replacements) {
1011
- // @ts-expect-error TS2345
1012
986
  replacements.set(local, renamed);
1013
987
  continue;
1014
988
  }
@@ -1020,9 +994,7 @@ ${code}
1020
994
  if (!renamed) {
1021
995
  if (referencedBundle) {
1022
996
  let entry = nullthrows(referencedBundle.getMainEntry());
1023
- // @ts-expect-error TS2322
1024
997
  renamed =
1025
- // @ts-expect-error TS2345
1026
998
  entry.symbols.get('*')?.local ??
1027
999
  `$${String(entry.meta.id)}$exports`;
1028
1000
  } else {
@@ -1031,17 +1003,13 @@ ${code}
1031
1003
  );
1032
1004
  }
1033
1005
 
1034
- // @ts-expect-error TS2345
1035
1006
  external.set('*', renamed);
1036
1007
  }
1037
1008
 
1038
- // @ts-expect-error TS2367
1039
1009
  if (local !== '*' && replacements) {
1040
1010
  let replacement;
1041
- // @ts-expect-error TS2367
1042
1011
  if (imported === '*') {
1043
1012
  replacement = renamed;
1044
- // @ts-expect-error TS2367
1045
1013
  } else if (imported === 'default') {
1046
1014
  let needsDefaultInterop = true;
1047
1015
  if (referencedBundle) {
@@ -1055,44 +1023,36 @@ ${code}
1055
1023
  replacement = `${renamed}.default`;
1056
1024
  }
1057
1025
  } else {
1058
- // @ts-expect-error TS2345
1059
1026
  replacement = this.getPropertyAccess(renamed, imported);
1060
1027
  }
1061
1028
 
1062
- // @ts-expect-error TS2345
1063
1029
  replacements.set(local, replacement);
1064
1030
  }
1065
1031
  } else {
1066
1032
  let property;
1067
1033
  if (referencedBundle) {
1068
1034
  let entry = nullthrows(referencedBundle.getMainEntry());
1069
- // @ts-expect-error TS2345
1070
1035
  if (entry.symbols.hasExportSymbol('*')) {
1071
1036
  // If importing * and the referenced module has a * export (e.g. CJS), use default instead.
1072
1037
  // This mirrors the logic in buildExportedSymbols.
1073
1038
  property = imported;
1074
- // @ts-expect-error TS2322
1075
1039
  imported =
1076
1040
  referencedBundle?.env.outputFormat === 'esmodule'
1077
1041
  ? 'default'
1078
1042
  : '*';
1079
1043
  } else {
1080
- // @ts-expect-error TS2367
1081
1044
  if (imported === '*') {
1082
1045
  let exportedSymbols = this.bundleGraph.getExportedSymbols(entry);
1083
- // @ts-expect-error TS2367
1084
1046
  if (local === '*') {
1085
1047
  // Re-export all symbols.
1086
1048
  for (let exported of exportedSymbols) {
1087
1049
  if (exported.symbol) {
1088
- // @ts-expect-error TS2345
1089
1050
  external.set(exported.exportSymbol, exported.symbol);
1090
1051
  }
1091
1052
  }
1092
1053
  continue;
1093
1054
  }
1094
1055
  }
1095
- // @ts-expect-error TS2322
1096
1056
  renamed = this.bundleGraph.getSymbolResolution(
1097
1057
  entry,
1098
1058
  imported,
@@ -1105,40 +1065,30 @@ ${code}
1105
1065
  // are deduplicated. We have to prefix the imported name with the bundle id so that
1106
1066
  // local variables do not shadow it.
1107
1067
  if (!renamed) {
1108
- // @ts-expect-error TS2345
1109
1068
  if (this.exportedSymbols.has(local)) {
1110
- // @ts-expect-error TS2322
1111
1069
  renamed = local;
1112
- // @ts-expect-error TS2367
1113
1070
  } else if (imported === 'default' || imported === '*') {
1114
1071
  renamed = this.getTopLevelName(
1115
1072
  `$${this.bundle.publicId}$${specifier}`,
1116
1073
  );
1117
1074
  } else {
1118
1075
  renamed = this.getTopLevelName(
1119
- // @ts-expect-error TS2731
1120
1076
  `$${this.bundle.publicId}$${imported}`,
1121
1077
  );
1122
1078
  }
1123
1079
  }
1124
1080
 
1125
- // @ts-expect-error TS2345
1126
1081
  external.set(imported, renamed);
1127
- // @ts-expect-error TS2367
1128
1082
  if (local !== '*' && replacements) {
1129
1083
  let replacement = renamed;
1130
- // @ts-expect-error TS2367
1131
1084
  if (property === '*') {
1132
1085
  replacement = renamed;
1133
- // @ts-expect-error TS2367
1134
1086
  } else if (property === 'default') {
1135
1087
  replacement = `($parcel$interopDefault(${renamed}))`;
1136
1088
  this.usedHelpers.add('$parcel$interopDefault');
1137
1089
  } else if (property) {
1138
- // @ts-expect-error TS2345
1139
1090
  replacement = this.getPropertyAccess(renamed, property);
1140
1091
  }
1141
- // @ts-expect-error TS2345
1142
1092
  replacements.set(local, replacement);
1143
1093
  }
1144
1094
  }
@@ -1177,7 +1127,6 @@ ${code}
1177
1127
  asset: resolvedAsset,
1178
1128
  exportSymbol,
1179
1129
  symbol,
1180
- // @ts-expect-error TS2345
1181
1130
  } = this.bundleGraph.getSymbolResolution(resolved, imported, this.bundle);
1182
1131
 
1183
1132
  if (
@@ -1236,11 +1185,8 @@ ${code}
1236
1185
  staticExports &&
1237
1186
  !isWrapped &&
1238
1187
  (dep?.meta.kind === 'Import' || dep?.meta.kind === 'Export') &&
1239
- // @ts-expect-error TS2345
1240
1188
  resolvedAsset.symbols.hasExportSymbol('*') &&
1241
- // @ts-expect-error TS2345
1242
1189
  resolvedAsset.symbols.hasExportSymbol('default') &&
1243
- // @ts-expect-error TS2345
1244
1190
  !resolvedAsset.symbols.hasExportSymbol('__esModule');
1245
1191
 
1246
1192
  // Find the namespace object for the resolved module. If wrapped and this
@@ -1256,9 +1202,7 @@ ${code}
1256
1202
  } else if (isWrapped && dep) {
1257
1203
  obj = `$${publicId}`;
1258
1204
  } else {
1259
- // @ts-expect-error TS2345
1260
1205
  obj = resolvedAsset.symbols.get('*')?.local || `$${assetId}$exports`;
1261
- // @ts-expect-error TS2345
1262
1206
  obj = replacements?.get(obj) || obj;
1263
1207
  }
1264
1208
 
@@ -1271,7 +1215,6 @@ ${code}
1271
1215
  // Directly use module.exports for wrapped assets importing themselves.
1272
1216
  return 'module.exports';
1273
1217
  } else {
1274
- // @ts-expect-error TS2322
1275
1218
  return obj;
1276
1219
  }
1277
1220
  } else if (
@@ -1286,21 +1229,17 @@ ${code}
1286
1229
  if (
1287
1230
  (!dep || kind === 'Import' || kind === 'Export') &&
1288
1231
  exportSymbol === 'default' &&
1289
- // @ts-expect-error TS2345
1290
1232
  resolvedAsset.symbols.hasExportSymbol('*') &&
1291
1233
  this.needsDefaultInterop(resolvedAsset)
1292
1234
  ) {
1293
1235
  this.usedHelpers.add('$parcel$interopDefault');
1294
- // @ts-expect-error TS2731
1295
1236
  return `(/*@__PURE__*/$parcel$interopDefault(${obj}))`;
1296
1237
  } else {
1297
- // @ts-expect-error TS2345
1298
1238
  return this.getPropertyAccess(obj, exportSymbol);
1299
1239
  }
1300
1240
  } else if (!symbol) {
1301
1241
  invariant(false, 'Asset was skipped or not found.');
1302
1242
  } else {
1303
- // @ts-expect-error TS2322
1304
1243
  return replacements?.get(symbol) || symbol;
1305
1244
  }
1306
1245
  }
@@ -1363,11 +1302,8 @@ ${code}
1363
1302
  // If there's no __esModule flag, and default is a used symbol, we need
1364
1303
  // to insert an interop helper.
1365
1304
  let defaultInterop =
1366
- // @ts-expect-error TS2345
1367
1305
  asset.symbols.hasExportSymbol('*') &&
1368
- // @ts-expect-error TS2345
1369
1306
  usedSymbols.has('default') &&
1370
- // @ts-expect-error TS2345
1371
1307
  !asset.symbols.hasExportSymbol('__esModule');
1372
1308
 
1373
1309
  let usedNamespace;
@@ -1376,33 +1312,33 @@ ${code}
1376
1312
  asset.meta.isConstantModule
1377
1313
  ) {
1378
1314
  // Only set usedNamespace if there is an incoming dependency in the current bundle that uses '*'
1379
- usedNamespace = this.bundleGraph.getIncomingDependencies(asset).some(
1380
- (dep) =>
1381
- this.bundle.hasDependency(dep) &&
1382
- // @ts-expect-error TS2345
1383
- nullthrows(this.bundleGraph.getUsedSymbols(dep)).has('*'),
1384
- );
1315
+ usedNamespace = this.bundleGraph
1316
+ .getIncomingDependencies(asset)
1317
+ .some(
1318
+ (dep) =>
1319
+ this.bundle.hasDependency(dep) &&
1320
+ nullthrows(this.bundleGraph.getUsedSymbols(dep)).has('*'),
1321
+ );
1385
1322
  } else {
1386
1323
  usedNamespace =
1387
1324
  // If the asset has * in its used symbols, we might need the exports namespace.
1388
1325
  // The one case where this isn't true is in ESM library entries, where the only
1389
1326
  // dependency on * is the entry dependency. In this case, we will use ESM exports
1390
1327
  // instead of the namespace object.
1391
- // @ts-expect-error TS2345
1392
1328
  (usedSymbols.has('*') &&
1393
1329
  (this.bundle.env.outputFormat !== 'esmodule' ||
1394
1330
  !this.bundle.env.isLibrary ||
1395
1331
  asset !== this.bundle.getMainEntry() ||
1396
- this.bundleGraph.getIncomingDependencies(asset).some(
1397
- (dep) =>
1398
- !dep.isEntry &&
1399
- this.bundle.hasDependency(dep) &&
1400
- // @ts-expect-error TS2345
1401
- nullthrows(this.bundleGraph.getUsedSymbols(dep)).has('*'),
1402
- ))) ||
1332
+ this.bundleGraph
1333
+ .getIncomingDependencies(asset)
1334
+ .some(
1335
+ (dep) =>
1336
+ !dep.isEntry &&
1337
+ this.bundle.hasDependency(dep) &&
1338
+ nullthrows(this.bundleGraph.getUsedSymbols(dep)).has('*'),
1339
+ ))) ||
1403
1340
  // If a symbol is imported (used) from a CJS asset but isn't listed in the symbols,
1404
1341
  // we fallback on the namespace object.
1405
- // @ts-expect-error TS2345
1406
1342
  (asset.symbols.hasExportSymbol('*') &&
1407
1343
  [...usedSymbols].some((s) => !asset.symbols.hasExportSymbol(s))) ||
1408
1344
  // If the exports has this asset's namespace (e.g. ESM output from CJS input),
@@ -1439,7 +1375,6 @@ ${code}
1439
1375
  // Insert the __esModule interop flag for this module if it has a `default` export
1440
1376
  // and the namespace symbol is used.
1441
1377
  // TODO: only if required by CJS?
1442
- // @ts-expect-error TS2345
1443
1378
  if (asset.symbols.hasExportSymbol('default') && usedSymbols.has('*')) {
1444
1379
  prepend += `\n$parcel$defineInteropFlag($${assetId}$exports);\n`;
1445
1380
  prependLineCount += 2;
@@ -1458,7 +1393,6 @@ ${code}
1458
1393
  let isWrapped = resolved && resolved.meta.shouldWrap;
1459
1394
 
1460
1395
  for (let [imported, {local}] of dep.symbols) {
1461
- // @ts-expect-error TS2367
1462
1396
  if (imported === '*' && local === '*') {
1463
1397
  if (!resolved) {
1464
1398
  // Re-exporting an external module. This should have already been handled in buildReplacements.
@@ -1476,11 +1410,9 @@ ${code}
1476
1410
  if (
1477
1411
  isWrapped ||
1478
1412
  resolved.meta.staticExports === false ||
1479
- // @ts-expect-error TS2345
1480
1413
  nullthrows(this.bundleGraph.getUsedSymbols(resolved)).has('*') ||
1481
1414
  // an empty asset
1482
1415
  (!resolved.meta.hasCJSExports &&
1483
- // @ts-expect-error TS2345
1484
1416
  resolved.symbols.hasExportSymbol('*'))
1485
1417
  ) {
1486
1418
  let obj = this.getSymbolResolution(
@@ -1497,9 +1429,7 @@ ${code}
1497
1429
  this.bundleGraph.getUsedSymbols(dep),
1498
1430
  )) {
1499
1431
  if (
1500
- // @ts-expect-error TS2367
1501
1432
  symbol === 'default' || // `export * as ...` does not include the default export
1502
- // @ts-expect-error TS2367
1503
1433
  symbol === '__esModule'
1504
1434
  ) {
1505
1435
  continue;
@@ -1508,7 +1438,6 @@ ${code}
1508
1438
  let resolvedSymbol = this.getSymbolResolution(
1509
1439
  asset,
1510
1440
  resolved,
1511
- // @ts-expect-error TS2345
1512
1441
  symbol,
1513
1442
  undefined,
1514
1443
  replacements,
@@ -1534,7 +1463,6 @@ ${code}
1534
1463
  // re-exported symbols rather than only symbols declared in this asset.
1535
1464
  let incomingDeps = this.bundleGraph.getIncomingDependencies(asset);
1536
1465
  let usedExports = [...asset.symbols.exportSymbols()].filter((symbol) => {
1537
- // @ts-expect-error TS2367
1538
1466
  if (symbol === '*') {
1539
1467
  return false;
1540
1468
  }
@@ -1551,7 +1479,6 @@ ${code}
1551
1479
  // No used symbols available for the asset, make sure we keep all of them
1552
1480
  if (!symbols) return false;
1553
1481
 
1554
- // @ts-expect-error TS2345
1555
1482
  return !symbols.has(symbol) && !symbols.has('*');
1556
1483
  });
1557
1484
  return !unused;
@@ -1567,7 +1494,6 @@ ${code}
1567
1494
  let resolved = this.getSymbolResolution(
1568
1495
  asset,
1569
1496
  asset,
1570
- // @ts-expect-error TS2345
1571
1497
  exp,
1572
1498
  undefined,
1573
1499
  replacements,
@@ -1623,10 +1549,8 @@ ${code}
1623
1549
  }
1624
1550
 
1625
1551
  for (let helper of this.usedHelpers) {
1626
- // @ts-expect-error TS7053
1627
1552
  let currentHelper = helpers[helper];
1628
1553
  if (typeof currentHelper === 'function') {
1629
- // @ts-expect-error TS7053
1630
1554
  currentHelper = helpers[helper](this.bundle.env);
1631
1555
  }
1632
1556
  res += currentHelper;
@@ -1699,9 +1623,7 @@ ${code}
1699
1623
 
1700
1624
  needsDefaultInterop(asset: Asset): boolean {
1701
1625
  if (
1702
- // @ts-expect-error TS2345
1703
1626
  asset.symbols.hasExportSymbol('*') &&
1704
- // @ts-expect-error TS2345
1705
1627
  !asset.symbols.hasExportSymbol('default')
1706
1628
  ) {
1707
1629
  return true;
@@ -12,12 +12,12 @@
12
12
  typeof globalThis !== 'undefined'
13
13
  ? globalThis
14
14
  : typeof self !== 'undefined'
15
- ? self
16
- : typeof window !== 'undefined'
17
- ? window
18
- : typeof global !== 'undefined'
19
- ? global
20
- : {};
15
+ ? self
16
+ : typeof window !== 'undefined'
17
+ ? window
18
+ : typeof global !== 'undefined'
19
+ ? global
20
+ : {};
21
21
  /* eslint-enable no-undef */
22
22
 
23
23
  // Save the require from previous bundle to this closure if any
@@ -1,3 +1,4 @@
1
+ // @flow strict-local
1
2
  import type {Environment} from '@atlaspack/types';
2
3
 
3
4
  export const prelude = (parcelRequireName: string): string => `
@@ -165,4 +166,4 @@ export const helpers = {
165
166
  $parcel$interopDefault,
166
167
  $parcel$global,
167
168
  $parcel$defineInteropFlag,
168
- } as const;
169
+ };