rollup 3.0.0-6 → 3.0.0-8

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,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-5
4
- Tue, 06 Sep 2022 05:29:28 GMT - commit 1d085668121abe6be83c28c212a02c181c16d2b8
3
+ Rollup.js v3.0.0-7
4
+ Tue, 11 Oct 2022 04:31:14 GMT - commit d9237e8c942d96e21de8f275df8d7c9aa2f620f4
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -10,25 +10,14 @@
10
10
  'use strict';
11
11
 
12
12
  const node_path = require('node:path');
13
- const require$$0 = require('path');
13
+ const require$$0$1 = require('path');
14
14
  const process$1 = require('node:process');
15
15
  const node_perf_hooks = require('node:perf_hooks');
16
16
  const node_crypto = require('node:crypto');
17
17
  const node_fs = require('node:fs');
18
18
  const node_events = require('node:events');
19
19
 
20
- function _interopNamespaceDefault(e) {
21
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
22
- if (e) {
23
- for (const k in e) {
24
- n[k] = e[k];
25
- }
26
- }
27
- n.default = e;
28
- return n;
29
- }
30
-
31
- var version$1 = "3.0.0-5";
20
+ var version$1 = "3.0.0-7";
32
21
 
33
22
  function ensureArray$1(items) {
34
23
  if (Array.isArray(items)) {
@@ -218,7 +207,7 @@ function augmentCodeLocation(props, pos, source, id) {
218
207
  }
219
208
  // Error codes should be sorted alphabetically while errors should be sorted by
220
209
  // error code below
221
- const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
210
+ const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ASSERTIONS = 'INCONSISTENT_IMPORT_ASSERTIONS', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
222
211
  function errAddonNotGenerated(message, hook, plugin) {
223
212
  return {
224
213
  code: ADDON_ERROR,
@@ -397,6 +386,18 @@ function errIllegalImportReassignment(name, importingId) {
397
386
  message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
398
387
  };
399
388
  }
389
+ function errInconsistentImportAssertions(existingAssertions, newAssertions, source, importer) {
390
+ return {
391
+ code: INCONSISTENT_IMPORT_ASSERTIONS,
392
+ message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAssertions$1(newAssertions)} assertions, but it was already imported elsewhere with ${formatAssertions$1(existingAssertions)} assertions. Please ensure that import assertions for the same module are always consistent.`
393
+ };
394
+ }
395
+ const formatAssertions$1 = (assertions) => {
396
+ const entries = Object.entries(assertions);
397
+ if (entries.length === 0)
398
+ return 'no';
399
+ return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
400
+ };
400
401
  function errInputHookInOutputPlugin(pluginName, hookName) {
401
402
  return {
402
403
  code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
@@ -842,7 +843,7 @@ const objectifyOptionWithPresets = (presets, optionName, additionalValues) => (v
842
843
  return objectifyOption(value);
843
844
  };
844
845
  const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
845
- const presetName = value === null || value === void 0 ? void 0 : value.preset;
846
+ const presetName = value?.preset;
846
847
  if (presetName) {
847
848
  const preset = presets[presetName];
848
849
  if (preset) {
@@ -860,7 +861,7 @@ let fsEvents;
860
861
  let fsEventsImportError;
861
862
  async function loadFsEvents() {
862
863
  try {
863
- ({ default: fsEvents } = await Promise.resolve().then(() => /*#__PURE__*/_interopNamespaceDefault(require('fsevents'))));
864
+ ({ default: fsEvents } = await import('fsevents'));
864
865
  }
865
866
  catch (err) {
866
867
  fsEventsImportError = err;
@@ -1028,11 +1029,10 @@ class Chunk$1 {
1028
1029
  this.storeName = false;
1029
1030
  this.edited = false;
1030
1031
 
1031
- // we make these non-enumerable, for sanity while debugging
1032
- Object.defineProperties(this, {
1033
- previous: { writable: true, value: null },
1034
- next: { writable: true, value: null },
1035
- });
1032
+ {
1033
+ this.previous = null;
1034
+ this.next = null;
1035
+ }
1036
1036
  }
1037
1037
 
1038
1038
  appendLeft(content) {
@@ -1675,6 +1675,11 @@ class MagicString {
1675
1675
  }
1676
1676
 
1677
1677
  overwrite(start, end, content, options) {
1678
+ options = options || {};
1679
+ return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
1680
+ }
1681
+
1682
+ update(start, end, content, options) {
1678
1683
  if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
1679
1684
 
1680
1685
  while (start < 0) start += this.original.length;
@@ -1700,7 +1705,7 @@ class MagicString {
1700
1705
  options = { storeName: true };
1701
1706
  }
1702
1707
  const storeName = options !== undefined ? options.storeName : false;
1703
- const contentOnly = options !== undefined ? options.contentOnly : false;
1708
+ const overwrite = options !== undefined ? options.overwrite : false;
1704
1709
 
1705
1710
  if (storeName) {
1706
1711
  const original = this.original.slice(start, end);
@@ -1724,7 +1729,7 @@ class MagicString {
1724
1729
  chunk.edit('', false);
1725
1730
  }
1726
1731
 
1727
- first.edit(content, storeName, contentOnly);
1732
+ first.edit(content, storeName, !overwrite);
1728
1733
  } else {
1729
1734
  // must be inserting at the end
1730
1735
  const newChunk = new Chunk$1(start, end, '').edit(content, storeName);
@@ -2043,7 +2048,7 @@ class MagicString {
2043
2048
  return this.original !== this.toString();
2044
2049
  }
2045
2050
 
2046
- replace(searchValue, replacement) {
2051
+ _replaceRegexp(searchValue, replacement) {
2047
2052
  function getReplacement(match, str) {
2048
2053
  if (typeof replacement === 'string') {
2049
2054
  return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
@@ -2066,7 +2071,7 @@ class MagicString {
2066
2071
  }
2067
2072
  return matches;
2068
2073
  }
2069
- if (typeof searchValue !== 'string' && searchValue.global) {
2074
+ if (searchValue.global) {
2070
2075
  const matches = matchAll(searchValue, this.original);
2071
2076
  matches.forEach((match) => {
2072
2077
  if (match.index != null)
@@ -2087,6 +2092,53 @@ class MagicString {
2087
2092
  }
2088
2093
  return this;
2089
2094
  }
2095
+
2096
+ _replaceString(string, replacement) {
2097
+ const { original } = this;
2098
+ const index = original.indexOf(string);
2099
+
2100
+ if (index !== -1) {
2101
+ this.overwrite(index, index + string.length, replacement);
2102
+ }
2103
+
2104
+ return this;
2105
+ }
2106
+
2107
+ replace(searchValue, replacement) {
2108
+ if (typeof searchValue === 'string') {
2109
+ return this._replaceString(searchValue, replacement);
2110
+ }
2111
+
2112
+ return this._replaceRegexp(searchValue, replacement);
2113
+ }
2114
+
2115
+ _replaceAllString(string, replacement) {
2116
+ const { original } = this;
2117
+ const stringLength = string.length;
2118
+ for (
2119
+ let index = original.indexOf(string);
2120
+ index !== -1;
2121
+ index = original.indexOf(string, index + stringLength)
2122
+ ) {
2123
+ this.overwrite(index, index + stringLength, replacement);
2124
+ }
2125
+
2126
+ return this;
2127
+ }
2128
+
2129
+ replaceAll(searchValue, replacement) {
2130
+ if (typeof searchValue === 'string') {
2131
+ return this._replaceAllString(searchValue, replacement);
2132
+ }
2133
+
2134
+ if (!searchValue.global) {
2135
+ throw new TypeError(
2136
+ 'MagicString.prototype.replaceAll called with a non-global RegExp argument'
2137
+ );
2138
+ }
2139
+
2140
+ return this._replaceRegexp(searchValue, replacement);
2141
+ }
2090
2142
  }
2091
2143
 
2092
2144
  const hasOwnProp = Object.prototype.hasOwnProperty;
@@ -2388,7 +2440,9 @@ class ExternalChunk {
2388
2440
  this.namespaceVariableName = '';
2389
2441
  this.variableName = '';
2390
2442
  this.fileName = null;
2443
+ this.importAssertions = null;
2391
2444
  this.id = module.id;
2445
+ this.moduleInfo = module.info;
2392
2446
  this.renormalizeRenderPath = module.renormalizeRenderPath;
2393
2447
  this.suggestedVariableName = module.suggestedVariableName;
2394
2448
  }
@@ -2401,12 +2455,27 @@ class ExternalChunk {
2401
2455
  (typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
2402
2456
  (this.renormalizeRenderPath ? normalize(node_path.relative(this.inputBase, this.id)) : this.id));
2403
2457
  }
2458
+ getImportAssertions(snippets) {
2459
+ return (this.importAssertions || (this.importAssertions = formatAssertions(this.options.format === 'es' &&
2460
+ this.options.externalImportAssertions &&
2461
+ this.moduleInfo.assertions, snippets)));
2462
+ }
2404
2463
  getImportPath(importer) {
2405
2464
  return escapeId(this.renormalizeRenderPath
2406
2465
  ? getImportPath(importer, this.getFileName(), this.options.format === 'amd', false)
2407
2466
  : this.getFileName());
2408
2467
  }
2409
2468
  }
2469
+ function formatAssertions(assertions, { getObject }) {
2470
+ if (!assertions) {
2471
+ return null;
2472
+ }
2473
+ const assertionEntries = Object.entries(assertions).map(([key, value]) => [key, `'${value}'`]);
2474
+ if (assertionEntries.length) {
2475
+ return getObject(assertionEntries, { lineBreakIndent: null });
2476
+ }
2477
+ return null;
2478
+ }
2410
2479
 
2411
2480
  function getOrCreate(map, key, init) {
2412
2481
  const existing = map.get(key);
@@ -2690,7 +2759,7 @@ function makeLegal(str) {
2690
2759
  }
2691
2760
 
2692
2761
  class ExternalModule {
2693
- constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath) {
2762
+ constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath, assertions) {
2694
2763
  this.options = options;
2695
2764
  this.id = id;
2696
2765
  this.renormalizeRenderPath = renormalizeRenderPath;
@@ -2706,6 +2775,7 @@ class ExternalModule {
2706
2775
  this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
2707
2776
  const { importers, dynamicImporters } = this;
2708
2777
  const info = (this.info = {
2778
+ assertions,
2709
2779
  ast: null,
2710
2780
  code: null,
2711
2781
  dynamicallyImportedIdResolutions: EMPTY_ARRAY,
@@ -2748,8 +2818,7 @@ class ExternalModule {
2748
2818
  return [externalVariable];
2749
2819
  }
2750
2820
  suggestName(name) {
2751
- var _a;
2752
- const value = ((_a = this.nameSuggestions.get(name)) !== null && _a !== void 0 ? _a : 0) + 1;
2821
+ const value = (this.nameSuggestions.get(name) ?? 0) + 1;
2753
2822
  this.nameSuggestions.set(name, value);
2754
2823
  if (value > this.mostCommonSuggestion) {
2755
2824
  this.mostCommonSuggestion = value;
@@ -2804,7 +2873,7 @@ var picomatch$1 = {exports: {}};
2804
2873
 
2805
2874
  var utils$3 = {};
2806
2875
 
2807
- const path$1 = require$$0;
2876
+ const path$1 = require$$0$1;
2808
2877
  const WIN_SLASH = '\\\\/';
2809
2878
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
2810
2879
 
@@ -2984,7 +3053,7 @@ var constants$2 = {
2984
3053
 
2985
3054
  (function (exports) {
2986
3055
 
2987
- const path = require$$0;
3056
+ const path = require$$0$1;
2988
3057
  const win32 = process.platform === 'win32';
2989
3058
  const {
2990
3059
  REGEX_BACKSLASH,
@@ -3483,7 +3552,7 @@ const syntaxError = (type, char) => {
3483
3552
  * @return {Object}
3484
3553
  */
3485
3554
 
3486
- const parse$1 = (input, options) => {
3555
+ const parse$2 = (input, options) => {
3487
3556
  if (typeof input !== 'string') {
3488
3557
  throw new TypeError('Expected a string');
3489
3558
  }
@@ -3686,7 +3755,7 @@ const parse$1 = (input, options) => {
3686
3755
  // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
3687
3756
  //
3688
3757
  // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
3689
- const expression = parse$1(rest, { ...options, fastpaths: false }).output;
3758
+ const expression = parse$2(rest, { ...options, fastpaths: false }).output;
3690
3759
 
3691
3760
  output = token.close = `)${expression})${extglobStar})`;
3692
3761
  }
@@ -4432,7 +4501,7 @@ const parse$1 = (input, options) => {
4432
4501
  * impact when none of the fast paths match.
4433
4502
  */
4434
4503
 
4435
- parse$1.fastpaths = (input, options) => {
4504
+ parse$2.fastpaths = (input, options) => {
4436
4505
  const opts = { ...options };
4437
4506
  const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
4438
4507
  const len = input.length;
@@ -4519,11 +4588,11 @@ parse$1.fastpaths = (input, options) => {
4519
4588
  return source;
4520
4589
  };
4521
4590
 
4522
- var parse_1 = parse$1;
4591
+ var parse_1 = parse$2;
4523
4592
 
4524
- const path = require$$0;
4593
+ const path = require$$0$1;
4525
4594
  const scan = scan_1;
4526
- const parse = parse_1;
4595
+ const parse$1 = parse_1;
4527
4596
  const utils = utils$3;
4528
4597
  const constants = constants$2;
4529
4598
  const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
@@ -4719,7 +4788,7 @@ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str
4719
4788
 
4720
4789
  picomatch.parse = (pattern, options) => {
4721
4790
  if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
4722
- return parse(pattern, { ...options, fastpaths: false });
4791
+ return parse$1(pattern, { ...options, fastpaths: false });
4723
4792
  };
4724
4793
 
4725
4794
  /**
@@ -4812,11 +4881,11 @@ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = fal
4812
4881
  let parsed = { negated: false, fastpaths: true };
4813
4882
 
4814
4883
  if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
4815
- parsed.output = parse.fastpaths(input, options);
4884
+ parsed.output = parse$1.fastpaths(input, options);
4816
4885
  }
4817
4886
 
4818
4887
  if (!parsed.output) {
4819
- parsed = parse(input, options);
4888
+ parsed = parse$1(input, options);
4820
4889
  }
4821
4890
 
4822
4891
  return picomatch.compileRe(parsed, options, returnOutput, returnState);
@@ -4917,22 +4986,22 @@ function ensureArray(thing) {
4917
4986
  }
4918
4987
 
4919
4988
  const normalizePath = function normalizePath(filename) {
4920
- return filename.split(require$$0.win32.sep).join(require$$0.posix.sep);
4989
+ return filename.split(require$$0$1.win32.sep).join(require$$0$1.posix.sep);
4921
4990
  };
4922
4991
 
4923
4992
  function getMatcherString(id, resolutionBase) {
4924
- if (resolutionBase === false || require$$0.isAbsolute(id) || id.startsWith('*')) {
4993
+ if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('*')) {
4925
4994
  return normalizePath(id);
4926
4995
  }
4927
4996
  // resolve('') is valid and will default to process.cwd()
4928
- const basePath = normalizePath(require$$0.resolve(resolutionBase || ''))
4997
+ const basePath = normalizePath(require$$0$1.resolve(resolutionBase || ''))
4929
4998
  // escape all possible (posix + win) path characters that might interfere with regex
4930
4999
  .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
4931
5000
  // Note that we use posix.join because:
4932
5001
  // 1. the basePath has been normalized to use /
4933
5002
  // 2. the incoming glob (id) matcher, also uses /
4934
5003
  // otherwise Node will force backslash (\) on windows
4935
- return require$$0.posix.join(basePath, normalizePath(id));
5004
+ return require$$0$1.posix.join(basePath, normalizePath(id));
4936
5005
  }
4937
5006
  const createFilter = function createFilter(include, exclude, options) {
4938
5007
  const resolutionBase = options && options.resolve;
@@ -5178,11 +5247,10 @@ function getLiteralMembersForValue(value) {
5178
5247
  return Object.create(null);
5179
5248
  }
5180
5249
  function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
5181
- var _a, _b;
5182
5250
  if (typeof memberName !== 'string' || !members[memberName]) {
5183
5251
  return true;
5184
5252
  }
5185
- return ((_b = (_a = members[memberName]).hasEffectsWhenCalled) === null || _b === void 0 ? void 0 : _b.call(_a, interaction, context)) || false;
5253
+ return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false;
5186
5254
  }
5187
5255
  function getMemberReturnExpressionWhenCalled(members, memberName) {
5188
5256
  if (typeof memberName !== 'string' || !members[memberName])
@@ -5609,6 +5677,9 @@ function annotateNode(node, comment, valid) {
5609
5677
  }
5610
5678
 
5611
5679
  const keys = {
5680
+ // TODO this should be removed once ImportExpression follows official ESTree
5681
+ // specs with "null" as default
5682
+ ImportExpression: ['arguments'],
5612
5683
  Literal: [],
5613
5684
  Program: ['body']
5614
5685
  };
@@ -5646,14 +5717,12 @@ class NodeBase extends ExpressionEntity {
5646
5717
  bind() {
5647
5718
  for (const key of this.keys) {
5648
5719
  const value = this[key];
5649
- if (value === null)
5650
- continue;
5651
5720
  if (Array.isArray(value)) {
5652
5721
  for (const child of value) {
5653
- child === null || child === void 0 ? void 0 : child.bind();
5722
+ child?.bind();
5654
5723
  }
5655
5724
  }
5656
- else {
5725
+ else if (value) {
5657
5726
  value.bind();
5658
5727
  }
5659
5728
  }
@@ -5673,7 +5742,7 @@ class NodeBase extends ExpressionEntity {
5673
5742
  continue;
5674
5743
  if (Array.isArray(value)) {
5675
5744
  for (const child of value) {
5676
- if (child === null || child === void 0 ? void 0 : child.hasEffects(context))
5745
+ if (child?.hasEffects(context))
5677
5746
  return true;
5678
5747
  }
5679
5748
  }
@@ -5696,7 +5765,7 @@ class NodeBase extends ExpressionEntity {
5696
5765
  continue;
5697
5766
  if (Array.isArray(value)) {
5698
5767
  for (const child of value) {
5699
- child === null || child === void 0 ? void 0 : child.include(context, includeChildrenRecursively);
5768
+ child?.include(context, includeChildrenRecursively);
5700
5769
  }
5701
5770
  }
5702
5771
  else {
@@ -5753,7 +5822,7 @@ class NodeBase extends ExpressionEntity {
5753
5822
  continue;
5754
5823
  if (Array.isArray(value)) {
5755
5824
  for (const child of value) {
5756
- child === null || child === void 0 ? void 0 : child.render(code, options);
5825
+ child?.render(code, options);
5757
5826
  }
5758
5827
  }
5759
5828
  else {
@@ -5780,7 +5849,7 @@ class NodeBase extends ExpressionEntity {
5780
5849
  continue;
5781
5850
  if (Array.isArray(value)) {
5782
5851
  for (const child of value) {
5783
- child === null || child === void 0 ? void 0 : child.deoptimizePath(UNKNOWN_PATH);
5852
+ child?.deoptimizePath(UNKNOWN_PATH);
5784
5853
  }
5785
5854
  }
5786
5855
  else {
@@ -5836,19 +5905,18 @@ class Method extends ExpressionEntity {
5836
5905
  : this.description.returns()));
5837
5906
  }
5838
5907
  hasEffectsOnInteractionAtPath(path, interaction, context) {
5839
- var _a, _b;
5840
5908
  const { type } = interaction;
5841
5909
  if (path.length > (type === INTERACTION_ACCESSED ? 1 : 0)) {
5842
5910
  return true;
5843
5911
  }
5844
5912
  if (type === INTERACTION_CALLED) {
5845
5913
  if (this.description.mutatesSelfAsArray === true &&
5846
- ((_a = interaction.thisArg) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context))) {
5914
+ interaction.thisArg?.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)) {
5847
5915
  return true;
5848
5916
  }
5849
5917
  if (this.description.callsArgs) {
5850
5918
  for (const argIndex of this.description.callsArgs) {
5851
- if ((_b = interaction.args[argIndex]) === null || _b === void 0 ? void 0 : _b.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
5919
+ if (interaction.args[argIndex]?.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
5852
5920
  return true;
5853
5921
  }
5854
5922
  }
@@ -5924,7 +5992,6 @@ class ObjectEntity extends ExpressionEntity {
5924
5992
  }
5925
5993
  }
5926
5994
  deoptimizeAllProperties(noAccessors) {
5927
- var _a;
5928
5995
  const isDeoptimized = this.hasLostTrack || this.hasUnknownDeoptimizedProperty;
5929
5996
  if (noAccessors) {
5930
5997
  this.hasUnknownDeoptimizedProperty = true;
@@ -5941,7 +6008,7 @@ class ObjectEntity extends ExpressionEntity {
5941
6008
  }
5942
6009
  }
5943
6010
  // While the prototype itself cannot be mutated, each property can
5944
- (_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizePath([UnknownKey, UnknownKey]);
6011
+ this.prototypeExpression?.deoptimizePath([UnknownKey, UnknownKey]);
5945
6012
  this.deoptimizeCachedEntities();
5946
6013
  }
5947
6014
  deoptimizeIntegerProperties() {
@@ -5962,7 +6029,6 @@ class ObjectEntity extends ExpressionEntity {
5962
6029
  }
5963
6030
  // Assumption: If only a specific path is deoptimized, no accessors are created
5964
6031
  deoptimizePath(path) {
5965
- var _a;
5966
6032
  if (this.hasLostTrack || this.immutable) {
5967
6033
  return;
5968
6034
  }
@@ -5992,10 +6058,9 @@ class ObjectEntity extends ExpressionEntity {
5992
6058
  : this.allProperties) {
5993
6059
  property.deoptimizePath(subPath);
5994
6060
  }
5995
- (_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
6061
+ this.prototypeExpression?.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
5996
6062
  }
5997
6063
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
5998
- var _a;
5999
6064
  const [key, ...subPath] = path;
6000
6065
  if (this.hasLostTrack ||
6001
6066
  // single paths that are deoptimized will not become getters or setters
@@ -6051,7 +6116,7 @@ class ObjectEntity extends ExpressionEntity {
6051
6116
  if (!this.immutable) {
6052
6117
  this.thisParametersToBeDeoptimized.add(interaction.thisArg);
6053
6118
  }
6054
- (_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
6119
+ this.prototypeExpression?.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
6055
6120
  }
6056
6121
  getLiteralValueAtPath(path, recursionTracker, origin) {
6057
6122
  if (path.length === 0) {
@@ -6208,7 +6273,7 @@ class ObjectEntity extends ExpressionEntity {
6208
6273
  return UNKNOWN_EXPRESSION;
6209
6274
  }
6210
6275
  const properties = this.propertiesAndGettersByKey[key];
6211
- if ((properties === null || properties === void 0 ? void 0 : properties.length) === 1) {
6276
+ if (properties?.length === 1) {
6212
6277
  return properties[0];
6213
6278
  }
6214
6279
  if (properties ||
@@ -6460,7 +6525,7 @@ class ArrayExpression extends NodeBase {
6460
6525
  class ArrayPattern extends NodeBase {
6461
6526
  addExportedVariables(variables, exportNamesByVariable) {
6462
6527
  for (const element of this.elements) {
6463
- element === null || element === void 0 ? void 0 : element.addExportedVariables(variables, exportNamesByVariable);
6528
+ element?.addExportedVariables(variables, exportNamesByVariable);
6464
6529
  }
6465
6530
  }
6466
6531
  declare(kind) {
@@ -6475,20 +6540,20 @@ class ArrayPattern extends NodeBase {
6475
6540
  // Patterns can only be deoptimized at the empty path at the moment
6476
6541
  deoptimizePath() {
6477
6542
  for (const element of this.elements) {
6478
- element === null || element === void 0 ? void 0 : element.deoptimizePath(EMPTY_PATH);
6543
+ element?.deoptimizePath(EMPTY_PATH);
6479
6544
  }
6480
6545
  }
6481
6546
  // Patterns are only checked at the emtpy path at the moment
6482
6547
  hasEffectsOnInteractionAtPath(_path, interaction, context) {
6483
6548
  for (const element of this.elements) {
6484
- if (element === null || element === void 0 ? void 0 : element.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
6549
+ if (element?.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
6485
6550
  return true;
6486
6551
  }
6487
6552
  return false;
6488
6553
  }
6489
6554
  markDeclarationReached() {
6490
6555
  for (const element of this.elements) {
6491
- element === null || element === void 0 ? void 0 : element.markDeclarationReached();
6556
+ element?.markDeclarationReached();
6492
6557
  }
6493
6558
  }
6494
6559
  }
@@ -6520,7 +6585,6 @@ class LocalVariable extends Variable {
6520
6585
  }
6521
6586
  }
6522
6587
  deoptimizePath(path) {
6523
- var _a, _b;
6524
6588
  if (this.isReassigned ||
6525
6589
  this.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)) {
6526
6590
  return;
@@ -6533,11 +6597,11 @@ class LocalVariable extends Variable {
6533
6597
  for (const expression of expressionsToBeDeoptimized) {
6534
6598
  expression.deoptimizeCache();
6535
6599
  }
6536
- (_a = this.init) === null || _a === void 0 ? void 0 : _a.deoptimizePath(UNKNOWN_PATH);
6600
+ this.init?.deoptimizePath(UNKNOWN_PATH);
6537
6601
  }
6538
6602
  }
6539
6603
  else {
6540
- (_b = this.init) === null || _b === void 0 ? void 0 : _b.deoptimizePath(path);
6604
+ this.init?.deoptimizePath(path);
6541
6605
  }
6542
6606
  }
6543
6607
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
@@ -7872,13 +7936,12 @@ class Identifier extends NodeBase {
7872
7936
  return [(this.variable = variable)];
7873
7937
  }
7874
7938
  deoptimizePath(path) {
7875
- var _a;
7876
7939
  if (path.length === 0 && !this.scope.contains(this.name)) {
7877
7940
  this.disallowImportReassignment();
7878
7941
  }
7879
7942
  // We keep conditional chaining because an unknown Node could have an
7880
7943
  // Identifier as property that might be deoptimized by default
7881
- (_a = this.variable) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
7944
+ this.variable?.deoptimizePath(path);
7882
7945
  }
7883
7946
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
7884
7947
  this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
@@ -8702,10 +8765,9 @@ class FunctionNode extends FunctionBase {
8702
8765
  }
8703
8766
  }
8704
8767
  hasEffects(context) {
8705
- var _a;
8706
8768
  if (!this.deoptimized)
8707
8769
  this.applyDeoptimizations();
8708
- return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
8770
+ return !!this.id?.hasEffects(context);
8709
8771
  }
8710
8772
  hasEffectsOnInteractionAtPath(path, interaction, context) {
8711
8773
  if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
@@ -8736,9 +8798,8 @@ class FunctionNode extends FunctionBase {
8736
8798
  return false;
8737
8799
  }
8738
8800
  include(context, includeChildrenRecursively) {
8739
- var _a;
8740
8801
  super.include(context, includeChildrenRecursively);
8741
- (_a = this.id) === null || _a === void 0 ? void 0 : _a.include();
8802
+ this.id?.include();
8742
8803
  const hasArguments = this.scope.argumentsVariable.included;
8743
8804
  for (const param of this.params) {
8744
8805
  if (!(param instanceof Identifier) || hasArguments) {
@@ -8747,9 +8808,8 @@ class FunctionNode extends FunctionBase {
8747
8808
  }
8748
8809
  }
8749
8810
  initialise() {
8750
- var _a;
8751
8811
  super.initialise();
8752
- (_a = this.id) === null || _a === void 0 ? void 0 : _a.declare('function', this);
8812
+ this.id?.declare('function', this);
8753
8813
  }
8754
8814
  getObjectEntity() {
8755
8815
  if (this.objectEntity !== null) {
@@ -9594,20 +9654,18 @@ class ClassNode extends NodeBase {
9594
9654
  return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
9595
9655
  }
9596
9656
  hasEffects(context) {
9597
- var _a, _b;
9598
9657
  if (!this.deoptimized)
9599
9658
  this.applyDeoptimizations();
9600
- const initEffect = ((_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffects(context)) || this.body.hasEffects(context);
9601
- (_b = this.id) === null || _b === void 0 ? void 0 : _b.markDeclarationReached();
9659
+ const initEffect = this.superClass?.hasEffects(context) || this.body.hasEffects(context);
9660
+ this.id?.markDeclarationReached();
9602
9661
  return initEffect || super.hasEffects(context);
9603
9662
  }
9604
9663
  hasEffectsOnInteractionAtPath(path, interaction, context) {
9605
- var _a;
9606
9664
  if (interaction.type === INTERACTION_CALLED && path.length === 0) {
9607
9665
  return (!interaction.withNew ||
9608
9666
  (this.classConstructor !== null
9609
9667
  ? this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)
9610
- : (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
9668
+ : this.superClass?.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
9611
9669
  false);
9612
9670
  }
9613
9671
  else {
@@ -9615,11 +9673,10 @@ class ClassNode extends NodeBase {
9615
9673
  }
9616
9674
  }
9617
9675
  include(context, includeChildrenRecursively) {
9618
- var _a;
9619
9676
  if (!this.deoptimized)
9620
9677
  this.applyDeoptimizations();
9621
9678
  this.included = true;
9622
- (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
9679
+ this.superClass?.include(context, includeChildrenRecursively);
9623
9680
  this.body.include(context, includeChildrenRecursively);
9624
9681
  if (this.id) {
9625
9682
  this.id.markDeclarationReached();
@@ -9627,8 +9684,7 @@ class ClassNode extends NodeBase {
9627
9684
  }
9628
9685
  }
9629
9686
  initialise() {
9630
- var _a;
9631
- (_a = this.id) === null || _a === void 0 ? void 0 : _a.declare('class', this);
9687
+ this.id?.declare('class', this);
9632
9688
  for (const method of this.body.body) {
9633
9689
  if (method instanceof MethodDefinition && method.kind === 'constructor') {
9634
9690
  this.classConstructor = method;
@@ -10044,13 +10100,11 @@ ExportDefaultDeclaration.prototype.needsBoundaries = true;
10044
10100
 
10045
10101
  class ExportNamedDeclaration extends NodeBase {
10046
10102
  bind() {
10047
- var _a;
10048
10103
  // Do not bind specifiers
10049
- (_a = this.declaration) === null || _a === void 0 ? void 0 : _a.bind();
10104
+ this.declaration?.bind();
10050
10105
  }
10051
10106
  hasEffects(context) {
10052
- var _a;
10053
- return !!((_a = this.declaration) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
10107
+ return !!this.declaration?.hasEffects(context);
10054
10108
  }
10055
10109
  initialise() {
10056
10110
  this.context.addExport(this);
@@ -10168,10 +10222,9 @@ class ForStatement extends NodeBase {
10168
10222
  this.scope = new BlockScope(parentScope);
10169
10223
  }
10170
10224
  hasEffects(context) {
10171
- var _a, _b, _c;
10172
- if (((_a = this.init) === null || _a === void 0 ? void 0 : _a.hasEffects(context)) ||
10173
- ((_b = this.test) === null || _b === void 0 ? void 0 : _b.hasEffects(context)) ||
10174
- ((_c = this.update) === null || _c === void 0 ? void 0 : _c.hasEffects(context)))
10225
+ if (this.init?.hasEffects(context) ||
10226
+ this.test?.hasEffects(context) ||
10227
+ this.update?.hasEffects(context))
10175
10228
  return true;
10176
10229
  const { brokenFlow, ignore: { breaks, continues } } = context;
10177
10230
  context.ignore.breaks = true;
@@ -10184,20 +10237,18 @@ class ForStatement extends NodeBase {
10184
10237
  return false;
10185
10238
  }
10186
10239
  include(context, includeChildrenRecursively) {
10187
- var _a, _b, _c;
10188
10240
  this.included = true;
10189
- (_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively, { asSingleStatement: true });
10190
- (_b = this.test) === null || _b === void 0 ? void 0 : _b.include(context, includeChildrenRecursively);
10241
+ this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
10242
+ this.test?.include(context, includeChildrenRecursively);
10191
10243
  const { brokenFlow } = context;
10192
- (_c = this.update) === null || _c === void 0 ? void 0 : _c.include(context, includeChildrenRecursively);
10244
+ this.update?.include(context, includeChildrenRecursively);
10193
10245
  this.body.include(context, includeChildrenRecursively, { asSingleStatement: true });
10194
10246
  context.brokenFlow = brokenFlow;
10195
10247
  }
10196
10248
  render(code, options) {
10197
- var _a, _b, _c;
10198
- (_a = this.init) === null || _a === void 0 ? void 0 : _a.render(code, options, NO_SEMICOLON);
10199
- (_b = this.test) === null || _b === void 0 ? void 0 : _b.render(code, options, NO_SEMICOLON);
10200
- (_c = this.update) === null || _c === void 0 ? void 0 : _c.render(code, options, NO_SEMICOLON);
10249
+ this.init?.render(code, options, NO_SEMICOLON);
10250
+ this.test?.render(code, options, NO_SEMICOLON);
10251
+ this.update?.render(code, options, NO_SEMICOLON);
10201
10252
  this.body.render(code, options);
10202
10253
  }
10203
10254
  }
@@ -10233,7 +10284,6 @@ class IfStatement extends NodeBase {
10233
10284
  this.testValue = UnknownValue;
10234
10285
  }
10235
10286
  hasEffects(context) {
10236
- var _a;
10237
10287
  if (this.test.hasEffects(context)) {
10238
10288
  return true;
10239
10289
  }
@@ -10252,7 +10302,7 @@ class IfStatement extends NodeBase {
10252
10302
  context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
10253
10303
  return false;
10254
10304
  }
10255
- return testValue ? this.consequent.hasEffects(context) : !!((_a = this.alternate) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
10305
+ return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
10256
10306
  }
10257
10307
  include(context, includeChildrenRecursively) {
10258
10308
  this.included = true;
@@ -10330,25 +10380,22 @@ class IfStatement extends NodeBase {
10330
10380
  return this.testValue;
10331
10381
  }
10332
10382
  includeKnownTest(context, testValue) {
10333
- var _a;
10334
10383
  if (this.test.shouldBeIncluded(context)) {
10335
10384
  this.test.include(context, false);
10336
10385
  }
10337
10386
  if (testValue && this.consequent.shouldBeIncluded(context)) {
10338
10387
  this.consequent.include(context, false, { asSingleStatement: true });
10339
10388
  }
10340
- if (!testValue && ((_a = this.alternate) === null || _a === void 0 ? void 0 : _a.shouldBeIncluded(context))) {
10389
+ if (!testValue && this.alternate?.shouldBeIncluded(context)) {
10341
10390
  this.alternate.include(context, false, { asSingleStatement: true });
10342
10391
  }
10343
10392
  }
10344
10393
  includeRecursively(includeChildrenRecursively, context) {
10345
- var _a;
10346
10394
  this.test.include(context, includeChildrenRecursively);
10347
10395
  this.consequent.include(context, includeChildrenRecursively);
10348
- (_a = this.alternate) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
10396
+ this.alternate?.include(context, includeChildrenRecursively);
10349
10397
  }
10350
10398
  includeUnknownTest(context) {
10351
- var _a;
10352
10399
  this.test.include(context, false);
10353
10400
  const { brokenFlow } = context;
10354
10401
  let consequentBrokenFlow = BROKEN_FLOW_NONE;
@@ -10357,7 +10404,7 @@ class IfStatement extends NodeBase {
10357
10404
  consequentBrokenFlow = context.brokenFlow;
10358
10405
  context.brokenFlow = brokenFlow;
10359
10406
  }
10360
- if ((_a = this.alternate) === null || _a === void 0 ? void 0 : _a.shouldBeIncluded(context)) {
10407
+ if (this.alternate?.shouldBeIncluded(context)) {
10361
10408
  this.alternate.include(context, false, { asSingleStatement: true });
10362
10409
  context.brokenFlow =
10363
10410
  context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow;
@@ -10396,8 +10443,11 @@ class IfStatement extends NodeBase {
10396
10443
  }
10397
10444
  }
10398
10445
 
10446
+ class ImportAttribute extends NodeBase {
10447
+ }
10448
+
10399
10449
  class ImportDeclaration extends NodeBase {
10400
- // Do not bind specifiers
10450
+ // Do not bind specifiers or assertions
10401
10451
  bind() { }
10402
10452
  hasEffects() {
10403
10453
  return false;
@@ -10621,15 +10671,22 @@ function getToStringTagValue(getObject) {
10621
10671
  });
10622
10672
  }
10623
10673
 
10674
+ // TODO once ImportExpression follows official ESTree specs with "null" as
10675
+ // default, keys.ts should be updated
10624
10676
  class ImportExpression extends NodeBase {
10625
10677
  constructor() {
10626
10678
  super(...arguments);
10627
10679
  this.inlineNamespace = null;
10680
+ this.assertions = null;
10628
10681
  this.mechanism = null;
10629
10682
  this.namespaceExportName = undefined;
10630
10683
  this.resolution = null;
10631
10684
  this.resolutionString = null;
10632
10685
  }
10686
+ // Do not bind assertions
10687
+ bind() {
10688
+ this.source.bind();
10689
+ }
10633
10690
  hasEffects() {
10634
10691
  return true;
10635
10692
  }
@@ -10645,19 +10702,19 @@ class ImportExpression extends NodeBase {
10645
10702
  this.context.addDynamicImport(this);
10646
10703
  }
10647
10704
  render(code, options) {
10648
- const { snippets: { getDirectReturnFunction, getPropertyAccess } } = options;
10705
+ const { snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess } } = options;
10649
10706
  if (this.inlineNamespace) {
10650
10707
  const [left, right] = getDirectReturnFunction([], {
10651
10708
  functionReturn: true,
10652
10709
  lineBreakIndent: null,
10653
10710
  name: null
10654
10711
  });
10655
- code.overwrite(this.start, this.end, `Promise.resolve().then(${left}${this.inlineNamespace.getName(getPropertyAccess)}${right})`, { contentOnly: true });
10712
+ code.overwrite(this.start, this.end, `Promise.resolve().then(${left}${this.inlineNamespace.getName(getPropertyAccess)}${right})`);
10656
10713
  return;
10657
10714
  }
10658
10715
  if (this.mechanism) {
10659
- code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left, { contentOnly: true });
10660
- code.overwrite(this.end - 1, this.end, this.mechanism.right, { contentOnly: true });
10716
+ code.overwrite(this.start, findFirstOccurrenceOutsideComment(code.original, '(', this.start + 6) + 1, this.mechanism.left);
10717
+ code.overwrite(this.end - 1, this.end, this.mechanism.right);
10661
10718
  }
10662
10719
  if (this.resolutionString) {
10663
10720
  code.overwrite(this.source.start, this.source.end, this.resolutionString);
@@ -10673,13 +10730,24 @@ class ImportExpression extends NodeBase {
10673
10730
  else {
10674
10731
  this.source.render(code, options);
10675
10732
  }
10733
+ if (this.assertions !== true) {
10734
+ if (this.arguments) {
10735
+ code.overwrite(this.source.end, this.end - 1, '', { contentOnly: true });
10736
+ }
10737
+ if (this.assertions) {
10738
+ code.appendLeft(this.end - 1, `,${_}${getObject([['assert', this.assertions]], {
10739
+ lineBreakIndent: null
10740
+ })}`);
10741
+ }
10742
+ }
10676
10743
  }
10677
- setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName) {
10744
+ setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, assertions) {
10678
10745
  const { format } = options;
10679
10746
  this.inlineNamespace = null;
10680
10747
  this.resolution = resolution;
10681
10748
  this.resolutionString = resolutionString;
10682
10749
  this.namespaceExportName = namespaceExportName;
10750
+ this.assertions = assertions;
10683
10751
  const accessedGlobals = [...(accessedImportGlobals[format] || [])];
10684
10752
  let helper;
10685
10753
  ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
@@ -10694,7 +10762,7 @@ class ImportExpression extends NodeBase {
10694
10762
  this.inlineNamespace = inlineNamespace;
10695
10763
  }
10696
10764
  applyDeoptimizations() { }
10697
- getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportFunction, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
10765
+ getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportFunction, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
10698
10766
  const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
10699
10767
  {
10700
10768
  customResolution: typeof this.resolution === 'string' ? this.resolution : null,
@@ -10709,6 +10777,10 @@ class ImportExpression extends NodeBase {
10709
10777
  const hasDynamicTarget = !this.resolution || typeof this.resolution === 'string';
10710
10778
  switch (format) {
10711
10779
  case 'cjs': {
10780
+ if (dynamicImportInCjs &&
10781
+ (!resolution || typeof resolution === 'string' || resolution instanceof ExternalModule)) {
10782
+ return { helper: null, mechanism: null };
10783
+ }
10712
10784
  const helper = getInteropHelper(resolution, exportMode, interop);
10713
10785
  let left = `require(`;
10714
10786
  let right = `)`;
@@ -10984,7 +11056,7 @@ class MetaProperty extends NodeBase {
10984
11056
  }
10985
11057
  getReferencedFileName(outputPluginDriver) {
10986
11058
  const { metaProperty } = this;
10987
- if (metaProperty === null || metaProperty === void 0 ? void 0 : metaProperty.startsWith(FILE_PREFIX)) {
11059
+ if (metaProperty?.startsWith(FILE_PREFIX)) {
10988
11060
  return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length));
10989
11061
  }
10990
11062
  return null;
@@ -11005,14 +11077,13 @@ class MetaProperty extends NodeBase {
11005
11077
  parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
11006
11078
  ? parent.propertyKey
11007
11079
  : null);
11008
- if (metaProperty === null || metaProperty === void 0 ? void 0 : metaProperty.startsWith(FILE_PREFIX)) {
11080
+ if (metaProperty?.startsWith(FILE_PREFIX)) {
11009
11081
  this.referenceId = metaProperty.substring(FILE_PREFIX.length);
11010
11082
  }
11011
11083
  }
11012
11084
  }
11013
11085
  }
11014
11086
  render(code, { format, pluginDriver, snippets }) {
11015
- var _a;
11016
11087
  const { metaProperty, parent, referenceId } = this;
11017
11088
  const chunkId = this.preliminaryChunkId;
11018
11089
  if (referenceId) {
@@ -11038,7 +11109,7 @@ class MetaProperty extends NodeBase {
11038
11109
  format,
11039
11110
  moduleId: this.context.module.id
11040
11111
  }
11041
- ]) || ((_a = importMetaMechanisms[format]) === null || _a === void 0 ? void 0 : _a.call(importMetaMechanisms, metaProperty, { chunkId, snippets }));
11112
+ ]) || importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets });
11042
11113
  if (typeof replacement === 'string') {
11043
11114
  if (parent instanceof MemberExpression) {
11044
11115
  code.overwrite(parent.start, parent.end, replacement, { contentOnly: true });
@@ -11049,9 +11120,8 @@ class MetaProperty extends NodeBase {
11049
11120
  }
11050
11121
  }
11051
11122
  setResolution(format, accessedGlobalsByScope, preliminaryChunkId) {
11052
- var _a;
11053
11123
  this.preliminaryChunkId = preliminaryChunkId;
11054
- const accessedGlobals = (((_a = this.metaProperty) === null || _a === void 0 ? void 0 : _a.startsWith(FILE_PREFIX)) ? accessedFileUrlGlobals : accessedMetaUrlGlobals)[format];
11124
+ const accessedGlobals = (this.metaProperty?.startsWith(FILE_PREFIX) ? accessedFileUrlGlobals : accessedMetaUrlGlobals)[format];
11055
11125
  if (accessedGlobals.length > 0) {
11056
11126
  this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope);
11057
11127
  }
@@ -11309,12 +11379,10 @@ class Property extends MethodBase {
11309
11379
 
11310
11380
  class PropertyDefinition extends NodeBase {
11311
11381
  deoptimizePath(path) {
11312
- var _a;
11313
- (_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
11382
+ this.value?.deoptimizePath(path);
11314
11383
  }
11315
11384
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
11316
- var _a;
11317
- (_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
11385
+ this.value?.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
11318
11386
  }
11319
11387
  getLiteralValueAtPath(path, recursionTracker, origin) {
11320
11388
  return this.value
@@ -11327,8 +11395,7 @@ class PropertyDefinition extends NodeBase {
11327
11395
  : UNKNOWN_EXPRESSION;
11328
11396
  }
11329
11397
  hasEffects(context) {
11330
- var _a;
11331
- return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
11398
+ return this.key.hasEffects(context) || (this.static && !!this.value?.hasEffects(context));
11332
11399
  }
11333
11400
  hasEffectsOnInteractionAtPath(path, interaction, context) {
11334
11401
  return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
@@ -11338,16 +11405,14 @@ class PropertyDefinition extends NodeBase {
11338
11405
 
11339
11406
  class ReturnStatement extends NodeBase {
11340
11407
  hasEffects(context) {
11341
- var _a;
11342
- if (!context.ignore.returnYield || ((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context)))
11408
+ if (!context.ignore.returnYield || this.argument?.hasEffects(context))
11343
11409
  return true;
11344
11410
  context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
11345
11411
  return false;
11346
11412
  }
11347
11413
  include(context, includeChildrenRecursively) {
11348
- var _a;
11349
11414
  this.included = true;
11350
- (_a = this.argument) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
11415
+ this.argument?.include(context, includeChildrenRecursively);
11351
11416
  context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
11352
11417
  }
11353
11418
  initialise() {
@@ -11473,8 +11538,7 @@ class Super extends NodeBase {
11473
11538
 
11474
11539
  class SwitchCase extends NodeBase {
11475
11540
  hasEffects(context) {
11476
- var _a;
11477
- if ((_a = this.test) === null || _a === void 0 ? void 0 : _a.hasEffects(context))
11541
+ if (this.test?.hasEffects(context))
11478
11542
  return true;
11479
11543
  for (const node of this.consequent) {
11480
11544
  if (context.brokenFlow)
@@ -11485,9 +11549,8 @@ class SwitchCase extends NodeBase {
11485
11549
  return false;
11486
11550
  }
11487
11551
  include(context, includeChildrenRecursively) {
11488
- var _a;
11489
11552
  this.included = true;
11490
- (_a = this.test) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
11553
+ this.test?.include(context, includeChildrenRecursively);
11491
11554
  for (const node of this.consequent) {
11492
11555
  if (includeChildrenRecursively || node.shouldBeIncluded(context))
11493
11556
  node.include(context, includeChildrenRecursively);
@@ -11874,14 +11937,13 @@ class TryStatement extends NodeBase {
11874
11937
  this.includedLabelsAfterBlock = null;
11875
11938
  }
11876
11939
  hasEffects(context) {
11877
- var _a;
11878
11940
  return ((this.context.options.treeshake.tryCatchDeoptimization
11879
11941
  ? this.block.body.length > 0
11880
- : this.block.hasEffects(context)) || !!((_a = this.finalizer) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
11942
+ : this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
11881
11943
  }
11882
11944
  include(context, includeChildrenRecursively) {
11883
- var _a, _b;
11884
- const tryCatchDeoptimization = (_a = this.context.options.treeshake) === null || _a === void 0 ? void 0 : _a.tryCatchDeoptimization;
11945
+ const tryCatchDeoptimization = this.context.options.treeshake
11946
+ ?.tryCatchDeoptimization;
11885
11947
  const { brokenFlow } = context;
11886
11948
  if (!this.directlyIncluded || !tryCatchDeoptimization) {
11887
11949
  this.included = true;
@@ -11901,7 +11963,7 @@ class TryStatement extends NodeBase {
11901
11963
  this.handler.include(context, includeChildrenRecursively);
11902
11964
  context.brokenFlow = brokenFlow;
11903
11965
  }
11904
- (_b = this.finalizer) === null || _b === void 0 ? void 0 : _b.include(context, includeChildrenRecursively);
11966
+ this.finalizer?.include(context, includeChildrenRecursively);
11905
11967
  }
11906
11968
  }
11907
11969
 
@@ -12153,14 +12215,13 @@ class VariableDeclaration extends NodeBase {
12153
12215
  }
12154
12216
  }
12155
12217
  function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports) {
12156
- var _a;
12157
12218
  let singleSystemExport = null;
12158
12219
  if (options.format === 'system') {
12159
12220
  for (const { node } of separatedNodes) {
12160
12221
  if (node.id instanceof Identifier &&
12161
12222
  node.init &&
12162
12223
  aggregatedSystemExports.length === 0 &&
12163
- ((_a = options.exportNamesByVariable.get(node.id.variable)) === null || _a === void 0 ? void 0 : _a.length) === 1) {
12224
+ options.exportNamesByVariable.get(node.id.variable)?.length === 1) {
12164
12225
  singleSystemExport = node.id.variable;
12165
12226
  aggregatedSystemExports.push(singleSystemExport);
12166
12227
  }
@@ -12186,15 +12247,13 @@ class VariableDeclarator extends NodeBase {
12186
12247
  this.id.deoptimizePath(path);
12187
12248
  }
12188
12249
  hasEffects(context) {
12189
- var _a;
12190
- const initEffect = (_a = this.init) === null || _a === void 0 ? void 0 : _a.hasEffects(context);
12250
+ const initEffect = this.init?.hasEffects(context);
12191
12251
  this.id.markDeclarationReached();
12192
12252
  return initEffect || this.id.hasEffects(context);
12193
12253
  }
12194
12254
  include(context, includeChildrenRecursively) {
12195
- var _a;
12196
12255
  this.included = true;
12197
- (_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
12256
+ this.init?.include(context, includeChildrenRecursively);
12198
12257
  this.id.markDeclarationReached();
12199
12258
  if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
12200
12259
  this.id.include(context, includeChildrenRecursively);
@@ -12246,10 +12305,9 @@ class WhileStatement extends NodeBase {
12246
12305
 
12247
12306
  class YieldExpression extends NodeBase {
12248
12307
  hasEffects(context) {
12249
- var _a;
12250
12308
  if (!this.deoptimized)
12251
12309
  this.applyDeoptimizations();
12252
- return !(context.ignore.returnYield && !((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
12310
+ return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
12253
12311
  }
12254
12312
  render(code, options) {
12255
12313
  if (this.argument) {
@@ -12293,6 +12351,7 @@ const nodeConstructors = {
12293
12351
  FunctionExpression,
12294
12352
  Identifier,
12295
12353
  IfStatement,
12354
+ ImportAttribute,
12296
12355
  ImportDeclaration,
12297
12356
  ImportDefaultSpecifier,
12298
12357
  ImportExpression,
@@ -12517,6 +12576,41 @@ function getOriginalLocation(sourcemapChain, location) {
12517
12576
  return location;
12518
12577
  }
12519
12578
 
12579
+ function getAssertionsFromImportExpression(node) {
12580
+ const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
12581
+ if (!assertProperty) {
12582
+ return EMPTY_OBJECT;
12583
+ }
12584
+ const assertFields = assertProperty.properties
12585
+ .map(property => {
12586
+ const key = getPropertyKey(property);
12587
+ if (typeof key === 'string' &&
12588
+ typeof property.value.value === 'string') {
12589
+ return [key, property.value.value];
12590
+ }
12591
+ return null;
12592
+ })
12593
+ .filter((property) => !!property);
12594
+ if (assertFields.length > 0) {
12595
+ return Object.fromEntries(assertFields);
12596
+ }
12597
+ return EMPTY_OBJECT;
12598
+ }
12599
+ const getPropertyKey = (property) => {
12600
+ const key = property.key;
12601
+ return key && (key.name || key.value);
12602
+ };
12603
+ function getAssertionsFromImportExportDeclaration(assertions) {
12604
+ return assertions?.length
12605
+ ? Object.fromEntries(assertions.map(assertion => [getPropertyKey(assertion), assertion.value.value]))
12606
+ : EMPTY_OBJECT;
12607
+ }
12608
+ function doAssertionsDiffer(assertionA, assertionB) {
12609
+ const keysA = Object.keys(assertionA);
12610
+ return (keysA.length !== Object.keys(assertionB).length ||
12611
+ keysA.some(key => assertionA[key] !== assertionB[key]));
12612
+ }
12613
+
12520
12614
  const NOOP = () => { };
12521
12615
  let timers = new Map();
12522
12616
  function getPersistedLabel(label, level) {
@@ -12687,7 +12781,7 @@ function getAndExtendSideEffectModules(variable, module) {
12687
12781
  return sideEffectModules;
12688
12782
  }
12689
12783
  class Module {
12690
- constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta) {
12784
+ constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta, assertions) {
12691
12785
  this.graph = graph;
12692
12786
  this.id = id;
12693
12787
  this.options = options;
@@ -12712,7 +12806,7 @@ class Module {
12712
12806
  this.isUserDefinedEntryPoint = false;
12713
12807
  this.needsExportShim = false;
12714
12808
  this.sideEffectDependenciesByVariable = new Map();
12715
- this.sources = new Set();
12809
+ this.sourcesWithAssertions = new Map();
12716
12810
  this.allExportNames = null;
12717
12811
  this.ast = null;
12718
12812
  this.exportAllModules = [];
@@ -12732,8 +12826,9 @@ class Module {
12732
12826
  this.preserveSignature = this.options.preserveEntrySignatures;
12733
12827
  // eslint-disable-next-line @typescript-eslint/no-this-alias
12734
12828
  const module = this;
12735
- const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sources } = this;
12829
+ const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAssertions } = this;
12736
12830
  this.info = {
12831
+ assertions,
12737
12832
  ast: null,
12738
12833
  code: null,
12739
12834
  get dynamicallyImportedIdResolutions() {
@@ -12768,12 +12863,12 @@ class Module {
12768
12863
  return Array.from(implicitlyLoadedBefore, getId).sort();
12769
12864
  },
12770
12865
  get importedIdResolutions() {
12771
- return Array.from(sources, source => module.resolvedIds[source]).filter(Boolean);
12866
+ return Array.from(sourcesWithAssertions.keys(), source => module.resolvedIds[source]).filter(Boolean);
12772
12867
  },
12773
12868
  get importedIds() {
12774
12869
  // We cannot use this.dependencies because this is needed before
12775
12870
  // dependencies are populated
12776
- return Array.from(sources, source => { var _a; return (_a = module.resolvedIds[source]) === null || _a === void 0 ? void 0 : _a.id; }).filter(Boolean);
12871
+ return Array.from(sourcesWithAssertions.keys(), source => module.resolvedIds[source]?.id).filter(Boolean);
12777
12872
  },
12778
12873
  get importers() {
12779
12874
  return importers.sort();
@@ -12945,7 +13040,6 @@ class Module {
12945
13040
  return this.syntheticNamespace;
12946
13041
  }
12947
13042
  getVariableForExportName(name, { importerForSideEffects, isExportAllSearch, onlyExplicit, searchedNamesAndModules } = EMPTY_OBJECT) {
12948
- var _a;
12949
13043
  if (name[0] === '*') {
12950
13044
  if (name.length === 1) {
12951
13045
  // export * from './other'
@@ -12987,7 +13081,8 @@ class Module {
12987
13081
  return [null];
12988
13082
  }
12989
13083
  if (name !== 'default') {
12990
- const foundNamespaceReexport = (_a = this.namespaceReexportsByName.get(name)) !== null && _a !== void 0 ? _a : this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules);
13084
+ const foundNamespaceReexport = this.namespaceReexportsByName.get(name) ??
13085
+ this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules);
12991
13086
  this.namespaceReexportsByName.set(name, foundNamespaceReexport);
12992
13087
  if (foundNamespaceReexport[0]) {
12993
13088
  return foundNamespaceReexport;
@@ -13139,6 +13234,7 @@ class Module {
13139
13234
  }
13140
13235
  toJSON() {
13141
13236
  return {
13237
+ assertions: this.info.assertions,
13142
13238
  ast: this.ast.esTreeNode,
13143
13239
  code: this.info.code,
13144
13240
  customTransformCache: this.customTransformCache,
@@ -13219,7 +13315,7 @@ class Module {
13219
13315
  }
13220
13316
  else if (node instanceof ExportAllDeclaration) {
13221
13317
  const source = node.source.value;
13222
- this.sources.add(source);
13318
+ this.addSource(source, node);
13223
13319
  if (node.exported) {
13224
13320
  // export * as name from './other'
13225
13321
  const name = node.exported.name;
@@ -13238,7 +13334,7 @@ class Module {
13238
13334
  else if (node.source instanceof Literal) {
13239
13335
  // export { name } from './other'
13240
13336
  const source = node.source.value;
13241
- this.sources.add(source);
13337
+ this.addSource(source, node);
13242
13338
  for (const specifier of node.specifiers) {
13243
13339
  const name = specifier.exported.name;
13244
13340
  this.reexportDescriptions.set(name, {
@@ -13277,7 +13373,7 @@ class Module {
13277
13373
  }
13278
13374
  addImport(node) {
13279
13375
  const source = node.source.value;
13280
- this.sources.add(source);
13376
+ this.addSource(source, node);
13281
13377
  for (const specifier of node.specifiers) {
13282
13378
  const isDefault = specifier.type === ImportDefaultSpecifier$1;
13283
13379
  const isNamespace = specifier.type === ImportNamespaceSpecifier$1;
@@ -13341,6 +13437,18 @@ class Module {
13341
13437
  addSideEffectDependencies(this.dependencies);
13342
13438
  addSideEffectDependencies(alwaysCheckedDependencies);
13343
13439
  }
13440
+ addSource(source, declaration) {
13441
+ const parsedAssertions = getAssertionsFromImportExportDeclaration(declaration.assertions);
13442
+ const existingAssertions = this.sourcesWithAssertions.get(source);
13443
+ if (existingAssertions) {
13444
+ if (doAssertionsDiffer(existingAssertions, parsedAssertions)) {
13445
+ this.warn(errInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
13446
+ }
13447
+ }
13448
+ else {
13449
+ this.sourcesWithAssertions.set(source, parsedAssertions);
13450
+ }
13451
+ }
13344
13452
  getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules) {
13345
13453
  let foundSyntheticDeclaration = null;
13346
13454
  const foundInternalDeclarations = new Map();
@@ -13792,8 +13900,8 @@ function getImportBlock$1(dependencies, { _, cnst, n }, compact) {
13792
13900
  }
13793
13901
 
13794
13902
  function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }, { externalLiveBindings, freeze, namespaceToStringTag }) {
13795
- const { _, n } = snippets;
13796
- const importBlock = getImportBlock(dependencies, _);
13903
+ const { n } = snippets;
13904
+ const importBlock = getImportBlock(dependencies, snippets);
13797
13905
  if (importBlock.length > 0)
13798
13906
  intro += importBlock.join(n) + n + n;
13799
13907
  intro += getHelpersBlock(null, accessedGlobals, t, snippets, externalLiveBindings, freeze, namespaceToStringTag);
@@ -13806,11 +13914,13 @@ function es(magicString, { accessedGlobals, indent: t, intro, outro, dependencie
13806
13914
  magicString.append(outro);
13807
13915
  magicString.trim();
13808
13916
  }
13809
- function getImportBlock(dependencies, _) {
13917
+ function getImportBlock(dependencies, { _ }) {
13810
13918
  const importBlock = [];
13811
- for (const { importPath, reexports, imports, name } of dependencies) {
13919
+ for (const { importPath, reexports, imports, name, assertions } of dependencies) {
13920
+ const assertion = assertions ? `${_}assert${_}${assertions}` : '';
13921
+ const pathWithAssertion = `'${importPath}'${assertion};`;
13812
13922
  if (!reexports && !imports) {
13813
- importBlock.push(`import${_}'${importPath}';`);
13923
+ importBlock.push(`import${_}${pathWithAssertion}`);
13814
13924
  continue;
13815
13925
  }
13816
13926
  if (imports) {
@@ -13829,10 +13939,10 @@ function getImportBlock(dependencies, _) {
13829
13939
  }
13830
13940
  }
13831
13941
  if (starImport) {
13832
- importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${importPath}';`);
13942
+ importBlock.push(`import${_}*${_}as ${starImport.local} from${_}${pathWithAssertion}`);
13833
13943
  }
