rollup 2.67.3 → 2.69.1

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 v2.67.3
4
- Fri, 18 Feb 2022 05:29:45 GMT - commit fa4e1b720f64ffae24fcbf99a44b605842ac7f23
3
+ Rollup.js v2.69.1
4
+ Fri, 04 Mar 2022 13:38:38 GMT - commit 994c1eccf4d53e416a010f47e54a2086f1a0f4e9
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -18,7 +18,7 @@ const require$$0$1 = require('fs');
18
18
  const require$$0$2 = require('events');
19
19
 
20
20
  function _interopNamespaceDefault(e) {
21
- const n = Object.create(null);
21
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
22
22
  if (e) {
23
23
  for (const k in e) {
24
24
  n[k] = e[k];
@@ -28,7 +28,7 @@ function _interopNamespaceDefault(e) {
28
28
  return n;
29
29
  }
30
30
 
31
- var version$1 = "2.67.3";
31
+ var version$1 = "2.69.1";
32
32
 
33
33
  function ensureArray$1(items) {
34
34
  if (Array.isArray(items)) {
@@ -127,33 +127,72 @@ function printQuotedStringList(list, verbs) {
127
127
  return output;
128
128
  }
129
129
 
130
- const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
131
- const relativePath = /^\.?\.\//;
130
+ const ANY_SLASH_REGEX = /[/\\]/;
131
+ function relative(from, to) {
132
+ const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);
133
+ const toParts = to.split(ANY_SLASH_REGEX).filter(Boolean);
134
+ if (fromParts[0] === '.')
135
+ fromParts.shift();
136
+ if (toParts[0] === '.')
137
+ toParts.shift();
138
+ while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) {
139
+ fromParts.shift();
140
+ toParts.shift();
141
+ }
142
+ while (toParts[0] === '..' && fromParts.length > 0) {
143
+ toParts.shift();
144
+ fromParts.pop();
145
+ }
146
+ while (fromParts.pop()) {
147
+ toParts.unshift('..');
148
+ }
149
+ return toParts.join('/');
150
+ }
151
+
152
+ const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
153
+ const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
132
154
  function isAbsolute(path) {
133
- return absolutePath.test(path);
155
+ return ABSOLUTE_PATH_REGEX.test(path);
134
156
  }
135
157
  function isRelative(path) {
136
- return relativePath.test(path);
158
+ return RELATIVE_PATH_REGEX.test(path);
137
159
  }
160
+ const BACKSLASH_REGEX = /\\/g;
138
161
  function normalize(path) {
139
- if (path.indexOf('\\') == -1)
140
- return path;
141
- return path.replace(/\\/g, '/');
162
+ return path.replace(BACKSLASH_REGEX, '/');
142
163
  }
143
164
 
144
165
  function getAliasName(id) {
145
166
  const base = require$$0.basename(id);
146
- return base.substr(0, base.length - require$$0.extname(id).length);
167
+ return base.substring(0, base.length - require$$0.extname(id).length);
147
168
  }
148
169
  function relativeId(id) {
149
170
  if (!isAbsolute(id))
150
171
  return id;
151
- return require$$0.relative(require$$0.resolve(), id);
172
+ return relative(require$$0.resolve(), id);
152
173
  }
153
174
  function isPathFragment(name) {
154
175
  // starting with "/", "./", "../", "C:/"
155
176
  return (name[0] === '/' || (name[0] === '.' && (name[1] === '/' || name[1] === '.')) || isAbsolute(name));
156
177
  }
178
+ const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
179
+ function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
180
+ let relativePath = normalize(relative(require$$0.dirname(importerId), targetPath));
181
+ if (stripJsExtension && relativePath.endsWith('.js')) {
182
+ relativePath = relativePath.slice(0, -3);
183
+ }
184
+ if (ensureFileName) {
185
+ if (relativePath === '')
186
+ return '../' + require$$0.basename(targetPath);
187
+ if (UPPER_DIR_REGEX.test(relativePath)) {
188
+ return relativePath
189
+ .split('/')
190
+ .concat(['..', require$$0.basename(targetPath)])
191
+ .join('/');
192
+ }
193
+ }
194
+ return !relativePath ? '.' : relativePath.startsWith('..') ? relativePath : './' + relativePath;
195
+ }
157
196
 
158
197
  function error(base) {
159
198
  if (!(base instanceof Error))
@@ -547,13 +586,15 @@ const generatedCodePresets = {
547
586
  arrowFunctions: true,
548
587
  constBindings: true,
549
588
  objectShorthand: true,
550
- reservedNamesAsProps: true
589
+ reservedNamesAsProps: true,
590
+ symbols: true
551
591
  },
552
592
  es5: {
553
593
  arrowFunctions: false,
554
594
  constBindings: false,
555
595
  objectShorthand: false,
556
- reservedNamesAsProps: true
596
+ reservedNamesAsProps: true,
597
+ symbols: false
557
598
  }
558
599
  };
559
600
  const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
@@ -600,11 +641,11 @@ function getFsEvents() {
600
641
  return fsEvents;
601
642
  }
602
643
 
603
- const fseventsImporter = {
644
+ const fseventsImporter = /*#__PURE__*/Object.defineProperty({
604
645
  __proto__: null,
605
646
  loadFsEvents,
606
647
  getFsEvents
607
- };
648
+ }, Symbol.toStringTag, { value: 'Module' });
608
649
 
609
650
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
610
651
 
@@ -2050,27 +2091,6 @@ Bundle$1.prototype.trimEnd = function trimEnd (charType) {
2050
2091
 
2051
2092
  const MagicString$1 = MagicString;
2052
2093
 
2053
- function relative(from, to) {
2054
- const fromParts = from.split(/[/\\]/).filter(Boolean);
2055
- const toParts = to.split(/[/\\]/).filter(Boolean);
2056
- if (fromParts[0] === '.')
2057
- fromParts.shift();
2058
- if (toParts[0] === '.')
2059
- toParts.shift();
2060
- while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) {
2061
- fromParts.shift();
2062
- toParts.shift();
2063
- }
2064
- while (toParts[0] === '..' && fromParts.length > 0) {
2065
- toParts.shift();
2066
- fromParts.pop();
2067
- }
2068
- while (fromParts.pop()) {
2069
- toParts.unshift('..');
2070
- }
2071
- return toParts.join('/');
2072
- }
2073
-
2074
2094
  function getOrCreate(map, key, init) {
2075
2095
  const existing = map.get(key);
2076
2096
  if (existing) {
@@ -2326,14 +2346,14 @@ class ExternalModule {
2326
2346
  this.options = options;
2327
2347
  this.id = id;
2328
2348
  this.renormalizeRenderPath = renormalizeRenderPath;
2329
- this.declarations = Object.create(null);
2349
+ this.declarations = new Map();
2330
2350
  this.defaultVariableName = '';
2331
2351
  this.dynamicImporters = [];
2332
2352
  this.execIndex = Infinity;
2333
2353
  this.exportedVariables = new Map();
2334
2354
  this.importers = [];
2335
2355
  this.mostCommonSuggestion = 0;
2336
- this.nameSuggestions = Object.create(null);
2356
+ this.nameSuggestions = new Map();
2337
2357
  this.namespaceVariableName = '';
2338
2358
  this.reexported = false;
2339
2359
  this.renderPath = undefined;
@@ -2375,12 +2395,13 @@ class ExternalModule {
2375
2395
  });
2376
2396
  }
2377
2397
  getVariableForExportName(name) {
2378
- let declaration = this.declarations[name];
2398
+ const declaration = this.declarations.get(name);
2379
2399
  if (declaration)
2380
2400
  return [declaration];
2381
- this.declarations[name] = declaration = new ExternalVariable(this, name);
2382
- this.exportedVariables.set(declaration, name);
2383
- return [declaration];
2401
+ const externalVariable = new ExternalVariable(this, name);
2402
+ this.declarations.set(name, externalVariable);
2403
+ this.exportedVariables.set(externalVariable, name);
2404
+ return [externalVariable];
2384
2405
  }
2385
2406
  setRenderPath(options, inputBase) {
2386
2407
  this.renderPath =
@@ -2390,30 +2411,25 @@ class ExternalModule {
2390
2411
  ? normalize(require$$0.relative(inputBase, this.id))
2391
2412
  : this.id;
2392
2413
  }
2393
- return this.renderPath;
2394
2414
  }
2395
2415
  suggestName(name) {
2396
- if (!this.nameSuggestions[name])
2397
- this.nameSuggestions[name] = 0;
2398
- this.nameSuggestions[name] += 1;
2399
- if (this.nameSuggestions[name] > this.mostCommonSuggestion) {
2400
- this.mostCommonSuggestion = this.nameSuggestions[name];
2416
+ var _a;
2417
+ const value = ((_a = this.nameSuggestions.get(name)) !== null && _a !== void 0 ? _a : 0) + 1;
2418
+ this.nameSuggestions.set(name, value);
2419
+ if (value > this.mostCommonSuggestion) {
2420
+ this.mostCommonSuggestion = value;
2401
2421
  this.suggestedVariableName = name;
2402
2422
  }
2403
2423
  }
2404
2424
  warnUnusedImports() {
2405
- const unused = Object.keys(this.declarations).filter(name => {
2406
- if (name === '*')
2407
- return false;
2408
- const declaration = this.declarations[name];
2409
- return !declaration.included && !this.reexported && !declaration.referenced;
2410
- });
2425
+ const unused = Array.from(this.declarations)
2426
+ .filter(([name, declaration]) => name !== '*' && !declaration.included && !this.reexported && !declaration.referenced)
2427
+ .map(([name]) => name);
2411
2428
  if (unused.length === 0)
2412
2429
  return;
2413
2430
  const importersSet = new Set();
2414
2431
  for (const name of unused) {
2415
- const { importers } = this.declarations[name].module;
2416
- for (const importer of importers) {
2432
+ for (const importer of this.declarations.get(name).module.importers) {
2417
2433
  importersSet.add(importer);
2418
2434
  }
2419
2435
  }
@@ -4796,9 +4812,8 @@ function getLiteralMembersForValue(value) {
4796
4812
  return literalNumberMembers;
4797
4813
  case 'string':
4798
4814
  return literalStringMembers;
4799
- default:
4800
- return Object.create(null);
4801
4815
  }
4816
+ return Object.create(null);
4802
4817
  }
4803
4818
  function hasMemberEffectWhenCalled(members, memberName, callOptions, context) {
4804
4819
  if (typeof memberName !== 'string' || !members[memberName]) {
@@ -10134,19 +10149,17 @@ const HELPER_GENERATORS = {
10134
10149
  return (`${left}e${_}&&${_}e.__esModule${_}?${_}` +
10135
10150
  `${liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets)}${right}${n}${n}`);
10136
10151
  },
10137
- [INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE](_t, { _, getDirectReturnFunction, getObject, n }, _liveBindings, freeze, namespaceToStringTag) {
10152
+ [INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE](_t, snippets, _liveBindings, freeze, namespaceToStringTag) {
10153
+ const { getDirectReturnFunction, getObject, n } = snippets;
10138
10154
  const [left, right] = getDirectReturnFunction(['e'], {
10139
10155
  functionReturn: true,
10140
10156
  lineBreakIndent: null,
10141
10157
  name: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE
10142
10158
  });
10143
- return `${left}${getFrozen(getObject([
10159
+ return `${left}${getFrozen(freeze, getWithToStringTag(namespaceToStringTag, getObject([
10144
10160
  ['__proto__', 'null'],
10145
- ...(namespaceToStringTag
10146
- ? [[null, `[Symbol.toStringTag]:${_}'Module'`]]
10147
- : []),
10148
10161
  ['default', 'e']
10149
- ], { lineBreakIndent: null }), freeze)}${right}${n}${n}`;
10162
+ ], { lineBreakIndent: null }), snippets))}${right}${n}${n}`;
10150
10163
  },
10151
10164
  [INTEROP_NAMESPACE_DEFAULT_VARIABLE](t, snippets, liveBindings, freeze, namespaceToStringTag) {
10152
10165
  const { _, n } = snippets;
@@ -10169,7 +10182,7 @@ const HELPER_GENERATORS = {
10169
10182
  createNamespaceObject(t, t, snippets, liveBindings, freeze, namespaceToStringTag) +
10170
10183
  `}${n}${n}`);
10171
10184
  },
10172
- [MERGE_NAMESPACES_VARIABLE](t, snippets, liveBindings, freeze) {
10185
+ [MERGE_NAMESPACES_VARIABLE](t, snippets, liveBindings, freeze, namespaceToStringTag) {
10173
10186
  const { _, cnst, n } = snippets;
10174
10187
  const useForEach = cnst === 'var' && liveBindings;
10175
10188
  return (`function ${MERGE_NAMESPACES_VARIABLE}(n, m)${_}{${n}` +
@@ -10182,25 +10195,25 @@ const HELPER_GENERATORS = {
10182
10195
  : copyPropertyStatic)(t, t + t + t + t, snippets) +
10183
10196
  `${t}${t}${t}}${n}` +
10184
10197
  `${t}${t}}`, useForEach, t, snippets)}${n}` +
10185
- `${t}return ${getFrozen('n', freeze)};${n}` +
10198
+ `${t}return ${getFrozen(freeze, getWithToStringTag(namespaceToStringTag, 'n', snippets))};${n}` +
10186
10199
  `}${n}${n}`);
10187
10200
  }
10188
10201
  };
10189
10202
  const getDefaultLiveBinding = ({ _, getObject }) => `e${_}:${_}${getObject([['default', 'e']], { lineBreakIndent: null })}`;
10190
10203
  const getDefaultStatic = ({ _, getPropertyAccess }) => `e${getPropertyAccess('default')}${_}:${_}e`;
10191
10204
  const createNamespaceObject = (t, i, snippets, liveBindings, freeze, namespaceToStringTag) => {
10192
- const { _, cnst, getPropertyAccess, n, s } = snippets;
10205
+ const { _, cnst, getObject, getPropertyAccess, n, s } = snippets;
10193
10206
  const copyProperty = `{${n}` +
10194
10207
  (liveBindings ? copyNonDefaultOwnPropertyLiveBinding : copyPropertyStatic)(t, i + t + t, snippets) +
10195
10208
  `${i}${t}}`;
10196
- return (`${i}${cnst} n${_}=${_}${namespaceToStringTag
10197
- ? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
10198
- : 'Object.create(null)'};${n}` +
10209
+ return (`${i}${cnst} n${_}=${_}Object.create(null${namespaceToStringTag
10210
+ ? `,${_}{${_}[Symbol.toStringTag]:${_}${getToStringTagValue(getObject)}${_}}`
10211
+ : ''});${n}` +
10199
10212
  `${i}if${_}(e)${_}{${n}` +
10200
10213
  `${i}${t}${loopOverKeys(copyProperty, !liveBindings, snippets)}${n}` +
10201
10214
  `${i}}${n}` +
10202
10215
  `${i}n${getPropertyAccess('default')}${_}=${_}e;${n}` +
10203
- `${i}return ${getFrozen('n', freeze)}${s}${n}`);
10216
+ `${i}return ${getFrozen(freeze, 'n')}${s}${n}`);
10204
10217
  };
10205
10218
  const loopOverKeys = (body, allowVarLoopVariable, { _, cnst, getFunctionIntro, s }) => cnst !== 'var' || allowVarLoopVariable
10206
10219
  ? `for${_}(${cnst} k in e)${_}${body}`
@@ -10258,8 +10271,16 @@ const copyPropertyLiveBinding = (t, i, { _, cnst, getDirectReturnFunction, n })
10258
10271
  `${i}}${n}`);
10259
10272
  };
10260
10273
  const copyPropertyStatic = (_t, i, { _, n }) => `${i}n[k]${_}=${_}e[k];${n}`;
10261
- const getFrozen = (fragment, freeze) => freeze ? `Object.freeze(${fragment})` : fragment;
10274
+ const getFrozen = (freeze, fragment) => freeze ? `Object.freeze(${fragment})` : fragment;
10275
+ const getWithToStringTag = (namespaceToStringTag, fragment, { _, getObject }) => namespaceToStringTag
10276
+ ? `Object.defineProperty(${fragment},${_}Symbol.toStringTag,${_}${getToStringTagValue(getObject)})`
10277
+ : fragment;
10262
10278
  const HELPER_NAMES = Object.keys(HELPER_GENERATORS);
10279
+ function getToStringTagValue(getObject) {
10280
+ return getObject([['value', "'Module'"]], {
10281
+ lineBreakIndent: null
10282
+ });
10283
+ }
10263
10284
 
10264
10285
  class ImportExpression extends NodeBase {
10265
10286
  constructor() {
@@ -10636,7 +10657,7 @@ class MetaProperty extends NodeBase {
10636
10657
  getReferencedFileName(outputPluginDriver) {
10637
10658
  const metaProperty = this.metaProperty;
10638
10659
  if (metaProperty && metaProperty.startsWith(FILE_PREFIX)) {
10639
- return outputPluginDriver.getFileName(metaProperty.substr(FILE_PREFIX.length));
10660
+ return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length));
10640
10661
  }
10641
10662
  return null;
10642
10663
  }
@@ -10672,17 +10693,17 @@ class MetaProperty extends NodeBase {
10672
10693
  let chunkReferenceId = null;
10673
10694
  let fileName;
10674
10695
  if (metaProperty.startsWith(FILE_PREFIX)) {
10675
- referenceId = metaProperty.substr(FILE_PREFIX.length);
10696
+ referenceId = metaProperty.substring(FILE_PREFIX.length);
10676
10697
  fileName = outputPluginDriver.getFileName(referenceId);
10677
10698
  }
10678
10699
  else if (metaProperty.startsWith(ASSET_PREFIX)) {
10679
10700
  warnDeprecation(`Using the "${ASSET_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
10680
- assetReferenceId = metaProperty.substr(ASSET_PREFIX.length);
10701
+ assetReferenceId = metaProperty.substring(ASSET_PREFIX.length);
10681
10702
  fileName = outputPluginDriver.getFileName(assetReferenceId);
10682
10703
  }
10683
10704
  else {
10684
10705
  warnDeprecation(`Using the "${CHUNK_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
10685
- chunkReferenceId = metaProperty.substr(CHUNK_PREFIX.length);
10706
+ chunkReferenceId = metaProperty.substring(CHUNK_PREFIX.length);
10686
10707
  fileName = outputPluginDriver.getFileName(chunkReferenceId);
10687
10708
  }
10688
10709
  const relativePath = normalize(require$$0.relative(require$$0.dirname(chunkId), fileName));
@@ -12038,17 +12059,20 @@ class NamespaceVariable extends Variable {
12038
12059
  }
12039
12060
  return [name, original.getName(getPropertyAccess)];
12040
12061
  });
12041
- if (namespaceToStringTag) {
12042
- members.unshift([null, `[Symbol.toStringTag]:${_}'Module'`]);
12043
- }
12044
12062
  members.unshift([null, `__proto__:${_}null`]);
12045
12063
  let output = getObject(members, { lineBreakIndent: { base: '', t } });
12046
12064
  if (this.mergedNamespaces.length > 0) {
12047
12065
  const assignmentArgs = this.mergedNamespaces.map(variable => variable.getName(getPropertyAccess));
12048
- output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output}, [${assignmentArgs.join(`,${_}`)}])`;
12066
+ output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output},${_}[${assignmentArgs.join(`,${_}`)}])`;
12049
12067
  }
12050
- if (freeze) {
12051
- output = `/*#__PURE__*/Object.freeze(${output})`;
12068
+ else {
12069
+ // The helper to merge namespaces will also take care of freezing and toStringTag
12070
+ if (namespaceToStringTag) {
12071
+ output = `/*#__PURE__*/Object.defineProperty(${output},${_}Symbol.toStringTag,${_}${getToStringTagValue(getObject)})`;
12072
+ }
12073
+ if (freeze) {
12074
+ output = `/*#__PURE__*/Object.freeze(${output})`;
12075
+ }
12052
12076
  }
12053
12077
  const name = this.getName(getPropertyAccess);
12054
12078
  output = `${cnst} ${name}${_}=${_}${output};`;
@@ -12127,29 +12151,23 @@ function getId(m) {
12127
12151
 
12128
12152
  function getOriginalLocation(sourcemapChain, location) {
12129
12153
  const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
12130
- while (filteredSourcemapChain.length > 0) {
12154
+ traceSourcemap: while (filteredSourcemapChain.length > 0) {
12131
12155
  const sourcemap = filteredSourcemapChain.pop();
12132
12156
  const line = sourcemap.mappings[location.line - 1];
12133
- let locationFound = false;
12134
- if (line !== undefined) {
12135
- for (const segment of line) {
12136
- if (segment[0] >= location.column) {
12137
- if (segment.length === 1)
12138
- break;
12157
+ if (line) {
12158
+ const filteredLine = line.filter((segment) => segment.length > 1);
12159
+ const lastSegment = filteredLine[filteredLine.length - 1];
12160
+ for (const segment of filteredLine) {
12161
+ if (segment[0] >= location.column || segment === lastSegment) {
12139
12162
  location = {
12140
12163
  column: segment[3],
12141
- line: segment[2] + 1,
12142
- name: segment.length === 5 ? sourcemap.names[segment[4]] : undefined,
12143
- source: sourcemap.sources[segment[1]]
12164
+ line: segment[2] + 1
12144
12165
  };
12145
- locationFound = true;
12146
- break;
12166
+ continue traceSourcemap;
12147
12167
  }
12148
12168
  }
12149
12169
  }
12150
- if (!locationFound) {
12151
- throw new Error("Can't resolve original location of error.");
12152
- }
12170
+ throw new Error("Can't resolve original location of error.");
12153
12171
  }
12154
12172
  return location;
12155
12173
  }
@@ -12346,7 +12364,7 @@ class Module {
12346
12364
  this.exportNamesByVariable = null;
12347
12365
  this.exportShimVariable = new ExportShimVariable(this);
12348
12366
  this.exports = new Map();
12349
- this.namespaceReexportsByName = Object.create(null);
12367
+ this.namespaceReexportsByName = new Map();
12350
12368
  this.reexportDescriptions = new Map();
12351
12369
  this.relevantDependencies = null;
12352
12370
  this.syntheticExports = new Map();
@@ -12358,7 +12376,7 @@ class Module {
12358
12376
  this.preserveSignature = this.options.preserveEntrySignatures;
12359
12377
  // eslint-disable-next-line @typescript-eslint/no-this-alias
12360
12378
  const module = this;
12361
- const { dynamicImports, dynamicImporters, reexportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, sources, importers } = this;
12379
+ const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sources } = this;
12362
12380
  this.info = {
12363
12381
  ast: null,
12364
12382
  code: null,
@@ -12368,13 +12386,9 @@ class Module {
12368
12386
  .filter(Boolean);
12369
12387
  },
12370
12388
  get dynamicallyImportedIds() {
12371
- const dynamicallyImportedIds = [];
12372
- for (const { id } of dynamicImports) {
12373
- if (id) {
12374
- dynamicallyImportedIds.push(id);
12375
- }
12376
- }
12377
- return dynamicallyImportedIds;
12389
+ // We cannot use this.dynamicDependencies because this is needed before
12390
+ // dynamicDependencies are populated
12391
+ return dynamicImports.map(({ id }) => id).filter((id) => id != null);
12378
12392
  },
12379
12393
  get dynamicImporters() {
12380
12394
  return dynamicImporters.sort();
@@ -12388,7 +12402,7 @@ class Module {
12388
12402
  },
12389
12403
  get hasModuleSideEffects() {
12390
12404
  warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', false, options);
12391
- return module.info.moduleSideEffects;
12405
+ return this.moduleSideEffects;
12392
12406
  },
12393
12407
  id,
12394
12408
  get implicitlyLoadedAfterOneOf() {
@@ -12401,6 +12415,8 @@ class Module {
12401
12415
  return Array.from(sources, source => module.resolvedIds[source]).filter(Boolean);
12402
12416
  },
12403
12417
  get importedIds() {
12418
+ // We cannot use this.dependencies because this is needed before
12419
+ // dependencies are populated
12404
12420
  return Array.from(sources, source => { var _a; return (_a = module.resolvedIds[source]) === null || _a === void 0 ? void 0 : _a.id; }).filter(Boolean);
12405
12421
  },
12406
12422
  get importers() {
@@ -12460,7 +12476,7 @@ class Module {
12460
12476
  getDependenciesToBeIncluded() {
12461
12477
  if (this.relevantDependencies)
12462
12478
  return this.relevantDependencies;
12463
- const relevantDependencies = new Set();
12479
+ this.relevantDependencies = new Set();
12464
12480
  const necessaryDependencies = new Set();
12465
12481
  const alwaysCheckedDependencies = new Set();
12466
12482
  const dependencyVariables = new Set(this.imports);
@@ -12492,16 +12508,16 @@ class Module {
12492
12508
  }
12493
12509
  if (!this.options.treeshake || this.info.moduleSideEffects === 'no-treeshake') {
12494
12510
  for (const dependency of this.dependencies) {
12495
- relevantDependencies.add(dependency);
12511
+ this.relevantDependencies.add(dependency);
12496
12512
  }
12497
12513
  }
12498
12514
  else {
12499
- this.addRelevantSideEffectDependencies(relevantDependencies, necessaryDependencies, alwaysCheckedDependencies);
12515
+ this.addRelevantSideEffectDependencies(this.relevantDependencies, necessaryDependencies, alwaysCheckedDependencies);
12500
12516
  }
12501
12517
  for (const dependency of necessaryDependencies) {
12502
- relevantDependencies.add(dependency);
12518
+ this.relevantDependencies.add(dependency);
12503
12519
  }
12504
- return (this.relevantDependencies = relevantDependencies);
12520
+ return this.relevantDependencies;
12505
12521
  }
12506
12522
  getExportNamesByVariable() {
12507
12523
  if (this.exportNamesByVariable) {
@@ -12573,16 +12589,15 @@ class Module {
12573
12589
  return this.syntheticNamespace;
12574
12590
  }
12575
12591
  getVariableForExportName(name, { importerForSideEffects, isExportAllSearch, onlyExplicit, searchedNamesAndModules } = EMPTY_OBJECT) {
12592
+ var _a;
12576
12593
  if (name[0] === '*') {
12577
12594
  if (name.length === 1) {
12578
12595
  // export * from './other'
12579
12596
  return [this.namespace];
12580
12597
  }
12581
- else {
12582
- // export * from 'external'
12583
- const module = this.graph.modulesById.get(name.slice(1));
12584
- return module.getVariableForExportName('*');
12585
- }
12598
+ // export * from 'external'
12599
+ const module = this.graph.modulesById.get(name.slice(1));
12600
+ return module.getVariableForExportName('*');
12586
12601
  }
12587
12602
  // export { foo } from './other'
12588
12603
  const reexportDeclaration = this.reexportDescriptions.get(name);
@@ -12613,10 +12628,8 @@ class Module {
12613
12628
  return [null];
12614
12629
  }
12615
12630
  if (name !== 'default') {
12616
- const foundNamespaceReexport = name in this.namespaceReexportsByName
12617
- ? this.namespaceReexportsByName[name]
12618
- : this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules);
12619
- this.namespaceReexportsByName[name] = foundNamespaceReexport;
12631
+ const foundNamespaceReexport = (_a = this.namespaceReexportsByName.get(name)) !== null && _a !== void 0 ? _a : this.getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules);
12632
+ this.namespaceReexportsByName.set(name, foundNamespaceReexport);
12620
12633
  if (foundNamespaceReexport[0]) {
12621
12634
  return foundNamespaceReexport;
12622
12635
  }
@@ -13224,26 +13237,29 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
13224
13237
  }
13225
13238
  return `${moduleVariableName}${getPropertyAccess(imported)}`;
13226
13239
  }
13227
- function getEsModuleExport(_) {
13228
- return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`;
13229
- }
13230
- function getNamespaceToStringExport(_) {
13231
- return `exports[Symbol.toStringTag]${_}=${_}'Module';`;
13240
+ function getEsModuleValue(getObject) {
13241
+ return getObject([['value', 'true']], {
13242
+ lineBreakIndent: null
13243
+ });
13232
13244
  }
13233
- function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, _, n) {
13234
- let namespaceMarkers = '';
13245
+ function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, { _, getObject }) {
13235
13246
  if (hasNamedExports) {
13236
13247
  if (addEsModule) {
13237
- namespaceMarkers += getEsModuleExport(_);
13248
+ if (addNamespaceToStringTag) {
13249
+ return `Object.defineProperties(exports,${_}${getObject([
13250
+ ['__esModule', getEsModuleValue(getObject)],
13251
+ [null, `[Symbol.toStringTag]:${_}${getToStringTagValue(getObject)}`]
13252
+ ], {
13253
+ lineBreakIndent: null
13254
+ })});`;
13255
+ }
13256
+ return `Object.defineProperty(exports,${_}'__esModule',${_}${getEsModuleValue(getObject)});`;
13238
13257
  }
13239
13258
  if (addNamespaceToStringTag) {
13240
- if (namespaceMarkers) {
13241
- namespaceMarkers += n;
13242
- }
13243
- namespaceMarkers += getNamespaceToStringExport(_);
13259
+ return `Object.defineProperty(exports,${_}Symbol.toStringTag,${_}${getToStringTagValue(getObject)});`;
13244
13260
  }
13245
13261
  }
13246
- return namespaceMarkers;
13262
+ return '';
13247
13263
  }
13248
13264
  const getDefineProperty = (name, needsLiveBinding, t, { _, getDirectReturnFunction, n }) => {
13249
13265
  if (needsLiveBinding) {
@@ -13380,7 +13396,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13380
13396
  const useStrict = strict ? `${_}'use strict';` : '';
13381
13397
  magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
13382
13398
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13383
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
13399
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
13384
13400
  if (namespaceMarkers) {
13385
13401
  namespaceMarkers = n + n + namespaceMarkers;
13386
13402
  }
@@ -13399,7 +13415,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13399
13415
  function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
13400
13416
  const { _, n } = snippets;
13401
13417
  const useStrict = strict ? `'use strict';${n}${n}` : '';
13402
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
13418
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
13403
13419
  if (namespaceMarkers) {
13404
13420
  namespaceMarkers += n + n;
13405
13421
  }
@@ -13593,7 +13609,7 @@ function trimEmptyImports(dependencies) {
13593
13609
 
13594
13610
  function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets, warn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
13595
13611
  const { _, cnst, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
13596
- const isNamespaced = name && name.indexOf('.') !== -1;
13612
+ const isNamespaced = name && name.includes('.');
13597
13613
  const useVariableAssignment = !extend && !isNamespaced;
13598
13614
  if (name && useVariableAssignment && !isLegal(name)) {
13599
13615
  return error({
@@ -13643,7 +13659,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
13643
13659
  wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`;
13644
13660
  }
13645
13661
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13646
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
13662
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
13647
13663
  if (namespaceMarkers) {
13648
13664
  namespaceMarkers = n + n + namespaceMarkers;
13649
13665
  }
@@ -13877,7 +13893,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13877
13893
  const wrapperOutro = n + n + '}));';
13878
13894
  magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
13879
13895
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13880
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
13896
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
13881
13897
  if (namespaceMarkers) {
13882
13898
  namespaceMarkers = n + n + namespaceMarkers;
13883
13899
  }
@@ -13905,6 +13921,7 @@ class Link {
13905
13921
  }
13906
13922
  traceMappings() {
13907
13923
  const sources = [];
13924
+ const sourceIndexMap = new Map();
13908
13925
  const sourcesContent = [];
13909
13926
  const names = [];
13910
13927
  const nameIndexMap = new Map();
@@ -13912,41 +13929,36 @@ class Link {
13912
13929
  for (const line of this.mappings) {
13913
13930
  const tracedLine = [];
13914
13931
  for (const segment of line) {
13915
- if (segment.length == 1)
13932
+ if (segment.length === 1)
13916
13933
  continue;
13917
13934
  const source = this.sources[segment[1]];
13918
13935
  if (!source)
13919
13936
  continue;
13920
13937
  const traced = source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : '');
13921
13938
  if (traced) {
13922
- // newer sources are more likely to be used, so search backwards.
13923
- let sourceIndex = sources.lastIndexOf(traced.source.filename);
13924
- if (sourceIndex === -1) {
13939
+ const { column, line, name, source: { content, filename } } = traced;
13940
+ let sourceIndex = sourceIndexMap.get(filename);
13941
+ if (sourceIndex === undefined) {
13925
13942
  sourceIndex = sources.length;
13926
- sources.push(traced.source.filename);
13927
- sourcesContent[sourceIndex] = traced.source.content;
13943
+ sources.push(filename);
13944
+ sourceIndexMap.set(filename, sourceIndex);
13945
+ sourcesContent[sourceIndex] = content;
13928
13946
  }
13929
13947
  else if (sourcesContent[sourceIndex] == null) {
13930
- sourcesContent[sourceIndex] = traced.source.content;
13948
+ sourcesContent[sourceIndex] = content;
13931
13949
  }
13932
- else if (traced.source.content != null &&
13933
- sourcesContent[sourceIndex] !== traced.source.content) {
13950
+ else if (content != null && sourcesContent[sourceIndex] !== content) {
13934
13951
  return error({
13935
- message: `Multiple conflicting contents for sourcemap source ${traced.source.filename}`
13952
+ message: `Multiple conflicting contents for sourcemap source ${filename}`
13936
13953
  });
13937
13954
  }
13938
- const tracedSegment = [
13939
- segment[0],
13940
- sourceIndex,
13941
- traced.line,
13942
- traced.column
13943
- ];
13944
- if (traced.name) {
13945
- let nameIndex = nameIndexMap.get(traced.name);
13955
+ const tracedSegment = [segment[0], sourceIndex, line, column];
13956
+ if (name) {
13957
+ let nameIndex = nameIndexMap.get(name);
13946
13958
  if (nameIndex === undefined) {
13947
13959
  nameIndex = names.length;
13948
- names.push(traced.name);
13949
- nameIndexMap.set(traced.name, nameIndex);
13960
+ names.push(name);
13961
+ nameIndexMap.set(name, nameIndex);
13950
13962
  }
13951
13963
  tracedSegment[4] = nameIndex;
13952
13964
  }
@@ -13962,12 +13974,15 @@ class Link {
13962
13974
  if (!segments)
13963
13975
  return null;
13964
13976
  // binary search through segments for the given column
13965
- let i = 0;
13966
- let j = segments.length - 1;
13967
- while (i <= j) {
13968
- const m = (i + j) >> 1;
13977
+ let searchStart = 0;
13978
+ let searchEnd = segments.length - 1;
13979
+ while (searchStart <= searchEnd) {
13980
+ const m = (searchStart + searchEnd) >> 1;
13969
13981
  const segment = segments[m];
13970
- if (segment[0] === column) {
13982
+ // If a sourcemap does not have sufficient resolution to contain a
13983
+ // necessary mapping, e.g. because it only contains line information, we
13984
+ // use the best approximation we could find
13985
+ if (segment[0] === column || searchStart === searchEnd) {
13971
13986
  if (segment.length == 1)
13972
13987
  return null;
13973
13988
  const source = this.sources[segment[1]];
@@ -13976,10 +13991,10 @@ class Link {
13976
13991
  return source.traceSegment(segment[2], segment[3], segment.length === 5 ? this.names[segment[4]] : name);
13977
13992
  }
13978
13993
  if (segment[0] > column) {
13979
- j = m - 1;
13994
+ searchEnd = m - 1;
13980
13995
  }
13981
13996
  else {
13982
- i = m + 1;
13997
+ searchStart = m + 1;
13983
13998
  }
13984
13999
  }
13985
14000
  return null;
@@ -14224,7 +14239,7 @@ function getExportMode(chunk, { exports: exportMode, name, format }, unsetOption
14224
14239
  exportMode = 'default';
14225
14240
  }
14226
14241
  else {
14227
- if (format !== 'es' && format !== 'system' && exportKeys.indexOf('default') !== -1) {
14242
+ if (format !== 'es' && format !== 'system' && exportKeys.includes('default')) {
14228
14243
  warn(errMixedExport(facadeModuleId, name));
14229
14244
  }
14230
14245
  exportMode = 'named';
@@ -14357,7 +14372,7 @@ function makeUnique(name, existingNames) {
14357
14372
  if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
14358
14373
  return name;
14359
14374
  const ext = require$$0.extname(name);
14360
- name = name.substr(0, name.length - ext.length);
14375
+ name = name.substring(0, name.length - ext.length);
14361
14376
  let uniqueName, uniqueIndex = 1;
14362
14377
  while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
14363
14378
  ;
@@ -14523,7 +14538,7 @@ class Chunk {
14523
14538
  var _a;
14524
14539
  const facades = [];
14525
14540
  const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]);
14526
- const exposedVariables = new Set(this.dynamicEntryModules.map(module => module.namespace));
14541
+ const exposedVariables = new Set(this.dynamicEntryModules.map(({ namespace }) => namespace));
14527
14542
  for (const module of entryModules) {
14528
14543
  if (module.preserveSignature) {
14529
14544
  for (const exportedVariable of module.getExportNamesByVariable().keys()) {
@@ -14532,7 +14547,9 @@ class Chunk {
14532
14547
  }
14533
14548
  }
14534
14549
  for (const module of entryModules) {
14535
- const requiredFacades = Array.from(new Set(module.chunkNames.filter(({ isUserDefined }) => isUserDefined).map(({ name }) => name)), name => ({
14550
+ const requiredFacades = Array.from(new Set(module.chunkNames.filter(({ isUserDefined }) => isUserDefined).map(({ name }) => name)),
14551
+ // mapping must run after Set 'name' dedupe
14552
+ name => ({
14536
14553
  name
14537
14554
  }));
14538
14555
  if (requiredFacades.length === 0 && module.isUserDefinedEntryPoint) {
@@ -14610,7 +14627,7 @@ class Chunk {
14610
14627
  const extension = require$$0.extname(sanitizedId);
14611
14628
  const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
14612
14629
  assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
14613
- ext: () => extension.substr(1),
14630
+ ext: () => extension.substring(1),
14614
14631
  extname: () => extension,
14615
14632
  format: () => options.format,
14616
14633
  name: () => this.getChunkName()
@@ -14628,7 +14645,7 @@ class Chunk {
14628
14645
  const extension = require$$0.extname(sanitizedId);
14629
14646
  const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
14630
14647
  assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
14631
- ext: () => extension.substr(1),
14648
+ ext: () => extension.substring(1),
14632
14649
  extname: () => extension,
14633
14650
  format: () => options.format,
14634
14651
  name: () => getAliasName(sanitizedId)
@@ -14742,7 +14759,7 @@ class Chunk {
14742
14759
  const source = module.render(renderOptions).trim();
14743
14760
  renderedLength = source.length();
14744
14761
  if (renderedLength) {
14745
- if (options.compact && source.lastLine().indexOf('//') !== -1)
14762
+ if (options.compact && source.lastLine().includes('//'))
14746
14763
  source.append('\n');
14747
14764
  this.renderedModuleSources.set(module, source);
14748
14765
  magicString.addSource(source);
@@ -14810,22 +14827,24 @@ class Chunk {
14810
14827
  const renderedDependency = this.renderedDependencies.get(dependency);
14811
14828
  if (dependency instanceof ExternalModule) {
14812
14829
  const originalId = dependency.renderPath;
14813
- renderedDependency.id = escapeId(dependency.renormalizeRenderPath ? this.getRelativePath(originalId, false) : originalId);
14830
+ renderedDependency.id = escapeId(dependency.renormalizeRenderPath
14831
+ ? getImportPath(this.id, originalId, false, false)
14832
+ : originalId);
14814
14833
  }
14815
14834
  else {
14816
14835
  renderedDependency.namedExportsMode = dependency.exportMode !== 'default';
14817
- renderedDependency.id = escapeId(this.getRelativePath(dependency.id, false));
14836
+ renderedDependency.id = escapeId(getImportPath(this.id, dependency.id, false, true));
14818
14837
  }
14819
14838
  }
14820
14839
  this.finaliseDynamicImports(options, snippets);
14821
14840
  this.finaliseImportMetas(format, snippets);
14822
14841
  const hasExports = this.renderedExports.length !== 0 ||
14823
14842
  [...this.renderedDependencies.values()].some(dep => (dep.reexports && dep.reexports.length !== 0));
14824
- let usesTopLevelAwait = false;
14843
+ let topLevelAwaitModule = null;
14825
14844
  const accessedGlobals = new Set();
14826
14845
  for (const module of this.orderedModules) {
14827
14846
  if (module.usesTopLevelAwait) {
14828
- usesTopLevelAwait = true;
14847
+ topLevelAwaitModule = module.id;
14829
14848
  }
14830
14849
  const accessedGlobalVariables = this.accessedGlobalsByScope.get(module.scope);
14831
14850
  if (accessedGlobalVariables) {
@@ -14834,9 +14853,10 @@ class Chunk {
14834
14853
  }
14835
14854
  }
14836
14855
  }
14837
- if (usesTopLevelAwait && format !== 'es' && format !== 'system') {
14856
+ if (topLevelAwaitModule !== null && format !== 'es' && format !== 'system') {
14838
14857
  return error({
14839
14858
  code: 'INVALID_TLA_FORMAT',
14859
+ id: topLevelAwaitModule,
14840
14860
  message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
14841
14861
  });
14842
14862
  }
@@ -14858,7 +14878,7 @@ class Chunk {
14858
14878
  namedExportsMode: this.exportMode !== 'default',
14859
14879
  outro: addons.outro,
14860
14880
  snippets,
14861
- usesTopLevelAwait,
14881
+ usesTopLevelAwait: topLevelAwaitModule !== null,
14862
14882
  warn: this.inputOptions.onwarn
14863
14883
  }, options);
14864
14884
  if (addons.banner)
@@ -14997,10 +15017,10 @@ class Chunk {
14997
15017
  continue;
14998
15018
  }
14999
15019
  const renderedResolution = resolution instanceof Module
15000
- ? `'${escapeId(this.getRelativePath((facadeChunk || chunk).id, stripKnownJsExtensions))}'`
15020
+ ? `'${escapeId(getImportPath(this.id, (facadeChunk || chunk).id, stripKnownJsExtensions, true))}'`
15001
15021
  : resolution instanceof ExternalModule
15002
15022
  ? `'${escapeId(resolution.renormalizeRenderPath
15003
- ? this.getRelativePath(resolution.renderPath, stripKnownJsExtensions)
15023
+ ? getImportPath(this.id, resolution.renderPath, stripKnownJsExtensions, false)
15004
15024
  : resolution.renderPath)}'`
15005
15025
  : resolution;
15006
15026
  node.renderFinalResolution(code, renderedResolution, resolution instanceof Module &&
@@ -15197,7 +15217,7 @@ class Chunk {
15197
15217
  let imported;
15198
15218
  let needsLiveBinding = false;
15199
15219
  if (exportName[0] === '*') {
15200
- const id = exportName.substr(1);
15220
+ const id = exportName.substring(1);
15201
15221
  if (interop(id) === 'defaultOnly') {
15202
15222
  this.inputOptions.onwarn(errUnexpectedNamespaceReexport(id));
15203
15223
  }
@@ -15248,17 +15268,6 @@ class Chunk {
15248
15268
  }
15249
15269
  return referencedFiles;
15250
15270
  }
15251
- getRelativePath(targetPath, stripJsExtension) {
15252
- let relativePath = normalize(relative(require$$0.dirname(this.id), targetPath));
15253
- if (stripJsExtension && relativePath.endsWith('.js')) {
15254
- relativePath = relativePath.slice(0, -3);
15255
- }
15256
- if (relativePath === '..')
15257
- return '../../' + require$$0.basename(targetPath);
15258
- if (relativePath === '')
15259
- return '../' + require$$0.basename(targetPath);
15260
- return relativePath.startsWith('../') ? relativePath : './' + relativePath;
15261
- }
15262
15271
  inlineChunkDependencies(chunk) {
15263
15272
  for (const dep of chunk.dependencies) {
15264
15273
  if (this.dependencies.has(dep))
@@ -15407,16 +15416,17 @@ function generateAssetFileName(name, source, outputOptions, bundle) {
15407
15416
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
15408
15417
  ? outputOptions.assetFileNames({ name, source, type: 'asset' })
15409
15418
  : outputOptions.assetFileNames, 'output.assetFileNames', {
15410
- ext: () => require$$0.extname(emittedName).substr(1),
15419
+ ext: () => require$$0.extname(emittedName).substring(1),
15411
15420
  extname: () => require$$0.extname(emittedName),
15412
15421
  hash() {
15413
- const hash = createHash();
15414
- hash.update(emittedName);
15415
- hash.update(':');
15416
- hash.update(source);
15417
- return hash.digest('hex').substr(0, 8);
15422
+ return createHash()
15423
+ .update(emittedName)
15424
+ .update(':')
15425
+ .update(source)
15426
+ .digest('hex')
15427
+ .substring(0, 8);
15418
15428
  },
15419
- name: () => emittedName.substr(0, emittedName.length - require$$0.extname(emittedName).length)
15429
+ name: () => emittedName.substring(0, emittedName.length - require$$0.extname(emittedName).length)
15420
15430
  }), bundle);
15421
15431
  }
15422
15432
  function reserveFileNameInBundle(fileName, bundle, warn) {
@@ -15465,7 +15475,7 @@ class FileEmitter {
15465
15475
  this.facadeChunkByModule = null;
15466
15476
  this.outputOptions = null;
15467
15477
  this.assertAssetsFinalized = () => {
15468
- for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) {
15478
+ for (const [referenceId, emittedFile] of this.filesByReferenceId) {
15469
15479
  if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
15470
15480
  return error(errNoAssetSourceSet(emittedFile.name || referenceId));
15471
15481
  }
@@ -15480,9 +15490,7 @@ class FileEmitter {
15480
15490
  if (emittedFile.type === 'chunk') {
15481
15491
  return this.emitChunk(emittedFile);
15482
15492
  }
15483
- else {
15484
- return this.emitAsset(emittedFile);
15485
- }
15493
+ return this.emitAsset(emittedFile);
15486
15494
  };
15487
15495
  this.getFileName = (fileReferenceId) => {
15488
15496
  const emittedFile = this.filesByReferenceId.get(fileReferenceId);
@@ -15491,9 +15499,7 @@ class FileEmitter {
15491
15499
  if (emittedFile.type === 'chunk') {
15492
15500
  return getChunkFileName(emittedFile, this.facadeChunkByModule);
15493
15501
  }
15494
- else {
15495
- return getAssetFileName(emittedFile, fileReferenceId);
15496
- }
15502
+ return getAssetFileName(emittedFile, fileReferenceId);
15497
15503
  };
15498
15504
  this.setAssetSource = (referenceId, requestedSource) => {
15499
15505
  const consumedFile = this.filesByReferenceId.get(referenceId);
@@ -15522,7 +15528,7 @@ class FileEmitter {
15522
15528
  reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
15523
15529
  }
15524
15530
  }
15525
- for (const [referenceId, consumedFile] of this.filesByReferenceId.entries()) {
15531
+ for (const [referenceId, consumedFile] of this.filesByReferenceId) {
15526
15532
  if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
15527
15533
  this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
15528
15534
  }
@@ -15535,14 +15541,10 @@ class FileEmitter {
15535
15541
  assignReferenceId(file, idBase) {
15536
15542
  let referenceId;
15537
15543
  do {
15538
- const hash = createHash();
15539
- if (referenceId) {
15540
- hash.update(referenceId);
15541
- }
15542
- else {
15543
- hash.update(idBase);
15544
- }
15545
- referenceId = hash.digest('hex').substr(0, 8);
15544
+ referenceId = createHash()
15545
+ .update(referenceId || idBase)
15546
+ .digest('hex')
15547
+ .substring(0, 8);
15546
15548
  } while (this.filesByReferenceId.has(referenceId));
15547
15549
  this.filesByReferenceId.set(referenceId, file);
15548
15550
  return referenceId;
@@ -16066,7 +16068,7 @@ class Bundle {
16066
16068
  warnDeprecation('A plugin is directly adding properties to the bundle object in the "generateBundle" hook. This is deprecated and will be removed in a future Rollup version, please use "this.emitFile" instead.', true, this.inputOptions);
16067
16069
  file.type = 'asset';
16068
16070
  }
16069
- if (this.outputOptions.validate && typeof file.code == 'string') {
16071
+ if (this.outputOptions.validate && 'code' in file) {
16070
16072
  try {
16071
16073
  this.graph.contextParse(file.code, {
16072
16074
  allowHashBang: true,
@@ -22178,6 +22180,7 @@ class ModuleLoader {
22178
22180
  id: cachedModule.id,
22179
22181
  meta: cachedModule.meta,
22180
22182
  moduleSideEffects: cachedModule.moduleSideEffects,
22183
+ resolvedSources: cachedModule.resolvedIds,
22181
22184
  syntheticNamedExports: cachedModule.syntheticNamedExports
22182
22185
  }
22183
22186
  ]))) {
@@ -22282,9 +22285,7 @@ class ModuleLoader {
22282
22285
  }
22283
22286
  return Promise.resolve(externalModule);
22284
22287
  }
22285
- else {
22286
- return this.fetchModule(resolvedId, importer, false, false);
22287
- }
22288
+ return this.fetchModule(resolvedId, importer, false, false);
22288
22289
  }
22289
22290
  async fetchStaticDependencies(module, resolveStaticDependencyPromises) {
22290
22291
  for (const dependency of await Promise.all(resolveStaticDependencyPromises.map(resolveStaticDependencyPromise => resolveStaticDependencyPromise.then(([source, resolvedId]) => this.fetchResolvedDependency(source, module.id, resolvedId))))) {
@@ -22422,6 +22423,8 @@ class ModuleLoader {
22422
22423
  : { id: resolveIdResult }), undefined, isEntry, false);
22423
22424
  }
22424
22425
  async resolveDynamicImport(module, specifier, importer) {
22426
+ var _a;
22427
+ var _b;
22425
22428
  const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
22426
22429
  specifier,
22427
22430
  importer
@@ -22440,9 +22443,7 @@ class ModuleLoader {
22440
22443
  };
22441
22444
  }
22442
22445
  if (resolution == null) {
22443
- return (module.resolvedIds[specifier] =
22444
- module.resolvedIds[specifier] ||
22445
- this.handleResolveId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false), specifier, module.id));
22446
+ 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)));
22446
22447
  }
22447
22448
  return this.handleResolveId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier)), specifier, importer);
22448
22449
  }
@@ -22493,7 +22494,6 @@ class GlobalScope extends Scope$1 {
22493
22494
  }
22494
22495
  }
22495
22496
 
22496
- // eslint-disable-next-line @typescript-eslint/ban-types
22497
22497
  function getDeprecatedContextHandler(handler, handlerName, newHandlerName, pluginName, activeDeprecation, options) {
22498
22498
  let deprecationWarningShown = false;
22499
22499
  return ((...args) => {
@@ -22599,24 +22599,19 @@ function resolveAction(actionTuple) {
22599
22599
  unfulfilledActions.delete(actionTuple);
22600
22600
  }
22601
22601
  function formatAction([pluginName, hookName, args]) {
22602
- let action = `(${pluginName}) ${hookName}`;
22602
+ const action = `(${pluginName}) ${hookName}`;
22603
22603
  const s = JSON.stringify;
22604
22604
  switch (hookName) {
22605
22605
  case 'resolveId':
22606
- action += ` ${s(args[0])} ${s(args[1])}`;
22607
- break;
22606
+ return `${action} ${s(args[0])} ${s(args[1])}`;
22608
22607
  case 'load':
22609
- action += ` ${s(args[0])}`;
22610
- break;
22608
+ return `${action} ${s(args[0])}`;
22611
22609
  case 'transform':
22612
- action += ` ${s(args[1])}`;
22613
- break;
22610
+ return `${action} ${s(args[1])}`;
22614
22611
  case 'shouldTransformCachedModule':
22615
- action += ` ${s(args[0].id)}`;
22616
- break;
22612
+ return `${action} ${s(args[0].id)}`;
22617
22613
  case 'moduleParsed':
22618
- action += ` ${s(args[0].id)}`;
22619
- break;
22614
+ return `${action} ${s(args[0].id)}`;
22620
22615
  }
22621
22616
  return action;
22622
22617
  }
@@ -23272,6 +23267,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23272
23267
  const preserveModules = getPreserveModules(config, inlineDynamicImports, inputOptions);
23273
23268
  const file = getFile(config, preserveModules, inputOptions);
23274
23269
  const preferConst = getPreferConst(config, inputOptions);
23270
+ const generatedCode = getGeneratedCode(config, preferConst);
23275
23271
  const outputOptions = {
23276
23272
  amd: getAmd(config),
23277
23273
  assetFileNames: (_a = config.assetFileNames) !== null && _a !== void 0 ? _a : 'assets/[name]-[hash][extname]',
@@ -23289,7 +23285,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23289
23285
  footer: getAddon(config, 'footer'),
23290
23286
  format,
23291
23287
  freeze: (_e = config.freeze) !== null && _e !== void 0 ? _e : true,
23292
- generatedCode: getGeneratedCode(config, preferConst),
23288
+ generatedCode,
23293
23289
  globals: config.globals || {},
23294
23290
  hoistTransitiveImports: (_f = config.hoistTransitiveImports) !== null && _f !== void 0 ? _f : true,
23295
23291
  indent: getIndent(config, compact),
@@ -23299,7 +23295,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23299
23295
  manualChunks: getManualChunks(config, inlineDynamicImports, preserveModules, inputOptions),
23300
23296
  minifyInternalExports: getMinifyInternalExports(config, format, compact),
23301
23297
  name: config.name,
23302
- namespaceToStringTag: config.namespaceToStringTag || false,
23298
+ namespaceToStringTag: getNamespaceToStringTag(config, generatedCode, inputOptions),
23303
23299
  noConflict: config.noConflict || false,
23304
23300
  outro: getAddon(config, 'outro'),
23305
23301
  paths: config.paths || {},
@@ -23469,7 +23465,8 @@ const getGeneratedCode = (config, preferConst) => {
23469
23465
  arrowFunctions: configWithPreset.arrowFunctions === true,
23470
23466
  constBindings: configWithPreset.constBindings === true || preferConst,
23471
23467
  objectShorthand: configWithPreset.objectShorthand === true,
23472
- reservedNamesAsProps: configWithPreset.reservedNamesAsProps === true
23468
+ reservedNamesAsProps: configWithPreset.reservedNamesAsProps === true,
23469
+ symbols: configWithPreset.symbols === true
23473
23470
  };
23474
23471
  };
23475
23472
  const getIndent = (config, compact) => {
@@ -23494,7 +23491,7 @@ const getInterop = (config, inputOptions) => {
23494
23491
  if (!validatedInteropTypes.has(interop)) {
23495
23492
  validatedInteropTypes.add(interop);
23496
23493
  if (!ALLOWED_INTEROP_TYPES.has(interop)) {
23497
- return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES.values(), value => JSON.stringify(value)).join(', ')}`, interop));
23494
+ return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
23498
23495
  }
23499
23496
  if (typeof interop === 'boolean') {
23500
23497
  warnDeprecation({
@@ -23529,6 +23526,14 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
23529
23526
  return configManualChunks || {};
23530
23527
  };
23531
23528
  const getMinifyInternalExports = (config, format, compact) => { var _a; return (_a = config.minifyInternalExports) !== null && _a !== void 0 ? _a : (compact || format === 'es' || format === 'system'); };
23529
+ const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
23530
+ const configNamespaceToStringTag = config.namespaceToStringTag;
23531
+ if (configNamespaceToStringTag != null) {
23532
+ warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`, false, inputOptions);
23533
+ return configNamespaceToStringTag;
23534
+ }
23535
+ return generatedCode.symbols || false;
23536
+ };
23532
23537
 
23533
23538
  function rollup(rawInputOptions) {
23534
23539
  return rollupInternal(rawInputOptions, null);
@@ -23600,12 +23605,11 @@ function applyOptionHook(watchMode) {
23600
23605
  };
23601
23606
  }
23602
23607
  function normalizePlugins(plugins, anonymousPrefix) {
23603
- for (let pluginIndex = 0; pluginIndex < plugins.length; pluginIndex++) {
23604
- const plugin = plugins[pluginIndex];
23608
+ plugins.forEach((plugin, index) => {
23605
23609
  if (!plugin.name) {
23606
- plugin.name = `${anonymousPrefix}${pluginIndex + 1}`;
23610
+ plugin.name = `${anonymousPrefix}${index + 1}`;
23607
23611
  }
23608
- }
23612
+ });
23609
23613
  }
23610
23614
  async function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutputOptions, graph) {
23611
23615
  const { options: outputOptions, outputPluginDriver, unsetOptions } = getOutputOptionsAndPluginDriver(rawOutputOptions, graph.pluginDriver, inputOptions, unsetInputOptions);