13834
13944
  if (defaultImport && importedNames.length === 0) {
13835
- importBlock.push(`import ${defaultImport.local} from${_}'${importPath}';`);
13945
+ importBlock.push(`import ${defaultImport.local} from${_}${pathWithAssertion}`);
13836
13946
  }
13837
13947
  else if (importedNames.length > 0) {
13838
13948
  importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
@@ -13844,7 +13954,7 @@ function getImportBlock(dependencies, _) {
13844
13954
  return `${specifier.imported} as ${specifier.local}`;
13845
13955
  }
13846
13956
  })
13847
- .join(`,${_}`)}${_}}${_}from${_}'${importPath}';`);
13957
+ .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13848
13958
  }
13849
13959
  }
13850
13960
  if (reexports) {
@@ -13863,12 +13973,12 @@ function getImportBlock(dependencies, _) {
13863
13973
  }
13864
13974
  }
13865
13975
  if (starExport) {
13866
- importBlock.push(`export${_}*${_}from${_}'${importPath}';`);
13976
+ importBlock.push(`export${_}*${_}from${_}${pathWithAssertion}`);
13867
13977
  }
13868
13978
  if (namespaceReexports.length > 0) {
13869
13979
  if (!imports ||
13870
13980
  !imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
13871
- importBlock.push(`import${_}*${_}as ${name} from${_}'${importPath}';`);
13981
+ importBlock.push(`import${_}*${_}as ${name} from${_}${pathWithAssertion}`);
13872
13982
  }
13873
13983
  for (const specifier of namespaceReexports) {
13874
13984
  importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
@@ -13884,7 +13994,7 @@ function getImportBlock(dependencies, _) {
13884
13994
  return `${specifier.imported} as ${specifier.reexported}`;
13885
13995
  }
13886
13996
  })
13887
- .join(`,${_}`)}${_}}${_}from${_}'${importPath}';`);
13997
+ .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13888
13998
  }
13889
13999
  }
13890
14000
  }
@@ -14247,380 +14357,93 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
14247
14357
 
14248
14358
  const finalisers = { amd, cjs, es, iife, system, umd };
14249
14359
 
14250
- const createHash = () => node_crypto.createHash('sha256');
14360
+ const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
14361
+ const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
14362
+ async function createAddons(options, outputPluginDriver, chunk) {
14363
+ try {
14364
+ let [banner, footer, intro, outro] = await Promise.all([
14365
+ outputPluginDriver.hookReduceValue('banner', options.banner(chunk), [chunk], concatSep),
14366
+ outputPluginDriver.hookReduceValue('footer', options.footer(chunk), [chunk], concatSep),
14367
+ outputPluginDriver.hookReduceValue('intro', options.intro(chunk), [chunk], concatDblSep),
14368
+ outputPluginDriver.hookReduceValue('outro', options.outro(chunk), [chunk], concatDblSep)
14369
+ ]);
14370
+ if (intro)
14371
+ intro += '\n\n';
14372
+ if (outro)
14373
+ outro = `\n\n${outro}`;
14374
+ if (banner)
14375
+ banner += '\n';
14376
+ if (footer)
14377
+ footer = '\n' + footer;
14378
+ return { banner, footer, intro, outro };
14379
+ }
14380
+ catch (err) {
14381
+ return error(errAddonNotGenerated(err.message, err.hook, err.plugin));
14382
+ }
14383
+ }
14251
14384
 
14252
- // Four random characters from the private use area to minimize risk of conflicts
14253
- const hashPlaceholderLeft = '!~{';
14254
- const hashPlaceholderRight = '}~';
14255
- const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
14256
- // This is the size of a sha256
14257
- const maxHashSize = 64;
14258
- const defaultHashSize = 8;
14259
- const getHashPlaceholderGenerator = () => {
14260
- let nextIndex = 0;
14261
- return (optionName, hashSize = defaultHashSize) => {
14262
- if (hashSize > maxHashSize) {
14263
- return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
14385
+ const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
14386
+ amd: deconflictImportsOther,
14387
+ cjs: deconflictImportsOther,
14388
+ es: deconflictImportsEsmOrSystem,
14389
+ iife: deconflictImportsOther,
14390
+ system: deconflictImportsEsmOrSystem,
14391
+ umd: deconflictImportsOther
14392
+ };
14393
+ function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
14394
+ const reversedModules = modules.slice().reverse();
14395
+ for (const module of reversedModules) {
14396
+ module.scope.addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope);
14397
+ }
14398
+ deconflictTopLevelVariables(usedNames, reversedModules, includedNamespaces);
14399
+ DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports);
14400
+ for (const module of reversedModules) {
14401
+ module.scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
14402
+ }
14403
+ }
14404
+ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports) {
14405
+ // This is needed for namespace reexports
14406
+ for (const dependency of dependenciesToBeDeconflicted.dependencies) {
14407
+ if (preserveModules || dependency instanceof ExternalChunk) {
14408
+ dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
14264
14409
  }
14265
- const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
14266
- if (placeholder.length > hashSize) {
14267
- return error(errFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
14410
+ }
14411
+ for (const variable of imports) {
14412
+ const module = variable.module;
14413
+ const name = variable.name;
14414
+ if (variable.isNamespace && (preserveModules || module instanceof ExternalModule)) {
14415
+ variable.setRenderNames(null, (module instanceof ExternalModule
14416
+ ? externalChunkByModule.get(module)
14417
+ : chunkByModule.get(module)).variableName);
14268
14418
  }
14269
- return placeholder;
14270
- };
14271
- };
14272
- const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
14273
- const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
14274
- const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
14275
- const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
14276
- const containedPlaceholders = new Set();
14277
- const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
14278
- if (placeholders.has(placeholder)) {
14279
- containedPlaceholders.add(placeholder);
14280
- return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
14419
+ else if (module instanceof ExternalModule && name === 'default') {
14420
+ variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
14421
+ ? module.suggestedVariableName + '__default'
14422
+ : module.suggestedVariableName, usedNames));
14281
14423
  }
14282
- return placeholder;
14283
- });
14284
- return { containedPlaceholders, transformedCode };
14285
- };
14286
-
14287
- function renderNamePattern(pattern, patternName, replacements) {
14288
- if (isPathFragment(pattern))
14289
- return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
14290
- return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
14291
- if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
14292
- return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
14424
+ else {
14425
+ variable.setRenderNames(null, getSafeName(name, usedNames));
14293
14426
  }
14294
- const replacement = replacements[type](size && parseInt(size.slice(1)));
14295
- if (isPathFragment(replacement))
14296
- return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
14297
- return replacement;
14298
- });
14299
- }
14300
- function makeUnique(name, existingNames) {
14301
- const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
14302
- if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
14303
- return name;
14304
- const ext = node_path.extname(name);
14305
- name = name.substring(0, name.length - ext.length);
14306
- let uniqueName, uniqueIndex = 1;
14307
- while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
14308
- ;
14309
- return uniqueName;
14310
- }
14311
-
14312
- function generateAssetFileName(name, source, outputOptions, bundle) {
14313
- const emittedName = outputOptions.sanitizeFileName(name || 'asset');
14314
- return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
14315
- ? outputOptions.assetFileNames({ name, source, type: 'asset' })
14316
- : outputOptions.assetFileNames, 'output.assetFileNames', {
14317
- ext: () => node_path.extname(emittedName).substring(1),
14318
- extname: () => node_path.extname(emittedName),
14319
- hash: size => createHash()
14320
- .update(source)
14321
- .digest('hex')
14322
- .substring(0, size || defaultHashSize),
14323
- name: () => emittedName.substring(0, emittedName.length - node_path.extname(emittedName).length)
14324
- }), bundle);
14325
- }
14326
- function reserveFileNameInBundle(fileName, bundle, warn) {
14327
- if (fileName in bundle) {
14328
- warn(errFileNameConflict(fileName));
14329
14427
  }
14330
- bundle[fileName] = FILE_PLACEHOLDER;
14331
- }
14332
- const FILE_PLACEHOLDER = {
14333
- type: 'placeholder'
14334
- };
14335
- function hasValidType(emittedFile) {
14336
- return Boolean(emittedFile &&
14337
- (emittedFile.type === 'asset' ||
14338
- emittedFile.type === 'chunk'));
14339
- }
14340
- function hasValidName(emittedFile) {
14341
- const validatedName = emittedFile.fileName || emittedFile.name;
14342
- return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
14343
- }
14344
- function getValidSource(source, emittedFile, fileReferenceId) {
14345
- if (!(typeof source === 'string' || source instanceof Uint8Array)) {
14346
- const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
14347
- return error(errFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
14428
+ for (const variable of syntheticExports) {
14429
+ variable.setRenderNames(null, getSafeName(variable.name, usedNames));
14348
14430
  }
14349
- return source;
14350
14431
  }
14351
- function getAssetFileName(file, referenceId) {
14352
- if (typeof file.fileName !== 'string') {
14353
- return error(errAssetNotFinalisedForFileName(file.name || referenceId));
14432
+ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
14433
+ for (const chunk of dependencies) {
14434
+ chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
14354
14435
  }
14355
- return file.fileName;
14356
- }
14357
- function getChunkFileName(file, facadeChunkByModule) {
14358
- if (file.fileName) {
14359
- return file.fileName;
14436
+ for (const chunk of deconflictedNamespace) {
14437
+ chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
14360
14438
  }
14361
- if (facadeChunkByModule) {
14362
- const chunk = facadeChunkByModule.get(file.module);
14363
- return chunk.id || chunk.getFileName();
14364
- }
14365
- return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
14366
- }
14367
- class FileEmitter {
14368
- constructor(graph, options, baseFileEmitter) {
14369
- this.graph = graph;
14370
- this.options = options;
14371
- this.bundle = null;
14372
- this.facadeChunkByModule = null;
14373
- this.outputOptions = null;
14374
- this.emitFile = (emittedFile) => {
14375
- if (!hasValidType(emittedFile)) {
14376
- return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
14377
- }
14378
- if (!hasValidName(emittedFile)) {
14379
- return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
14380
- }
14381
- if (emittedFile.type === 'chunk') {
14382
- return this.emitChunk(emittedFile);
14383
- }
14384
- return this.emitAsset(emittedFile);
14385
- };
14386
- this.finaliseAssets = () => {
14387
- for (const [referenceId, emittedFile] of this.filesByReferenceId) {
14388
- if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
14389
- return error(errNoAssetSourceSet(emittedFile.name || referenceId));
14390
- }
14391
- };
14392
- this.getFileName = (fileReferenceId) => {
14393
- const emittedFile = this.filesByReferenceId.get(fileReferenceId);
14394
- if (!emittedFile)
14395
- return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
14396
- if (emittedFile.type === 'chunk') {
14397
- return getChunkFileName(emittedFile, this.facadeChunkByModule);
14398
- }
14399
- return getAssetFileName(emittedFile, fileReferenceId);
14400
- };
14401
- this.setAssetSource = (referenceId, requestedSource) => {
14402
- const consumedFile = this.filesByReferenceId.get(referenceId);
14403
- if (!consumedFile)
14404
- return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
14405
- if (consumedFile.type !== 'asset') {
14406
- return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
14407
- }
14408
- if (consumedFile.source !== undefined) {
14409
- return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
14410
- }
14411
- const source = getValidSource(requestedSource, consumedFile, referenceId);
14412
- if (this.bundle) {
14413
- this.finalizeAsset(consumedFile, source, referenceId, this.bundle);
14414
- }
14415
- else {
14416
- consumedFile.source = source;
14417
- }
14418
- };
14419
- this.setChunkInformation = (facadeChunkByModule) => {
14420
- this.facadeChunkByModule = facadeChunkByModule;
14421
- };
14422
- this.setOutputBundle = (outputBundle, outputOptions) => {
14423
- this.outputOptions = outputOptions;
14424
- this.bundle = outputBundle;
14425
- for (const emittedFile of this.filesByReferenceId.values()) {
14426
- if (emittedFile.fileName) {
14427
- reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
14428
- }
14429
- }
14430
- for (const [referenceId, consumedFile] of this.filesByReferenceId) {
14431
- if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
14432
- this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
14433
- }
14434
- }
14435
- };
14436
- this.filesByReferenceId = baseFileEmitter
14437
- ? new Map(baseFileEmitter.filesByReferenceId)
14438
- : new Map();
14439
- }
14440
- assignReferenceId(file, idBase) {
14441
- let referenceId;
14442
- do {
14443
- referenceId = createHash()
14444
- .update(referenceId || idBase)
14445
- .digest('hex')
14446
- .substring(0, 8);
14447
- } while (this.filesByReferenceId.has(referenceId));
14448
- this.filesByReferenceId.set(referenceId, file);
14449
- return referenceId;
14450
- }
14451
- emitAsset(emittedAsset) {
14452
- const source = typeof emittedAsset.source !== 'undefined'
14453
- ? getValidSource(emittedAsset.source, emittedAsset, null)
14454
- : undefined;
14455
- const consumedAsset = {
14456
- fileName: emittedAsset.fileName,
14457
- name: emittedAsset.name,
14458
- source,
14459
- type: 'asset'
14460
- };
14461
- const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || emittedAsset.type);
14462
- if (this.bundle) {
14463
- if (emittedAsset.fileName) {
14464
- reserveFileNameInBundle(emittedAsset.fileName, this.bundle, this.options.onwarn);
14465
- }
14466
- if (source !== undefined) {
14467
- this.finalizeAsset(consumedAsset, source, referenceId, this.bundle);
14468
- }
14469
- }
14470
- return referenceId;
14471
- }
14472
- emitChunk(emittedChunk) {
14473
- if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
14474
- return error(errInvalidRollupPhaseForChunkEmission());
14475
- }
14476
- if (typeof emittedChunk.id !== 'string') {
14477
- return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
14478
- }
14479
- const consumedChunk = {
14480
- fileName: emittedChunk.fileName,
14481
- module: null,
14482
- name: emittedChunk.name || emittedChunk.id,
14483
- type: 'chunk'
14484
- };
14485
- this.graph.moduleLoader
14486
- .emitChunk(emittedChunk)
14487
- .then(module => (consumedChunk.module = module))
14488
- .catch(() => {
14489
- // Avoid unhandled Promise rejection as the error will be thrown later
14490
- // once module loading has finished
14491
- });
14492
- return this.assignReferenceId(consumedChunk, emittedChunk.id);
14493
- }
14494
- finalizeAsset(consumedFile, source, referenceId, bundle) {
14495
- const fileName = consumedFile.fileName ||
14496
- findExistingAssetFileNameWithSource(bundle, source) ||
14497
- generateAssetFileName(consumedFile.name, source, this.outputOptions, bundle);
14498
- // We must not modify the original assets to avoid interaction between outputs
14499
- const assetWithFileName = { ...consumedFile, fileName, source };
14500
- this.filesByReferenceId.set(referenceId, assetWithFileName);
14501
- bundle[fileName] = {
14502
- fileName,
14503
- name: consumedFile.name,
14504
- source,
14505
- type: 'asset'
14506
- };
14507
- }
14508
- }
14509
- function findExistingAssetFileNameWithSource(bundle, source) {
14510
- for (const [fileName, outputFile] of Object.entries(bundle)) {
14511
- if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source))
14512
- return fileName;
14513
- }
14514
- return null;
14515
- }
14516
- function areSourcesEqual(sourceA, sourceB) {
14517
- if (typeof sourceA === 'string') {
14518
- return sourceA === sourceB;
14519
- }
14520
- if (typeof sourceB === 'string') {
14521
- return false;
14522
- }
14523
- if ('equals' in sourceA) {
14524
- return sourceA.equals(sourceB);
14525
- }
14526
- if (sourceA.length !== sourceB.length) {
14527
- return false;
14528
- }
14529
- for (let index = 0; index < sourceA.length; index++) {
14530
- if (sourceA[index] !== sourceB[index]) {
14531
- return false;
14532
- }
14533
- }
14534
- return true;
14535
- }
14536
-
14537
- const concatSep = (out, next) => (next ? `${out}\n${next}` : out);
14538
- const concatDblSep = (out, next) => (next ? `${out}\n\n${next}` : out);
14539
- async function createAddons(options, outputPluginDriver, chunk) {
14540
- try {
14541
- let [banner, footer, intro, outro] = await Promise.all([
14542
- outputPluginDriver.hookReduceValue('banner', options.banner(chunk), [chunk], concatSep),
14543
- outputPluginDriver.hookReduceValue('footer', options.footer(chunk), [chunk], concatSep),
14544
- outputPluginDriver.hookReduceValue('intro', options.intro(chunk), [chunk], concatDblSep),
14545
- outputPluginDriver.hookReduceValue('outro', options.outro(chunk), [chunk], concatDblSep)
14546
- ]);
14547
- if (intro)
14548
- intro += '\n\n';
14549
- if (outro)
14550
- outro = `\n\n${outro}`;
14551
- if (banner)
14552
- banner += '\n';
14553
- if (footer)
14554
- footer = '\n' + footer;
14555
- return { banner, footer, intro, outro };
14556
- }
14557
- catch (err) {
14558
- return error(errAddonNotGenerated(err.message, err.hook, err.plugin));
14559
- }
14560
- }
14561
-
14562
- const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT = {
14563
- amd: deconflictImportsOther,
14564
- cjs: deconflictImportsOther,
14565
- es: deconflictImportsEsmOrSystem,
14566
- iife: deconflictImportsOther,
14567
- system: deconflictImportsEsmOrSystem,
14568
- umd: deconflictImportsOther
14569
- };
14570
- function deconflictChunk(modules, dependenciesToBeDeconflicted, imports, usedNames, format, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports, exportNamesByVariable, accessedGlobalsByScope, includedNamespaces) {
14571
- const reversedModules = modules.slice().reverse();
14572
- for (const module of reversedModules) {
14573
- module.scope.addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope);
14574
- }
14575
- deconflictTopLevelVariables(usedNames, reversedModules, includedNamespaces);
14576
- DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](usedNames, imports, dependenciesToBeDeconflicted, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports);
14577
- for (const module of reversedModules) {
14578
- module.scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
14579
- }
14580
- }
14581
- function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconflicted, _interop, preserveModules, _externalLiveBindings, chunkByModule, externalChunkByModule, syntheticExports) {
14582
- // This is needed for namespace reexports
14583
- for (const dependency of dependenciesToBeDeconflicted.dependencies) {
14584
- if (preserveModules || dependency instanceof ExternalChunk) {
14585
- dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
14586
- }
14587
- }
14588
- for (const variable of imports) {
14589
- const module = variable.module;
14590
- const name = variable.name;
14591
- if (variable.isNamespace && (preserveModules || module instanceof ExternalModule)) {
14592
- variable.setRenderNames(null, (module instanceof ExternalModule
14593
- ? externalChunkByModule.get(module)
14594
- : chunkByModule.get(module)).variableName);
14595
- }
14596
- else if (module instanceof ExternalModule && name === 'default') {
14597
- variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
14598
- ? module.suggestedVariableName + '__default'
14599
- : module.suggestedVariableName, usedNames));
14600
- }
14601
- else {
14602
- variable.setRenderNames(null, getSafeName(name, usedNames));
14603
- }
14604
- }
14605
- for (const variable of syntheticExports) {
14606
- variable.setRenderNames(null, getSafeName(variable.name, usedNames));
14607
- }
14608
- }
14609
- function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
14610
- for (const chunk of dependencies) {
14611
- chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
14612
- }
14613
- for (const chunk of deconflictedNamespace) {
14614
- chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
14615
- }
14616
- for (const externalModule of deconflictedDefault) {
14617
- if (deconflictedNamespace.has(externalModule) &&
14618
- canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)) {
14619
- externalModule.defaultVariableName = externalModule.namespaceVariableName;
14620
- }
14621
- else {
14622
- externalModule.defaultVariableName = getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames);
14623
- }
14439
+ for (const externalModule of deconflictedDefault) {
14440
+ if (deconflictedNamespace.has(externalModule) &&
14441
+ canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)) {
14442
+ externalModule.defaultVariableName = externalModule.namespaceVariableName;
14443
+ }
14444
+ else {
14445
+ externalModule.defaultVariableName = getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames);
14446
+ }
14624
14447
  }
14625
14448
  for (const variable of imports) {
14626
14449
  const module = variable.module;
@@ -14806,6 +14629,93 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
14806
14629
  }
14807
14630
  }
14808
14631
 
14632
+ // Four random characters from the private use area to minimize risk of conflicts
14633
+ const hashPlaceholderLeft = '!~{';
14634
+ const hashPlaceholderRight = '}~';
14635
+ const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
14636
+ // This is the size of a sha256
14637
+ const maxHashSize = 64;
14638
+ const defaultHashSize = 8;
14639
+ const getHashPlaceholderGenerator = () => {
14640
+ let nextIndex = 0;
14641
+ return (optionName, hashSize = defaultHashSize) => {
14642
+ if (hashSize > maxHashSize) {
14643
+ return error(errFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
14644
+ }
14645
+ const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
14646
+ if (placeholder.length > hashSize) {
14647
+ return error(errFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
14648
+ }
14649
+ return placeholder;
14650
+ };
14651
+ };
14652
+ const REPLACER_REGEX = new RegExp(`${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${maxHashSize - hashPlaceholderOverhead}}${hashPlaceholderRight}`, 'g');
14653
+ const replacePlaceholders = (code, hashesByPlaceholder) => code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder);
14654
+ const replaceSinglePlaceholder = (code, placeholder, value) => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match));
14655
+ const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = (code, placeholders) => {
14656
+ const containedPlaceholders = new Set();
14657
+ const transformedCode = code.replace(REPLACER_REGEX, placeholder => {
14658
+ if (placeholders.has(placeholder)) {
14659
+ containedPlaceholders.add(placeholder);
14660
+ return `${hashPlaceholderLeft}${'0'.repeat(placeholder.length - hashPlaceholderOverhead)}${hashPlaceholderRight}`;
14661
+ }
14662
+ return placeholder;
14663
+ });
14664
+ return { containedPlaceholders, transformedCode };
14665
+ };
14666
+
14667
+ const lowercaseBundleKeys = Symbol('bundleKeys');
14668
+ const FILE_PLACEHOLDER = {
14669
+ type: 'placeholder'
14670
+ };
14671
+ const getOutputBundle = (outputBundleBase) => {
14672
+ const reservedLowercaseBundleKeys = new Set();
14673
+ return new Proxy(outputBundleBase, {
14674
+ deleteProperty(target, key) {
14675
+ if (typeof key === 'string') {
14676
+ reservedLowercaseBundleKeys.delete(key.toLowerCase());
14677
+ }
14678
+ return Reflect.deleteProperty(target, key);
14679
+ },
14680
+ get(target, key) {
14681
+ if (key === lowercaseBundleKeys) {
14682
+ return reservedLowercaseBundleKeys;
14683
+ }
14684
+ return Reflect.get(target, key);
14685
+ },
14686
+ set(target, key, value) {
14687
+ if (typeof key === 'string') {
14688
+ reservedLowercaseBundleKeys.add(key.toLowerCase());
14689
+ }
14690
+ return Reflect.set(target, key, value);
14691
+ }
14692
+ });
14693
+ };
14694
+
14695
+ function renderNamePattern(pattern, patternName, replacements) {
14696
+ if (isPathFragment(pattern))
14697
+ return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
14698
+ return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
14699
+ if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
14700
+ return error(errFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
14701
+ }
14702
+ const replacement = replacements[type](size && parseInt(size.slice(1)));
14703
+ if (isPathFragment(replacement))
14704
+ return error(errFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
14705
+ return replacement;
14706
+ });
14707
+ }
14708
+ function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }) {
14709
+ if (!reservedLowercaseBundleKeys.has(name.toLowerCase()))
14710
+ return name;
14711
+ const ext = node_path.extname(name);
14712
+ name = name.substring(0, name.length - ext.length);
14713
+ let uniqueName, uniqueIndex = 1;
14714
+ while (reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
14715
+ ;
14716
+ return uniqueName;
14717
+ }
14718
+
14809
14719
  const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.cjs', '.cts'];
14810
14720
  function getGlobalName(chunk, globals, hasExports, warn) {
14811
14721
  const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
@@ -14952,7 +14862,6 @@ class Chunk {
14952
14862
  this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
14953
14863
  }
14954
14864
  generateFacades() {
14955
- var _a;
14956
14865
  const facades = [];
14957
14866
  const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]);
14958
14867
  const exposedVariables = new Set(this.dynamicEntryModules.map(({ namespace }) => namespace));
@@ -15009,7 +14918,7 @@ class Chunk {
15009
14918
  this.canModuleBeFacade(module, exposedVariables)) {
15010
14919
  this.strictFacade = true;
15011
14920
  }
15012
- else if (!((_a = this.facadeChunkByModule.get(module)) === null || _a === void 0 ? void 0 : _a.strictFacade)) {
14921
+ else if (!this.facadeChunkByModule.get(module)?.strictFacade) {
15013
14922
  this.includedNamespaces.add(module);
15014
14923
  this.exports.add(module.namespace);
15015
14924
  }
@@ -15038,22 +14947,18 @@ class Chunk {
15038
14947
  };
15039
14948
  }
15040
14949
  getChunkName() {
15041
- var _a;
15042
- return ((_a = this.name) !== null && _a !== void 0 ? _a : (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
14950
+ return (this.name ?? (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
15043
14951
  }
15044
14952
  getExportNames() {
15045
- var _a;
15046
- return ((_a = this.sortedExportNames) !== null && _a !== void 0 ? _a : (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
14953
+ return (this.sortedExportNames ?? (this.sortedExportNames = Array.from(this.exportsByName.keys()).sort()));
15047
14954
  }
15048
14955
  getFileName() {
15049
- var _a;
15050
- return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
14956
+ return this.preliminaryFileName?.fileName || this.getPreliminaryFileName().fileName;
15051
14957
  }
15052
14958
  getImportPath(importer) {
15053
14959
  return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
15054
14960
  }
15055
14961
  getPreliminaryFileName() {
15056
- var _a;
15057
14962
  if (this.preliminaryFileName) {
15058
14963
  return this.preliminaryFileName;
15059
14964
  }
@@ -15067,7 +14972,7 @@ class Chunk {
15067
14972
  fileName = this.fileName;
15068
14973
  }
15069
14974
  else {
15070
- const [pattern, patternName] = preserveModules || ((_a = this.facadeModule) === null || _a === void 0 ? void 0 : _a.isUserDefinedEntryPoint)
14975
+ const [pattern, patternName] = preserveModules || this.facadeModule?.isUserDefinedEntryPoint
15071
14976
  ? [entryFileNames, 'output.entryFileNames']
15072
14977
  : [chunkFileNames, 'output.chunkFileNames'];
15073
14978
  fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
@@ -15132,7 +15037,7 @@ class Chunk {
15132
15037
  let hasExports = renderedExports.length !== 0;
15133
15038
  let hasDefaultExport = false;
15134
15039
  for (const { reexports } of renderedDependencies) {
15135
- if (reexports === null || reexports === void 0 ? void 0 : reexports.length) {
15040
+ if (reexports?.length) {
15136
15041
  hasExports = true;
15137
15042
  if (reexports.some(reexport => reexport.reexported === 'default')) {
15138
15043
  hasDefaultExport = true;
@@ -15354,6 +15259,16 @@ class Chunk {
15354
15259
  .filter((resolution) => resolution !== this &&
15355
15260
  (resolution instanceof Chunk || resolution instanceof ExternalChunk));
15356
15261
  }
15262
+ getDynamicImportStringAndAssertions(resolution, fileName) {
15263
+ if (resolution instanceof ExternalModule) {
15264
+ const chunk = this.externalChunkByModule.get(resolution);
15265
+ return [`'${chunk.getImportPath(fileName)}'`, chunk.getImportAssertions(this.snippets)];
15266
+ }
15267
+ return [
15268
+ resolution || '',
15269
+ (this.outputOptions.format === 'es' && this.outputOptions.externalImportAssertions) || null
15270
+ ];
15271
+ }
15357
15272
  getFallbackChunkName() {
15358
15273
  if (this.manualChunkAlias) {
15359
15274
  return this.manualChunkAlias;
@@ -15431,7 +15346,7 @@ class Chunk {
15431
15346
  exports: this.getExportNames(),
15432
15347
  facadeModuleId: facadeModule && facadeModule.id,
15433
15348
  isDynamicEntry: this.dynamicEntryModules.length > 0,
15434
- isEntry: !!(facadeModule === null || facadeModule === void 0 ? void 0 : facadeModule.info.isEntry),
15349
+ isEntry: !!facadeModule?.info.isEntry,
15435
15350
  isImplicitEntry: this.implicitEntryModules.length > 0,
15436
15351
  moduleIds: this.orderedModules.map(({ id }) => id),
15437
15352
  name: this.getChunkName(),
@@ -15530,6 +15445,7 @@ class Chunk {
15530
15445
  const namedExportsMode = dep instanceof ExternalChunk || dep.exportMode !== 'default';
15531
15446
  const importPath = dep.getImportPath(fileName);
15532
15447
  renderedDependencies.set(dep, {
15448
+ assertions: dep instanceof ExternalChunk ? dep.getImportAssertions(this.snippets) : null,
15533
15449
  defaultVariableName: dep.defaultVariableName,
15534
15450
  globalName: dep instanceof ExternalChunk &&
15535
15451
  (this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
@@ -15613,8 +15529,7 @@ class Chunk {
15613
15529
  const { renderedExports, removedExports } = module.getRenderedExports();
15614
15530
  renderedModules[module.id] = {
15615
15531
  get code() {
15616
- var _a;
15617
- return (_a = source === null || source === void 0 ? void 0 : source.toString()) !== null && _a !== void 0 ? _a : null;
15532
+ return source?.toString() ?? null;
15618
15533
  },
15619
15534
  originalLength: module.originalCode.length,
15620
15535
  removedExports,
@@ -15642,14 +15557,13 @@ class Chunk {
15642
15557
  node.setInternalResolution(resolution.namespace);
15643
15558
  }
15644
15559
  else {
15645
- node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !(facadeChunk === null || facadeChunk === void 0 ? void 0 : facadeChunk.strictFacade) && chunk.exportNamesByVariable.get(resolution.namespace)[0]);
15560
+ node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)[0], null);
15646
15561
  }
15647
15562
  }
15648
15563
  else {
15649
15564
  const { resolution } = resolvedDynamicImport;
15650
- resolvedDynamicImport.node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolution instanceof ExternalModule
15651
- ? `'${this.externalChunkByModule.get(resolution).getImportPath(fileName)}'`
15652
- : resolution || '', false);
15565
+ const [resolutionString, assertions] = this.getDynamicImportStringAndAssertions(resolution, fileName);
15566
+ resolvedDynamicImport.node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, assertions);
15653
15567
  }
15654
15568
  }
15655
15569
  }
@@ -15758,12 +15672,10 @@ class Chunk {
15758
15672
  }
15759
15673
  }
15760
15674
  function getChunkNameFromModule(module) {
15761
- var _a;
15762
- return (_a = getPredefinedChunkNameFromModule(module)) !== null && _a !== void 0 ? _a : getAliasName(module.id);
15675
+ return getPredefinedChunkNameFromModule(module) ?? getAliasName(module.id);
15763
15676
  }
15764
15677
  function getPredefinedChunkNameFromModule(module) {
15765
- var _a, _b, _c;
15766
- return ((_b = (_a = module.chunkNames.find(({ isUserDefined }) => isUserDefined)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : (_c = module.chunkNames[0]) === null || _c === void 0 ? void 0 : _c.name);
15678
+ return (module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? module.chunkNames[0]?.name);
15767
15679
  }
15768
15680
  function getImportedBindingsPerDependency(renderedDependencies, resolveFileName) {
15769
15681
  const importedBindingsPerDependency = {};
@@ -16215,6 +16127,8 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
16215
16127
  return { version: 3, ...map };
16216
16128
  }
16217
16129
 
16130
+ const createHash = () => node_crypto.createHash('sha256');
16131
+
16218
16132
  function decodedSourcemap(map) {
16219
16133
  if (!map)
16220
16134
  return null;
@@ -16233,7 +16147,7 @@ function decodedSourcemap(map) {
16233
16147
  return { ...map, mappings };
16234
16148
  }
16235
16149
 
16236
- async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, onwarn) {
16150
+ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, onwarn) {
16237
16151
  timeStart('render chunks', 2);
16238
16152
  reserveEntryChunksInBundle(chunks);
16239
16153
  const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
@@ -16241,8 +16155,8 @@ async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, o
16241
16155
  timeStart('transform chunks', 2);
16242
16156
  const chunkGraph = getChunkGraph(chunks);
16243
16157
  const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
16244
- const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle);
16245
- addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
16158
+ const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
16159
+ addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
16246
16160
  timeEnd('transform chunks', 2);
16247
16161
  }
16248
16162
  function reserveEntryChunksInBundle(chunks) {
@@ -16357,7 +16271,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16357
16271
  renderedChunksByPlaceholder
16358
16272
  };
16359
16273
  }
16360
- function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle) {
16274
+ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle) {
16361
16275
  const hashesByPlaceholder = new Map();
16362
16276
  for (const [placeholder, { fileName }] of renderedChunksByPlaceholder) {
16363
16277
  let hash = createHash();
@@ -16380,13 +16294,13 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
16380
16294
  }
16381
16295
  finalHash = hash.digest('hex').slice(0, placeholder.length);
16382
16296
  finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
16383
- } while (outputBundle[finalFileName]);
16384
- outputBundle[finalFileName] = FILE_PLACEHOLDER;
16385
- hashesByPlaceholder.set(placeholder, finalHash.slice(0, placeholder.length));
16297
+ } while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
16298
+ bundle[finalFileName] = FILE_PLACEHOLDER;
16299
+ hashesByPlaceholder.set(placeholder, finalHash);
16386
16300
  }
16387
16301
  return hashesByPlaceholder;
16388
16302
  }
16389
- function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
16303
+ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
16390
16304
  for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
16391
16305
  let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
16392
16306
  const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
@@ -16394,7 +16308,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
16394
16308
  map.file = replacePlaceholders(map.file, hashesByPlaceholder);
16395
16309
  updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
16396
16310
  }
16397
- outputBundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
16311
+ bundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
16398
16312
  }
16399
16313
  for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
16400
16314
  let updatedCode = hashesByPlaceholder.size
@@ -16403,7 +16317,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, out
16403
16317
  if (map) {
16404
16318
  updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
16405
16319
  }
16406
- outputBundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
16320
+ bundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
16407
16321
  }
16408
16322
  }
16409
16323
  function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
@@ -16433,7 +16347,8 @@ class Bundle {
16433
16347
  }
16434
16348
  async generate(isWrite) {
16435
16349
  timeStart('GENERATE', 1);
16436
- const outputBundle = Object.create(null);
16350
+ const outputBundleBase = Object.create(null);
16351
+ const outputBundle = getOutputBundle(outputBundleBase);
16437
16352
  this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions);
16438
16353
  try {
16439
16354
  timeStart('initialize render', 2);
@@ -16465,7 +16380,7 @@ class Bundle {
16465
16380
  this.finaliseAssets(outputBundle);
16466
16381
  timeEnd('generate bundle', 2);
16467
16382
  timeEnd('GENERATE', 1);
16468
- return outputBundle;
16383
+ return outputBundleBase;
16469
16384
  }
16470
16385
  async addManualChunks(manualChunks) {
16471
16386
  const manualChunkAliasByEntry = new Map();
@@ -16501,17 +16416,19 @@ class Bundle {
16501
16416
  }
16502
16417
  return manualChunkAliasByEntry;
16503
16418
  }
16504
- finaliseAssets(outputBundle) {
16505
- for (const file of Object.values(outputBundle)) {
16506
- if (this.outputOptions.validate && 'code' in file) {
16507
- try {
16508
- this.graph.contextParse(file.code, {
16509
- allowHashBang: true,
16510
- ecmaVersion: 'latest'
16511
- });
16512
- }
16513
- catch (err) {
16514
- this.inputOptions.onwarn(errChunkInvalid(file, err));
16419
+ finaliseAssets(bundle) {
16420
+ if (this.outputOptions.validate) {
16421
+ for (const file of Object.values(bundle)) {
16422
+ if ('code' in file) {
16423
+ try {
16424
+ this.graph.contextParse(file.code, {
16425
+ allowHashBang: true,
16426
+ ecmaVersion: 'latest'
16427
+ });
16428
+ }
16429
+ catch (err) {
16430
+ this.inputOptions.onwarn(errChunkInvalid(file, err));
16431
+ }
16515
16432
  }
16516
16433
  }
16517
16434
  }
@@ -17644,7 +17561,7 @@ pp$8.parseForStatement = function(node) {
17644
17561
 
17645
17562
  pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
17646
17563
  this.next();
17647
- return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
17564
+ return this.parseFunction(node, FUNC_STATEMENT$1 | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
17648
17565
  };
17649
17566
 
17650
17567
  pp$8.parseIfStatement = function(node) {
@@ -17908,7 +17825,7 @@ pp$8.parseVarId = function(decl, kind) {
17908
17825
  this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
17909
17826
  };
17910
17827
 
17911
- var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
17828
+ var FUNC_STATEMENT$1 = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID$1 = 4;
17912
17829
 
17913
17830
  // Parse a function declaration or literal (depending on the
17914
17831
  // `statement & FUNC_STATEMENT`).
@@ -17924,8 +17841,8 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
17924
17841
  if (this.options.ecmaVersion >= 8)
17925
17842
  { node.async = !!isAsync; }
17926
17843
 
17927
- if (statement & FUNC_STATEMENT) {
17928
- node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
17844
+ if (statement & FUNC_STATEMENT$1) {
17845
+ node.id = (statement & FUNC_NULLABLE_ID$1) && this.type !== types$1.name ? null : this.parseIdent();
17929
17846
  if (node.id && !(statement & FUNC_HANGING_STATEMENT))
17930
17847
  // If it is a regular function declaration in sloppy mode, then it is
17931
17848
  // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
@@ -17940,7 +17857,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
17940
17857
  this.awaitIdentPos = 0;
17941
17858
  this.enterScope(functionFlags(node.async, node.generator));
17942
17859
 
17943
- if (!(statement & FUNC_STATEMENT))
17860
+ if (!(statement & FUNC_STATEMENT$1))
17944
17861
  { node.id = this.type === types$1.name ? this.parseIdent() : null; }
17945
17862
 
17946
17863
  this.parseFunctionParams(node);
@@ -17949,7 +17866,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
17949
17866
  this.yieldPos = oldYieldPos;
17950
17867
  this.awaitPos = oldAwaitPos;
17951
17868
  this.awaitIdentPos = oldAwaitIdentPos;
17952
- return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
17869
+ return this.finishNode(node, (statement & FUNC_STATEMENT$1) ? "FunctionDeclaration" : "FunctionExpression")
17953
17870
  };
17954
17871
 
17955
17872
  pp$8.parseFunctionParams = function(node) {
@@ -18255,7 +18172,7 @@ pp$8.parseExport = function(node, exports) {
18255
18172
  var fNode = this.startNode();
18256
18173
  this.next();
18257
18174
  if (isAsync) { this.next(); }
18258
- node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
18175
+ node.declaration = this.parseFunction(fNode, FUNC_STATEMENT$1 | FUNC_NULLABLE_ID$1, false, isAsync);
18259
18176
  } else if (this.type === types$1._class) {
18260
18177
  var cNode = this.startNode();
18261
18178
  node.declaration = this.parseClass(cNode, "nullableID");
@@ -22140,7 +22057,59 @@ Parser.acorn = {
22140
22057
  nonASCIIwhitespace: nonASCIIwhitespace
22141
22058
  };
22142
22059
 
22143
- function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry) {
22060
+ // The main exported interface (under `self.acorn` when in the
22061
+ // browser) is a `parse` function that takes a code string and
22062
+ // returns an abstract syntax tree as specified by [Mozilla parser
22063
+ // API][api].
22064
+ //
22065
+ // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
22066
+
22067
+ function parse(input, options) {
22068
+ return Parser.parse(input, options)
22069
+ }
22070
+
22071
+ // This function tries to parse a single expression at a given
22072
+ // offset in a string. Useful for parsing mixed-language formats
22073
+ // that embed JavaScript expressions.
22074
+
22075
+ function parseExpressionAt(input, pos, options) {
22076
+ return Parser.parseExpressionAt(input, pos, options)
22077
+ }
22078
+
22079
+ // Acorn is organized as a tokenizer and a recursive-descent parser.
22080
+ // The `tokenizer` export provides an interface to the tokenizer.
22081
+
22082
+ function tokenizer(input, options) {
22083
+ return Parser.tokenizer(input, options)
22084
+ }
22085
+
22086
+ const acorn = /*#__PURE__*/Object.defineProperty({
22087
+ __proto__: null,
22088
+ Node,
22089
+ Parser,
22090
+ Position,
22091
+ SourceLocation,
22092
+ TokContext,
22093
+ Token,
22094
+ TokenType,
22095
+ defaultOptions,
22096
+ getLineInfo,
22097
+ isIdentifierChar,
22098
+ isIdentifierStart,
22099
+ isNewLine,
22100
+ keywordTypes: keywords,
22101
+ lineBreak,
22102
+ lineBreakG,
22103
+ nonASCIIwhitespace,
22104
+ parse,
22105
+ parseExpressionAt,
22106
+ tokContexts: types,
22107
+ tokTypes: types$1,
22108
+ tokenizer,
22109
+ version
22110
+ }, Symbol.toStringTag, { value: 'Module' });
22111
+
22112
+ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
22144
22113
  let skipped = null;
22145
22114
  let replaceContext = null;
22146
22115
  if (skip) {
@@ -22152,16 +22121,16 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
22152
22121
  }
22153
22122
  replaceContext = (pluginContext, plugin) => ({
22154
22123
  ...pluginContext,
22155
- resolve: (source, importer, { custom, isEntry, skipSelf } = BLANK) => {
22156
- return moduleLoaderResolveId(source, importer, custom, isEntry, skipSelf ? [...skip, { importer, plugin, source }] : skip);
22124
+ resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
22125
+ return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
22157
22126
  }
22158
22127
  });
22159
22128
  }
22160
- return pluginDriver.hookFirst('resolveId', [source, importer, { custom: customOptions, isEntry }], replaceContext, skipped);
22129
+ return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
22161
22130
  }
22162
22131
 
22163
- async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry) {
22164
- const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry);
22132
+ async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
22133
+ const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions);
22165
22134
  if (pluginResult != null)
22166
22135
  return pluginResult;
22167
22136
  // external modules (non-entry modules that start with neither '.' or '/')
@@ -22175,8 +22144,9 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
22175
22144
  return addJsExtensionIfNecessary(importer ? node_path.resolve(node_path.dirname(importer), source) : node_path.resolve(source), preserveSymlinks);
22176
22145
  }
22177
22146
  async function addJsExtensionIfNecessary(file, preserveSymlinks) {
22178
- var _a, _b;
22179
- return ((_b = (_a = (await findFile(file, preserveSymlinks))) !== null && _a !== void 0 ? _a : (await findFile(file + '.mjs', preserveSymlinks))) !== null && _b !== void 0 ? _b : (await findFile(file + '.js', preserveSymlinks)));
22147
+ return ((await findFile(file, preserveSymlinks)) ??
22148
+ (await findFile(file + '.mjs', preserveSymlinks)) ??
22149
+ (await findFile(file + '.js', preserveSymlinks)));
22180
22150
  }
22181
22151
  async function findFile(file, preserveSymlinks) {
22182
22152
  try {
@@ -22410,11 +22380,9 @@ class ModuleLoader {
22410
22380
  this.modulesWithLoadedDependencies = new Set();
22411
22381
  this.nextChunkNamePriority = 0;
22412
22382
  this.nextEntryModuleIndex = 0;
22413
- this.resolveId = async (source, importer, customOptions, isEntry, skip = null) => {
22414
- return this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
22415
- ? false
22416
- : await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer), importer, source));
22417
- };
22383
+ this.resolveId = async (source, importer, customOptions, isEntry, assertions, skip = null) => this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
22384
+ ? false
22385
+ : await resolveId(source, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, skip, customOptions, typeof isEntry === 'boolean' ? isEntry : !importer, assertions), importer, source), assertions);
22418
22386
  this.hasModuleSideEffects = options.treeshake
22419
22387
  ? options.treeshake.moduleSideEffects
22420
22388
  : () => true;
@@ -22472,7 +22440,7 @@ class ModuleLoader {
22472
22440
  return module;
22473
22441
  }
22474
22442
  async preloadModule(resolvedId) {
22475
- const module = await this.fetchModule(this.getResolvedIdWithDefaults(resolvedId), undefined, false, resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true);
22443
+ const module = await this.fetchModule(this.getResolvedIdWithDefaults(resolvedId, EMPTY_OBJECT), undefined, false, resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true);
22476
22444
  return module.info;
22477
22445
  }
22478
22446
  addEntryWithImplicitDependants(unresolvedModule, implicitlyLoadedAfter) {
@@ -22495,7 +22463,7 @@ class ModuleLoader {
22495
22463
  async addModuleSource(id, importer, module) {
22496
22464
  let source;
22497
22465
  try {
22498
- source = await this.graph.fileOperationQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await node_fs.promises.readFile(id, 'utf8')); });
22466
+ source = await this.graph.fileOperationQueue.run(async () => (await this.pluginDriver.hookFirst('load', [id])) ?? (await node_fs.promises.readFile(id, 'utf8')));
22499
22467
  }
22500
22468
  catch (err) {
22501
22469
  let msg = `Could not load ${id}`;
@@ -22570,16 +22538,21 @@ class ModuleLoader {
22570
22538
  }
22571
22539
  }
22572
22540
  }
22573
- // If this is a preload, then this method always waits for the dependencies of the module to be resolved.
22574
- // Otherwise if the module does not exist, it waits for the module and all its dependencies to be loaded.
22575
- // Otherwise it returns immediately.
22576
- async fetchModule({ id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry, isPreload) {
22541
+ // If this is a preload, then this method always waits for the dependencies of
22542
+ // the module to be resolved.
22543
+ // Otherwise, if the module does not exist, it waits for the module and all
22544
+ // its dependencies to be loaded.
22545
+ // Otherwise, it returns immediately.
22546
+ async fetchModule({ assertions, id, meta, moduleSideEffects, syntheticNamedExports }, importer, isEntry, isPreload) {
22577
22547
  const existingModule = this.modulesById.get(id);
22578
22548
  if (existingModule instanceof Module) {
22549
+ if (importer && doAssertionsDiffer(assertions, existingModule.info.assertions)) {
22550
+ this.options.onwarn(errInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
22551
+ }
22579
22552
  await this.handleExistingModule(existingModule, isEntry, isPreload);
22580
22553
  return existingModule;
22581
22554
  }
22582
- const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta);
22555
+ const module = new Module(this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, meta, assertions);
22583
22556
  this.modulesById.set(id, module);
22584
22557
  this.graph.watchFiles[id] = true;
22585
22558
  const loadPromise = this.addModuleSource(id, importer, module).then(() => [
@@ -22616,14 +22589,18 @@ class ModuleLoader {
22616
22589
  }
22617
22590
  fetchResolvedDependency(source, importer, resolvedId) {
22618
22591
  if (resolvedId.external) {
22619
- const { external, id, moduleSideEffects, meta } = resolvedId;
22620
- if (!this.modulesById.has(id)) {
22621
- this.modulesById.set(id, new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id)));
22592
+ const { assertions, external, id, moduleSideEffects, meta } = resolvedId;
22593
+ let externalModule = this.modulesById.get(id);
22594
+ if (!externalModule) {
22595
+ externalModule = new ExternalModule(this.options, id, moduleSideEffects, meta, external !== 'absolute' && isAbsolute(id), assertions);
22596
+ this.modulesById.set(id, externalModule);
22622
22597
  }
22623
- const externalModule = this.modulesById.get(id);
22624
- if (!(externalModule instanceof ExternalModule)) {
22598
+ else if (!(externalModule instanceof ExternalModule)) {
22625
22599
  return error(errInternalIdCannotBeExternal(source, importer));
22626
22600
  }
22601
+ else if (doAssertionsDiffer(externalModule.info.assertions, assertions)) {
22602
+ this.options.onwarn(errInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
22603
+ }
22627
22604
  return Promise.resolve(externalModule);
22628
22605
  }
22629
22606
  return this.fetchModule(resolvedId, importer, false, false);
@@ -22681,7 +22658,7 @@ class ModuleLoader {
22681
22658
  return module.dynamicImports.map(async (dynamicImport) => {
22682
22659
  const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
22683
22660
  ? dynamicImport.argument
22684
- : dynamicImport.argument.esTreeNode, module.id);
22661
+ : dynamicImport.argument.esTreeNode, module.id, getAssertionsFromImportExpression(dynamicImport.node));
22685
22662
  if (resolvedId && typeof resolvedId === 'object') {
22686
22663
  dynamicImport.id = resolvedId.id;
22687
22664
  }
@@ -22689,149 +22666,354 @@ class ModuleLoader {
22689
22666
  });
22690
22667
  }
22691
22668
  getResolveStaticDependencyPromises(module) {
22692
- return Array.from(module.sources, async (source) => [
22669
+ return Array.from(module.sourcesWithAssertions, async ([source, assertions]) => [
22693
22670
  source,
22694
22671
  (module.resolvedIds[source] =
22695
22672
  module.resolvedIds[source] ||
22696
- this.handleResolveId(await this.resolveId(source, module.id, EMPTY_OBJECT, false), source, module.id))
22673
+ this.handleInvalidResolvedId(await this.resolveId(source, module.id, EMPTY_OBJECT, false, assertions), source, module.id, assertions))
22697
22674
  ]);
22698
22675
  }
22699
- getResolvedIdWithDefaults(resolvedId) {
22700
- var _a, _b;
22676
+ getResolvedIdWithDefaults(resolvedId, assertions) {
22701
22677
  if (!resolvedId) {
22702
22678
  return null;
22703
22679
  }
22704
22680
  const external = resolvedId.external || false;
22705
22681
  return {
22682
+ assertions: resolvedId.assertions || assertions,
22706
22683
  external,
22707
22684
  id: resolvedId.id,
22708
22685
  meta: resolvedId.meta || {},
22709
- moduleSideEffects: (_a = resolvedId.moduleSideEffects) !== null && _a !== void 0 ? _a : this.hasModuleSideEffects(resolvedId.id, !!external),
22710
- syntheticNamedExports: (_b = resolvedId.syntheticNamedExports) !== null && _b !== void 0 ? _b : false
22686
+ moduleSideEffects: resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external),
22687
+ syntheticNamedExports: resolvedId.syntheticNamedExports ?? false
22688
+ };
22689
+ }
22690
+ async handleExistingModule(module, isEntry, isPreload) {
22691
+ const loadPromise = this.moduleLoadPromises.get(module);
22692
+ if (isPreload) {
22693
+ return isPreload === RESOLVE_DEPENDENCIES
22694
+ ? waitForDependencyResolution(loadPromise)
22695
+ : loadPromise;
22696
+ }
22697
+ if (isEntry) {
22698
+ module.info.isEntry = true;
22699
+ this.implicitEntryModules.delete(module);
22700
+ for (const dependant of module.implicitlyLoadedAfter) {
22701
+ dependant.implicitlyLoadedBefore.delete(module);
22702
+ }
22703
+ module.implicitlyLoadedAfter.clear();
22704
+ }
22705
+ return this.fetchModuleDependencies(module, ...(await loadPromise));
22706
+ }
22707
+ handleInvalidResolvedId(resolvedId, source, importer, assertions) {
22708
+ if (resolvedId === null) {
22709
+ if (isRelative(source)) {
22710
+ return error(errUnresolvedImport(source, importer));
22711
+ }
22712
+ this.options.onwarn(errUnresolvedImportTreatedAsExternal(source, importer));
22713
+ return {
22714
+ assertions,
22715
+ external: true,
22716
+ id: source,
22717
+ meta: {},
22718
+ moduleSideEffects: this.hasModuleSideEffects(source, true),
22719
+ syntheticNamedExports: false
22720
+ };
22721
+ }
22722
+ else if (resolvedId.external && resolvedId.syntheticNamedExports) {
22723
+ this.options.onwarn(errExternalSyntheticExports(source, importer));
22724
+ }
22725
+ return resolvedId;
22726
+ }
22727
+ async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore) {
22728
+ const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT);
22729
+ if (resolveIdResult == null) {
22730
+ return error(implicitlyLoadedBefore === null
22731
+ ? errUnresolvedEntry(unresolvedId)
22732
+ : errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
22733
+ }
22734
+ if (resolveIdResult === false ||
22735
+ (typeof resolveIdResult === 'object' && resolveIdResult.external)) {
22736
+ return error(implicitlyLoadedBefore === null
22737
+ ? errEntryCannotBeExternal(unresolvedId)
22738
+ : errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
22739
+ }
22740
+ return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
22741
+ ? resolveIdResult
22742
+ : { id: resolveIdResult }, EMPTY_OBJECT), undefined, isEntry, false);
22743
+ }
22744
+ async resolveDynamicImport(module, specifier, importer, assertions) {
22745
+ const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
22746
+ specifier,
22747
+ importer,
22748
+ { assertions }
22749
+ ]);
22750
+ if (typeof specifier !== 'string') {
22751
+ if (typeof resolution === 'string') {
22752
+ return resolution;
22753
+ }
22754
+ if (!resolution) {
22755
+ return null;
22756
+ }
22757
+ return this.getResolvedIdWithDefaults(resolution, assertions);
22758
+ }
22759
+ if (resolution == null) {
22760
+ const existingResolution = module.resolvedIds[specifier];
22761
+ if (existingResolution) {
22762
+ if (doAssertionsDiffer(existingResolution.assertions, assertions)) {
22763
+ this.options.onwarn(errInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
22764
+ }
22765
+ return existingResolution;
22766
+ }
22767
+ return (module.resolvedIds[specifier] = this.handleInvalidResolvedId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, assertions), specifier, module.id, assertions));
22768
+ }
22769
+ return this.handleInvalidResolvedId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), assertions), specifier, importer, assertions);
22770
+ }
22771
+ }
22772
+ function normalizeRelativeExternalId(source, importer) {
22773
+ return isRelative(source)
22774
+ ? importer
22775
+ ? node_path.resolve(importer, '..', source)
22776
+ : node_path.resolve(source)
22777
+ : source;
22778
+ }
22779
+ function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
22780
+ if (fileName !== null) {
22781
+ module.chunkFileNames.add(fileName);
22782
+ }
22783
+ else if (name !== null) {
22784
+ // Always keep chunkNames sorted by priority
22785
+ let namePosition = 0;
22786
+ while (module.chunkNames[namePosition]?.priority < priority)
22787
+ namePosition++;
22788
+ module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority });
22789
+ }
22790
+ }
22791
+ function isNotAbsoluteExternal(id, source, makeAbsoluteExternalsRelative) {
22792
+ return (makeAbsoluteExternalsRelative === true ||
22793
+ (makeAbsoluteExternalsRelative === 'ifRelativeSource' && isRelative(source)) ||
22794
+ !isAbsolute(id));
22795
+ }
22796
+ async function waitForDependencyResolution(loadPromise) {
22797
+ const [resolveStaticDependencyPromises, resolveDynamicImportPromises] = await loadPromise;
22798
+ return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]);
22799
+ }
22800
+
22801
+ class GlobalScope extends Scope$1 {
22802
+ constructor() {
22803
+ super();
22804
+ this.parent = null;
22805
+ this.variables.set('undefined', new UndefinedVariable());
22806
+ }
22807
+ findVariable(name) {
22808
+ let variable = this.variables.get(name);
22809
+ if (!variable) {
22810
+ variable = new GlobalVariable(name);
22811
+ this.variables.set(name, variable);
22812
+ }
22813
+ return variable;
22814
+ }
22815
+ }
22816
+
22817
+ function generateAssetFileName(name, source, outputOptions, bundle) {
22818
+ const emittedName = outputOptions.sanitizeFileName(name || 'asset');
22819
+ return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
22820
+ ? outputOptions.assetFileNames({ name, source, type: 'asset' })
22821
+ : outputOptions.assetFileNames, 'output.assetFileNames', {
22822
+ ext: () => node_path.extname(emittedName).substring(1),
22823
+ extname: () => node_path.extname(emittedName),
22824
+ hash: size => createHash()
22825
+ .update(source)
22826
+ .digest('hex')
22827
+ .substring(0, size || defaultHashSize),
22828
+ name: () => emittedName.substring(0, emittedName.length - node_path.extname(emittedName).length)
22829
+ }), bundle);
22830
+ }
22831
+ function reserveFileNameInBundle(fileName, { bundle }, warn) {
22832
+ if (bundle[lowercaseBundleKeys].has(fileName.toLowerCase())) {
22833
+ warn(errFileNameConflict(fileName));
22834
+ }
22835
+ else {
22836
+ bundle[fileName] = FILE_PLACEHOLDER;
22837
+ }
22838
+ }
22839
+ function hasValidType(emittedFile) {
22840
+ return Boolean(emittedFile &&
22841
+ (emittedFile.type === 'asset' ||
22842
+ emittedFile.type === 'chunk'));
22843
+ }
22844
+ function hasValidName(emittedFile) {
22845
+ const validatedName = emittedFile.fileName || emittedFile.name;
22846
+ return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName));
22847
+ }
22848
+ function getValidSource(source, emittedFile, fileReferenceId) {
22849
+ if (!(typeof source === 'string' || source instanceof Uint8Array)) {
22850
+ const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
22851
+ return error(errFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
22852
+ }
22853
+ return source;
22854
+ }
22855
+ function getAssetFileName(file, referenceId) {
22856
+ if (typeof file.fileName !== 'string') {
22857
+ return error(errAssetNotFinalisedForFileName(file.name || referenceId));
22858
+ }
22859
+ return file.fileName;
22860
+ }
22861
+ function getChunkFileName(file, facadeChunkByModule) {
22862
+ if (file.fileName) {
22863
+ return file.fileName;
22864
+ }
22865
+ if (facadeChunkByModule) {
22866
+ const chunk = facadeChunkByModule.get(file.module);
22867
+ return chunk.id || chunk.getFileName();
22868
+ }
22869
+ return error(errChunkNotGeneratedForFileName(file.fileName || file.name));
22870
+ }
22871
+ class FileEmitter {
22872
+ constructor(graph, options, baseFileEmitter) {
22873
+ this.graph = graph;
22874
+ this.options = options;
22875
+ this.facadeChunkByModule = null;
22876
+ this.nextIdBase = 1;
22877
+ this.output = null;
22878
+ this.emitFile = (emittedFile) => {
22879
+ if (!hasValidType(emittedFile)) {
22880
+ return error(errFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
22881
+ }
22882
+ if (!hasValidName(emittedFile)) {
22883
+ return error(errFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
22884
+ }
22885
+ if (emittedFile.type === 'chunk') {
22886
+ return this.emitChunk(emittedFile);
22887
+ }
22888
+ return this.emitAsset(emittedFile);
22889
+ };
22890
+ this.finaliseAssets = () => {
22891
+ for (const [referenceId, emittedFile] of this.filesByReferenceId) {
22892
+ if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
22893
+ return error(errNoAssetSourceSet(emittedFile.name || referenceId));
22894
+ }
22895
+ };
22896
+ this.getFileName = (fileReferenceId) => {
22897
+ const emittedFile = this.filesByReferenceId.get(fileReferenceId);
22898
+ if (!emittedFile)
22899
+ return error(errFileReferenceIdNotFoundForFilename(fileReferenceId));
22900
+ if (emittedFile.type === 'chunk') {
22901
+ return getChunkFileName(emittedFile, this.facadeChunkByModule);
22902
+ }
22903
+ return getAssetFileName(emittedFile, fileReferenceId);
22904
+ };
22905
+ this.setAssetSource = (referenceId, requestedSource) => {
22906
+ const consumedFile = this.filesByReferenceId.get(referenceId);
22907
+ if (!consumedFile)
22908
+ return error(errAssetReferenceIdNotFoundForSetSource(referenceId));
22909
+ if (consumedFile.type !== 'asset') {
22910
+ return error(errFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
22911
+ }
22912
+ if (consumedFile.source !== undefined) {
22913
+ return error(errAssetSourceAlreadySet(consumedFile.name || referenceId));
22914
+ }
22915
+ const source = getValidSource(requestedSource, consumedFile, referenceId);
22916
+ if (this.output) {
22917
+ this.finalizeAsset(consumedFile, source, referenceId, this.output);
22918
+ }
22919
+ else {
22920
+ consumedFile.source = source;
22921
+ }
22922
+ };
22923
+ this.setChunkInformation = (facadeChunkByModule) => {
22924
+ this.facadeChunkByModule = facadeChunkByModule;
22925
+ };
22926
+ this.setOutputBundle = (bundle, outputOptions) => {
22927
+ const fileNamesBySource = new Map();
22928
+ const output = (this.output = { bundle, fileNamesBySource, outputOptions });
22929
+ for (const emittedFile of this.filesByReferenceId.values()) {
22930
+ if (emittedFile.fileName) {
22931
+ reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
22932
+ if (emittedFile.type === 'asset' && typeof emittedFile.source === 'string') {
22933
+ fileNamesBySource.set(emittedFile.source, emittedFile.fileName);
22934
+ }
22935
+ }
22936
+ }
22937
+ for (const [referenceId, consumedFile] of this.filesByReferenceId) {
22938
+ if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
22939
+ this.finalizeAsset(consumedFile, consumedFile.source, referenceId, output);
22940
+ }
22941
+ }
22942
+ };
22943
+ this.filesByReferenceId = baseFileEmitter
22944
+ ? new Map(baseFileEmitter.filesByReferenceId)
22945
+ : new Map();
22946
+ }
22947
+ assignReferenceId(file, idBase) {
22948
+ let referenceId;
22949
+ do {
22950
+ referenceId = createHash()
22951
+ .update(referenceId || idBase)
22952
+ .digest('hex')
22953
+ .substring(0, 8);
22954
+ } while (this.filesByReferenceId.has(referenceId));
22955
+ this.filesByReferenceId.set(referenceId, file);
22956
+ return referenceId;
22957
+ }
22958
+ emitAsset(emittedAsset) {
22959
+ const source = typeof emittedAsset.source !== 'undefined'
22960
+ ? getValidSource(emittedAsset.source, emittedAsset, null)
22961
+ : undefined;
22962
+ const consumedAsset = {
22963
+ fileName: emittedAsset.fileName,
22964
+ name: emittedAsset.name,
22965
+ source,
22966
+ type: 'asset'
22711
22967
  };
22712
- }
22713
- async handleExistingModule(module, isEntry, isPreload) {
22714
- const loadPromise = this.moduleLoadPromises.get(module);
22715
- if (isPreload) {
22716
- return isPreload === RESOLVE_DEPENDENCIES
22717
- ? waitForDependencyResolution(loadPromise)
22718
- : loadPromise;
22719
- }
22720
- if (isEntry) {
22721
- module.info.isEntry = true;
22722
- this.implicitEntryModules.delete(module);
22723
- for (const dependant of module.implicitlyLoadedAfter) {
22724
- dependant.implicitlyLoadedBefore.delete(module);
22968
+ const referenceId = this.assignReferenceId(consumedAsset, emittedAsset.fileName || emittedAsset.name || String(this.nextIdBase++));
22969
+ if (this.output) {
22970
+ if (emittedAsset.fileName) {
22971
+ reserveFileNameInBundle(emittedAsset.fileName, this.output, this.options.onwarn);
22725
22972
  }
22726
- module.implicitlyLoadedAfter.clear();
22727
- }
22728
- return this.fetchModuleDependencies(module, ...(await loadPromise));
22729
- }
22730
- handleResolveId(resolvedId, source, importer) {
22731
- if (resolvedId === null) {
22732
- if (isRelative(source)) {
22733
- return error(errUnresolvedImport(source, importer));
22973
+ if (source !== undefined) {
22974
+ this.finalizeAsset(consumedAsset, source, referenceId, this.output);
22734
22975
  }
22735
- this.options.onwarn(errUnresolvedImportTreatedAsExternal(source, importer));
22736
- return {
22737
- external: true,
22738
- id: source,
22739
- meta: {},
22740
- moduleSideEffects: this.hasModuleSideEffects(source, true),
22741
- syntheticNamedExports: false
22742
- };
22743
- }
22744
- else if (resolvedId.external && resolvedId.syntheticNamedExports) {
22745
- this.options.onwarn(errExternalSyntheticExports(source, importer));
22746
- }
22747
- return resolvedId;
22748
- }
22749
- async loadEntryModule(unresolvedId, isEntry, importer, implicitlyLoadedBefore) {
22750
- const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true);
22751
- if (resolveIdResult == null) {
22752
- return error(implicitlyLoadedBefore === null
22753
- ? errUnresolvedEntry(unresolvedId)
22754
- : errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
22755
- }
22756
- if (resolveIdResult === false ||
22757
- (typeof resolveIdResult === 'object' && resolveIdResult.external)) {
22758
- return error(implicitlyLoadedBefore === null
22759
- ? errEntryCannotBeExternal(unresolvedId)
22760
- : errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
22761
22976
  }
22762
- return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
22763
- ? resolveIdResult
22764
- : { id: resolveIdResult }), undefined, isEntry, false);
22977
+ return referenceId;
22765
22978
  }
22766
- async resolveDynamicImport(module, specifier, importer) {
22767
- var _a;
22768
- var _b;
22769
- const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
22770
- specifier,
22771
- importer
22772
- ]);
22773
- if (typeof specifier !== 'string') {
22774
- if (typeof resolution === 'string') {
22775
- return resolution;
22776
- }
22777
- if (!resolution) {
22778
- return null;
22779
- }
22780
- return {
22781
- external: false,
22782
- moduleSideEffects: true,
22783
- ...resolution
22784
- };
22979
+ emitChunk(emittedChunk) {
22980
+ if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
22981
+ return error(errInvalidRollupPhaseForChunkEmission());
22785
22982
  }
22786
- if (resolution == null) {
22787
- return ((_a = (_b = module.resolvedIds)[specifier]) !== null && _a !== void 0 ? _a : (_b[specifier] = this.handleResolveId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false), specifier, module.id)));
22983
+ if (typeof emittedChunk.id !== 'string') {
22984
+ return error(errFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
22788
22985
  }
22789
- return this.handleResolveId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier)), specifier, importer);
22790
- }
22791
- }
22792
- function normalizeRelativeExternalId(source, importer) {
22793
- return isRelative(source)
22794
- ? importer
22795
- ? node_path.resolve(importer, '..', source)
22796
- : node_path.resolve(source)
22797
- : source;
22798
- }
22799
- function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
22800
- var _a;
22801
- if (fileName !== null) {
22802
- module.chunkFileNames.add(fileName);
22803
- }
22804
- else if (name !== null) {
22805
- // Always keep chunkNames sorted by priority
22806
- let namePosition = 0;
22807
- while (((_a = module.chunkNames[namePosition]) === null || _a === void 0 ? void 0 : _a.priority) < priority)
22808
- namePosition++;
22809
- module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority });
22810
- }
22811
- }
22812
- function isNotAbsoluteExternal(id, source, makeAbsoluteExternalsRelative) {
22813
- return (makeAbsoluteExternalsRelative === true ||
22814
- (makeAbsoluteExternalsRelative === 'ifRelativeSource' && isRelative(source)) ||
22815
- !isAbsolute(id));
22816
- }
22817
- async function waitForDependencyResolution(loadPromise) {
22818
- const [resolveStaticDependencyPromises, resolveDynamicImportPromises] = await loadPromise;
22819
- return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]);
22820
- }
22821
-
22822
- class GlobalScope extends Scope$1 {
22823
- constructor() {
22824
- super();
22825
- this.parent = null;
22826
- this.variables.set('undefined', new UndefinedVariable());
22986
+ const consumedChunk = {
22987
+ fileName: emittedChunk.fileName,
22988
+ module: null,
22989
+ name: emittedChunk.name || emittedChunk.id,
22990
+ type: 'chunk'
22991
+ };
22992
+ this.graph.moduleLoader
22993
+ .emitChunk(emittedChunk)
22994
+ .then(module => (consumedChunk.module = module))
22995
+ .catch(() => {
22996
+ // Avoid unhandled Promise rejection as the error will be thrown later
22997
+ // once module loading has finished
22998
+ });
22999
+ return this.assignReferenceId(consumedChunk, emittedChunk.id);
22827
23000
  }
22828
- findVariable(name) {
22829
- let variable = this.variables.get(name);
22830
- if (!variable) {
22831
- variable = new GlobalVariable(name);
22832
- this.variables.set(name, variable);
23001
+ finalizeAsset(consumedFile, source, referenceId, { bundle, fileNamesBySource, outputOptions }) {
23002
+ const fileName = consumedFile.fileName ||
23003
+ (typeof source === 'string' && fileNamesBySource.get(source)) ||
23004
+ generateAssetFileName(consumedFile.name, source, outputOptions, bundle);
23005
+ // We must not modify the original assets to avoid interaction between outputs
23006
+ const assetWithFileName = { ...consumedFile, fileName, source };
23007
+ this.filesByReferenceId.set(referenceId, assetWithFileName);
23008
+ if (typeof source === 'string') {
23009
+ fileNamesBySource.set(source, fileName);
22833
23010
  }
22834
- return variable;
23011
+ bundle[fileName] = {
23012
+ fileName,
23013
+ name: consumedFile.name,
23014
+ source,
23015
+ type: 'asset'
23016
+ };
22835
23017
  }
22836
23018
  }
22837
23019
 
@@ -22894,8 +23076,8 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
22894
23076
  return wrappedModuleIds();
22895
23077
  },
22896
23078
  parse: graph.contextParse.bind(graph),
22897
- resolve(source, importer, { custom, isEntry, skipSelf } = BLANK) {
22898
- return graph.moduleLoader.resolveId(source, importer, custom, isEntry, skipSelf ? [{ importer, plugin, source }] : null);
23079
+ resolve(source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) {
23080
+ return graph.moduleLoader.resolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
22899
23081
  },
22900
23082
  setAssetSource: fileEmitter.setAssetSource,
22901
23083
  warn(warning) {
@@ -23070,7 +23252,7 @@ class PluginDriver {
23070
23252
  }
23071
23253
  // eslint-disable-next-line @typescript-eslint/ban-types
23072
23254
  const hookResult = handler.apply(context, args);
23073
- if (!(hookResult === null || hookResult === void 0 ? void 0 : hookResult.then)) {
23255
+ if (!hookResult?.then) {
23074
23256
  // short circuit for non-thenables and non-Promises
23075
23257
  return hookResult;
23076
23258
  }
@@ -23210,7 +23392,6 @@ function normalizeEntryModules(entryModules) {
23210
23392
  }
23211
23393
  class Graph {
23212
23394
  constructor(options, watcher) {
23213
- var _a, _b;
23214
23395
  this.options = options;
23215
23396
  this.cachedModules = new Map();
23216
23397
  this.deoptimizationTracker = new PathTracker();
@@ -23231,11 +23412,11 @@ class Graph {
23231
23412
  return foundModule.info;
23232
23413
  };
23233
23414
  if (options.cache !== false) {
23234
- if ((_a = options.cache) === null || _a === void 0 ? void 0 : _a.modules) {
23415
+ if (options.cache?.modules) {
23235
23416
  for (const module of options.cache.modules)
23236
23417
  this.cachedModules.set(module.id, module);
23237
23418
  }
23238
- this.pluginCache = ((_b = options.cache) === null || _b === void 0 ? void 0 : _b.plugins) || Object.create(null);
23419
+ this.pluginCache = options.cache?.plugins || Object.create(null);
23239
23420
  // increment access counter
23240
23421
  for (const name in this.pluginCache) {
23241
23422
  const cache = this.pluginCache[name];
@@ -23432,12 +23613,300 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
23432
23613
  return result;
23433
23614
  }
23434
23615
 
23616
+ var lib = {};
23617
+
23618
+ const require$$0 = /*@__PURE__*/getAugmentedNamespace(acorn);
23619
+
23620
+ Object.defineProperty(lib, "__esModule", {
23621
+ value: true
23622
+ });
23623
+ var importAssertions_1 = lib.importAssertions = importAssertions;
23624
+
23625
+ var _acorn = _interopRequireWildcard(require$$0);
23626
+
23627
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23628
+
23629
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23630
+
23631
+ const leftCurlyBrace = "{".charCodeAt(0);
23632
+ const space = " ".charCodeAt(0);
23633
+ const keyword = "assert";
23634
+ const FUNC_STATEMENT = 1,
23635
+ FUNC_NULLABLE_ID = 4;
23636
+
23637
+ function importAssertions(Parser) {
23638
+ // Use supplied version acorn version if present, to avoid
23639
+ // reference mismatches due to different acorn versions. This
23640
+ // allows this plugin to be used with Rollup which supplies
23641
+ // its own internal version of acorn and thereby sidesteps
23642
+ // the package manager.
23643
+ const acorn = Parser.acorn || _acorn;
23644
+ const {
23645
+ tokTypes: tt,
23646
+ TokenType
23647
+ } = acorn;
23648
+ return class extends Parser {
23649
+ constructor(...args) {
23650
+ super(...args);
23651
+ this.assertToken = new TokenType(keyword);
23652
+ }
23653
+
23654
+ _codeAt(i) {
23655
+ return this.input.charCodeAt(i);
23656
+ }
23657
+
23658
+ _eat(t) {
23659
+ if (this.type !== t) {
23660
+ this.unexpected();
23661
+ }
23662
+
23663
+ this.next();
23664
+ }
23665
+
23666
+ readToken(code) {
23667
+ let i = 0;
23668
+
23669
+ for (; i < keyword.length; i++) {
23670
+ if (this._codeAt(this.pos + i) !== keyword.charCodeAt(i)) {
23671
+ return super.readToken(code);
23672
+ }
23673
+ } // ensure that the keyword is at the correct location
23674
+ // ie `assert{...` or `assert {...`
23675
+
23676
+
23677
+ for (;; i++) {
23678
+ if (this._codeAt(this.pos + i) === leftCurlyBrace) {
23679
+ // Found '{'
23680
+ break;
23681
+ } else if (this._codeAt(this.pos + i) === space) {
23682
+ // white space is allowed between `assert` and `{`, so continue.
23683
+ continue;
23684
+ } else {
23685
+ return super.readToken(code);
23686
+ }
23687
+ } // If we're inside a dynamic import expression we'll parse
23688
+ // the `assert` keyword as a standard object property name
23689
+ // ie `import(""./foo.json", { assert: { type: "json" } })`
23690
+
23691
+
23692
+ if (this.type.label === "{") {
23693
+ return super.readToken(code);
23694
+ }
23695
+
23696
+ this.pos += keyword.length;
23697
+ return this.finishToken(this.assertToken);
23698
+ }
23699
+
23700
+ parseDynamicImport(node) {
23701
+ this.next(); // skip `(`
23702
+ // Parse node.source.
23703
+
23704
+ node.source = this.parseMaybeAssign();
23705
+
23706
+ if (this.eat(tt.comma)) {
23707
+ const obj = this.parseObj(false);
23708
+ node.arguments = [obj];
23709
+ }
23710
+
23711
+ this._eat(tt.parenR);
23712
+
23713
+ return this.finishNode(node, "ImportExpression");
23714
+ } // ported from acorn/src/statement.js pp.parseExport
23715
+
23716
+
23717
+ parseExport(node, exports) {
23718
+ this.next(); // export * from '...'
23719
+
23720
+ if (this.eat(tt.star)) {
23721
+ if (this.options.ecmaVersion >= 11) {
23722
+ if (this.eatContextual("as")) {
23723
+ node.exported = this.parseIdent(true);
23724
+ this.checkExport(exports, node.exported.name, this.lastTokStart);
23725
+ } else {
23726
+ node.exported = null;
23727
+ }
23728
+ }
23729
+
23730
+ this.expectContextual("from");
23731
+
23732
+ if (this.type !== tt.string) {
23733
+ this.unexpected();
23734
+ }
23735
+
23736
+ node.source = this.parseExprAtom();
23737
+
23738
+ if (this.type === this.assertToken) {
23739
+ this.next();
23740
+ const assertions = this.parseImportAssertions();
23741
+
23742
+ if (assertions) {
23743
+ node.assertions = assertions;
23744
+ }
23745
+ }
23746
+
23747
+ this.semicolon();
23748
+ return this.finishNode(node, "ExportAllDeclaration");
23749
+ }
23750
+
23751
+ if (this.eat(tt._default)) {
23752
+ // export default ...
23753
+ this.checkExport(exports, "default", this.lastTokStart);
23754
+ var isAsync;
23755
+
23756
+ if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {
23757
+ var fNode = this.startNode();
23758
+ this.next();
23759
+
23760
+ if (isAsync) {
23761
+ this.next();
23762
+ }
23763
+
23764
+ node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
23765
+ } else if (this.type === tt._class) {
23766
+ var cNode = this.startNode();
23767
+ node.declaration = this.parseClass(cNode, "nullableID");
23768
+ } else {
23769
+ node.declaration = this.parseMaybeAssign();
23770
+ this.semicolon();
23771
+ }
23772
+
23773
+ return this.finishNode(node, "ExportDefaultDeclaration");
23774
+ } // export var|const|let|function|class ...
23775
+
23776
+
23777
+ if (this.shouldParseExportStatement()) {
23778
+ node.declaration = this.parseStatement(null);
23779
+
23780
+ if (node.declaration.type === "VariableDeclaration") {
23781
+ this.checkVariableExport(exports, node.declaration.declarations);
23782
+ } else {
23783
+ this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
23784
+ }
23785
+
23786
+ node.specifiers = [];
23787
+ node.source = null;
23788
+ } else {
23789
+ // export { x, y as z } [from '...']
23790
+ node.declaration = null;
23791
+ node.specifiers = this.parseExportSpecifiers(exports);
23792
+
23793
+ if (this.eatContextual("from")) {
23794
+ if (this.type !== tt.string) {
23795
+ this.unexpected();
23796
+ }
23797
+
23798
+ node.source = this.parseExprAtom();
23799
+
23800
+ if (this.type === this.assertToken) {
23801
+ this.next();
23802
+ const assertions = this.parseImportAssertions();
23803
+
23804
+ if (assertions) {
23805
+ node.assertions = assertions;
23806
+ }
23807
+ }
23808
+ } else {
23809
+ for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
23810
+ // check for keywords used as local names
23811
+ var spec = list[i];
23812
+ this.checkUnreserved(spec.local); // check if export is defined
23813
+
23814
+ this.checkLocalExport(spec.local);
23815
+ }
23816
+
23817
+ node.source = null;
23818
+ }
23819
+
23820
+ this.semicolon();
23821
+ }
23822
+
23823
+ return this.finishNode(node, "ExportNamedDeclaration");
23824
+ }
23825
+
23826
+ parseImport(node) {
23827
+ this.next(); // import '...'
23828
+
23829
+ if (this.type === tt.string) {
23830
+ node.specifiers = [];
23831
+ node.source = this.parseExprAtom();
23832
+ } else {
23833
+ node.specifiers = this.parseImportSpecifiers();
23834
+ this.expectContextual("from");
23835
+ node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
23836
+ }
23837
+
23838
+ if (this.type === this.assertToken) {
23839
+ this.next();
23840
+ const assertions = this.parseImportAssertions();
23841
+
23842
+ if (assertions) {
23843
+ node.assertions = assertions;
23844
+ }
23845
+ }
23846
+
23847
+ this.semicolon();
23848
+ return this.finishNode(node, "ImportDeclaration");
23849
+ }
23850
+
23851
+ parseImportAssertions() {
23852
+ this._eat(tt.braceL);
23853
+
23854
+ const attrs = this.parseAssertEntries();
23855
+
23856
+ this._eat(tt.braceR);
23857
+
23858
+ return attrs;
23859
+ }
23860
+
23861
+ parseAssertEntries() {
23862
+ const attrs = [];
23863
+ const attrNames = new Set();
23864
+
23865
+ do {
23866
+ if (this.type === tt.braceR) {
23867
+ break;
23868
+ }
23869
+
23870
+ const node = this.startNode(); // parse AssertionKey : IdentifierName, StringLiteral
23871
+
23872
+ let assertionKeyNode;
23873
+
23874
+ if (this.type === tt.string) {
23875
+ assertionKeyNode = this.parseLiteral(this.value);
23876
+ } else {
23877
+ assertionKeyNode = this.parseIdent(true);
23878
+ }
23879
+
23880
+ this.next();
23881
+ node.key = assertionKeyNode; // check if we already have an entry for an attribute
23882
+ // if a duplicate entry is found, throw an error
23883
+ // for now this logic will come into play only when someone declares `type` twice
23884
+
23885
+ if (attrNames.has(node.key.name)) {
23886
+ this.raise(this.pos, "Duplicated key in assertions");
23887
+ }
23888
+
23889
+ attrNames.add(node.key.name);
23890
+
23891
+ if (this.type !== tt.string) {
23892
+ this.raise(this.pos, "Only string is supported as an assertion value");
23893
+ }
23894
+
23895
+ node.value = this.parseLiteral(this.value);
23896
+ attrs.push(this.finishNode(node, "ImportAttribute"));
23897
+ } while (this.eat(tt.comma));
23898
+
23899
+ return attrs;
23900
+ }
23901
+
23902
+ };
23903
+ }
23904
+
23435
23905
  function normalizeInputOptions(config) {
23436
- var _a, _b, _c, _d;
23437
23906
  // These are options that may trigger special warnings or behaviour later
23438
23907
  // if the user did not select an explicit value
23439
23908
  const unsetOptions = new Set();
23440
- const context = (_a = config.context) !== null && _a !== void 0 ? _a : 'undefined';
23909
+ const context = config.context ?? 'undefined';
23441
23910
  const onwarn = getOnwarn(config);
23442
23911
  const strictDeprecations = config.strictDeprecations || false;
23443
23912
  const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
@@ -23446,11 +23915,11 @@ function normalizeInputOptions(config) {
23446
23915
  acornInjectPlugins: getAcornInjectPlugins(config),
23447
23916
  cache: getCache(config),
23448
23917
  context,
23449
- experimentalCacheExpiry: (_b = config.experimentalCacheExpiry) !== null && _b !== void 0 ? _b : 10,
23918
+ experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
23450
23919
  external: getIdMatcher(config.external),
23451
23920
  inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
23452
23921
  input: getInput(config),
23453
- makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c : 'ifRelativeSource',
23922
+ makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
23454
23923
  manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
23455
23924
  maxParallelFileOps,
23456
23925
  maxParallelFileReads: maxParallelFileOps,
@@ -23458,7 +23927,7 @@ function normalizeInputOptions(config) {
23458
23927
  onwarn,
23459
23928
  perf: config.perf || false,
23460
23929
  plugins: ensureArray$1(config.plugins),
23461
- preserveEntrySignatures: (_d = config.preserveEntrySignatures) !== null && _d !== void 0 ? _d : 'exports-only',
23930
+ preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only',
23462
23931
  preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
23463
23932
  preserveSymlinks: config.preserveSymlinks || false,
23464
23933
  shimMissingExports: config.shimMissingExports || false,
@@ -23492,8 +23961,11 @@ const getAcorn = (config) => ({
23492
23961
  sourceType: 'module',
23493
23962
  ...config.acorn
23494
23963
  });
23495
- const getAcornInjectPlugins = (config) => ensureArray$1(config.acornInjectPlugins);
23496
- const getCache = (config) => { var _a; return ((_a = config.cache) === null || _a === void 0 ? void 0 : _a.cache) || config.cache; };
23964
+ const getAcornInjectPlugins = (config) => [
23965
+ importAssertions_1,
23966
+ ...ensureArray$1(config.acornInjectPlugins)
23967
+ ];
23968
+ const getCache = (config) => config.cache?.cache || config.cache;
23497
23969
  const getIdMatcher = (option) => {
23498
23970
  if (option === true) {
23499
23971
  return () => true;
@@ -23535,12 +24007,11 @@ const getManualChunks$1 = (config, warn, strictDeprecations) => {
23535
24007
  return configManualChunks;
23536
24008
  };
23537
24009
  const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
23538
- var _a;
23539
24010
  const maxParallelFileReads = config.maxParallelFileReads;
23540
24011
  if (typeof maxParallelFileReads === 'number') {
23541
24012
  warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
23542
24013
  }
23543
- const maxParallelFileOps = (_a = config.maxParallelFileOps) !== null && _a !== void 0 ? _a : maxParallelFileReads;
24014
+ const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
23544
24015
  if (typeof maxParallelFileOps === 'number') {
23545
24016
  if (maxParallelFileOps <= 0)
23546
24017
  return Infinity;
@@ -23551,7 +24022,7 @@ const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
23551
24022
  const getModuleContext = (config, context) => {
23552
24023
  const configModuleContext = config.moduleContext;
23553
24024
  if (typeof configModuleContext === 'function') {
23554
- return id => { var _a; return (_a = configModuleContext(id)) !== null && _a !== void 0 ? _a : context; };
24025
+ return id => configModuleContext(id) ?? context;
23555
24026
  }
23556
24027
  if (configModuleContext) {
23557
24028
  const contextByModuleId = Object.create(null);
@@ -23629,7 +24100,6 @@ function isValidUrl(url) {
23629
24100
  }
23630
24101
 
23631
24102
  function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23632
- var _a, _b, _c, _d, _e, _f, _g;
23633
24103
  // These are options that may trigger special warnings or behaviour later
23634
24104
  // if the user did not select an explicit value
23635
24105
  const unsetOptions = new Set(unsetInputOptions);
@@ -23642,24 +24112,26 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23642
24112
  const generatedCode = getGeneratedCode(config, preferConst);
23643
24113
  const outputOptions = {
23644
24114
  amd: getAmd(config),
23645
- assetFileNames: (_a = config.assetFileNames) !== null && _a !== void 0 ? _a : 'assets/[name]-[hash][extname]',
24115
+ assetFileNames: config.assetFileNames ?? 'assets/[name]-[hash][extname]',
23646
24116
  banner: getAddon(config, 'banner'),
23647
- chunkFileNames: (_b = config.chunkFileNames) !== null && _b !== void 0 ? _b : '[name]-[hash].js',
24117
+ chunkFileNames: config.chunkFileNames ?? '[name]-[hash].js',
23648
24118
  compact,
23649
24119
  dir: getDir(config, file),
23650
24120
  dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
24121
+ dynamicImportInCjs: config.dynamicImportInCjs ?? true,
23651
24122
  entryFileNames: getEntryFileNames(config, unsetOptions),
23652
- esModule: (_c = config.esModule) !== null && _c !== void 0 ? _c : 'if-default-prop',
24123
+ esModule: config.esModule ?? 'if-default-prop',
23653
24124
  exports: getExports(config, unsetOptions),
23654
24125
  extend: config.extend || false,
23655
- externalLiveBindings: (_d = config.externalLiveBindings) !== null && _d !== void 0 ? _d : true,
24126
+ externalImportAssertions: config.externalImportAssertions ?? true,
24127
+ externalLiveBindings: config.externalLiveBindings ?? true,
23656
24128
  file,
23657
24129
  footer: getAddon(config, 'footer'),
23658
24130
  format,
23659
- freeze: (_e = config.freeze) !== null && _e !== void 0 ? _e : true,
24131
+ freeze: config.freeze ?? true,
23660
24132
  generatedCode,
23661
24133
  globals: config.globals || {},
23662
- hoistTransitiveImports: (_f = config.hoistTransitiveImports) !== null && _f !== void 0 ? _f : true,
24134
+ hoistTransitiveImports: config.hoistTransitiveImports ?? true,
23663
24135
  indent: getIndent(config, compact),
23664
24136
  inlineDynamicImports,
23665
24137
  interop: getInterop(config),
@@ -23685,8 +24157,8 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23685
24157
  sourcemapExcludeSources: config.sourcemapExcludeSources || false,
23686
24158
  sourcemapFile: config.sourcemapFile,
23687
24159
  sourcemapPathTransform: config.sourcemapPathTransform,
23688
- strict: (_g = config.strict) !== null && _g !== void 0 ? _g : true,
23689
- systemNullSetters: config.systemNullSetters || false,
24160
+ strict: config.strict ?? true,
24161
+ systemNullSetters: config.systemNullSetters ?? true,
23690
24162
  validate: config.validate || false
23691
24163
  };
23692
24164
  warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
@@ -23729,8 +24201,7 @@ const getFormat = (config) => {
23729
24201
  }
23730
24202
  };
23731
24203
  const getInlineDynamicImports = (config, inputOptions) => {
23732
- var _a;
23733
- const inlineDynamicImports = ((_a = config.inlineDynamicImports) !== null && _a !== void 0 ? _a : inputOptions.inlineDynamicImports) || false;
24204
+ const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
23734
24205
  const { input } = inputOptions;
23735
24206
  if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
23736
24207
  return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
@@ -23738,8 +24209,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
23738
24209
  return inlineDynamicImports;
23739
24210
  };
23740
24211
  const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
23741
- var _a;
23742
- const preserveModules = ((_a = config.preserveModules) !== null && _a !== void 0 ? _a : inputOptions.preserveModules) || false;
24212
+ const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
23743
24213
  if (preserveModules) {
23744
24214
  if (inlineDynamicImports) {
23745
24215
  return error(errInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', `this option is not supported for "output.preserveModules"`));
@@ -23826,7 +24296,7 @@ const getEntryFileNames = (config, unsetOptions) => {
23826
24296
  if (configEntryFileNames == null) {
23827
24297
  unsetOptions.add('entryFileNames');
23828
24298
  }
23829
- return configEntryFileNames !== null && configEntryFileNames !== void 0 ? configEntryFileNames : '[name].js';
24299
+ return configEntryFileNames ?? '[name].js';
23830
24300
  };
23831
24301
  function getExports(config, unsetOptions) {
23832
24302
  const configExports = config.exports;
@@ -23853,7 +24323,7 @@ const getIndent = (config, compact) => {
23853
24323
  return '';
23854
24324
  }
23855
24325
  const configIndent = config.indent;
23856
- return configIndent === false ? '' : configIndent !== null && configIndent !== void 0 ? configIndent : true;
24326
+ return configIndent === false ? '' : configIndent ?? true;
23857
24327
  };
23858
24328
  const ALLOWED_INTEROP_TYPES = new Set([
23859
24329
  'compat',
@@ -23893,7 +24363,7 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
23893
24363
  }
23894
24364
  return configManualChunks || {};
23895
24365
  };
23896
- const getMinifyInternalExports = (config, format, compact) => { var _a; return (_a = config.minifyInternalExports) !== null && _a !== void 0 ? _a : (compact || format === 'es' || format === 'system'); };
24366
+ const getMinifyInternalExports = (config, format, compact) => config.minifyInternalExports ?? (compact || format === 'es' || format === 'system');
23897
24367
  const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
23898
24368
  const configNamespaceToStringTag = config.namespaceToStringTag;
23899
24369
  if (configNamespaceToStringTag != null) {
@@ -24031,13 +24501,7 @@ function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, out
24031
24501
  }
24032
24502
  function createOutput(outputBundle) {
24033
24503
  return {
24034
- output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) => {
24035
- const fileTypeA = getSortingFileType(outputFileA);
24036
- const fileTypeB = getSortingFileType(outputFileB);
24037
- if (fileTypeA === fileTypeB)
24038
- return 0;
24039
- return fileTypeA < fileTypeB ? -1 : 1;
24040
- })
24504
+ output: Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0).sort((outputFileA, outputFileB) => getSortingFileType(outputFileA) - getSortingFileType(outputFileB))
24041
24505
  };
24042
24506
  }
24043
24507
  var SortingFileType;