rollup 2.68.0 → 2.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.68.0
4
- Tue, 22 Feb 2022 06:24:42 GMT - commit 51cab92373bcf8c844a8de2a6765869f7eb05a5d
3
+ Rollup.js v2.69.0
4
+ Wed, 02 Mar 2022 13:21:33 GMT - commit 10dc32678944cb276c2efe781b12350a8e0a5adf
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.68.0";
31
+ var version$1 = "2.69.0";
32
32
 
33
33
  function ensureArray$1(items) {
34
34
  if (Array.isArray(items)) {
@@ -127,8 +127,30 @@ function printQuotedStringList(list, verbs) {
127
127
  return output;
128
128
  }
129
129
 
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
+
130
152
  const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
131
- const RELATIVE_PATH_REGEX = /^\.?\.\//;
153
+ const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
132
154
  function isAbsolute(path) {
133
155
  return ABSOLUTE_PATH_REGEX.test(path);
134
156
  }
@@ -142,17 +164,35 @@ function normalize(path) {
142
164
 
143
165
  function getAliasName(id) {
144
166
  const base = require$$0.basename(id);
145
- return base.substr(0, base.length - require$$0.extname(id).length);
167
+ return base.substring(0, base.length - require$$0.extname(id).length);
146
168
  }
147
169
  function relativeId(id) {
148
170
  if (!isAbsolute(id))
149
171
  return id;
150
- return require$$0.relative(require$$0.resolve(), id);
172
+ return relative(require$$0.resolve(), id);
151
173
  }
152
174
  function isPathFragment(name) {
153
175
  // starting with "/", "./", "../", "C:/"
154
176
  return (name[0] === '/' || (name[0] === '.' && (name[1] === '/' || name[1] === '.')) || isAbsolute(name));
155
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
+ }
156
196
 
157
197
  function error(base) {
158
198
  if (!(base instanceof Error))
@@ -546,13 +586,15 @@ const generatedCodePresets = {
546
586
  arrowFunctions: true,
547
587
  constBindings: true,
548
588
  objectShorthand: true,
549
- reservedNamesAsProps: true
589
+ reservedNamesAsProps: true,
590
+ symbols: true
550
591
  },
551
592
  es5: {
552
593
  arrowFunctions: false,
553
594
  constBindings: false,
554
595
  objectShorthand: false,
555
- reservedNamesAsProps: true
596
+ reservedNamesAsProps: true,
597
+ symbols: false
556
598
  }
557
599
  };
558
600
  const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
@@ -599,11 +641,11 @@ function getFsEvents() {
599
641
  return fsEvents;
600
642
  }
601
643
 
602
- const fseventsImporter = {
644
+ const fseventsImporter = /*#__PURE__*/Object.defineProperty({
603
645
  __proto__: null,
604
646
  loadFsEvents,
605
647
  getFsEvents
606
- };
648
+ }, Symbol.toStringTag, { value: 'Module' });
607
649
 
608
650
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
609
651
 
@@ -2049,28 +2091,6 @@ Bundle$1.prototype.trimEnd = function trimEnd (charType) {
2049
2091
 
2050
2092
  const MagicString$1 = MagicString;
2051
2093
 
2052
- const ANY_SLASH_REGEX = /[/\\]/;
2053
- function relative(from, to) {
2054
- const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);
2055
- const toParts = to.split(ANY_SLASH_REGEX).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) {
@@ -2391,7 +2411,6 @@ class ExternalModule {
2391
2411
  ? normalize(require$$0.relative(inputBase, this.id))
2392
2412
  : this.id;
2393
2413
  }
2394
- return this.renderPath;
2395
2414
  }
2396
2415
  suggestName(name) {
2397
2416
  var _a;
@@ -4793,9 +4812,8 @@ function getLiteralMembersForValue(value) {
4793
4812
  return literalNumberMembers;
4794
4813
  case 'string':
4795
4814
  return literalStringMembers;
4796
- default:
4797
- return Object.create(null);
4798
4815
  }
4816
+ return Object.create(null);
4799
4817
  }
4800
4818
  function hasMemberEffectWhenCalled(members, memberName, callOptions, context) {
4801
4819
  if (typeof memberName !== 'string' || !members[memberName]) {
@@ -10131,19 +10149,17 @@ const HELPER_GENERATORS = {
10131
10149
  return (`${left}e${_}&&${_}e.__esModule${_}?${_}` +
10132
10150
  `${liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets)}${right}${n}${n}`);
10133
10151
  },
10134
- [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;
10135
10154
  const [left, right] = getDirectReturnFunction(['e'], {
10136
10155
  functionReturn: true,
10137
10156
  lineBreakIndent: null,
10138
10157
  name: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE
10139
10158
  });
10140
- return `${left}${getFrozen(getObject([
10159
+ return `${left}${getFrozen(freeze, getWithToStringTag(namespaceToStringTag, getObject([
10141
10160
  ['__proto__', 'null'],
10142
- ...(namespaceToStringTag
10143
- ? [[null, `[Symbol.toStringTag]:${_}'Module'`]]
10144
- : []),
10145
10161
  ['default', 'e']
10146
- ], { lineBreakIndent: null }), freeze)}${right}${n}${n}`;
10162
+ ], { lineBreakIndent: null }), snippets))}${right}${n}${n}`;
10147
10163
  },
10148
10164
  [INTEROP_NAMESPACE_DEFAULT_VARIABLE](t, snippets, liveBindings, freeze, namespaceToStringTag) {
10149
10165
  const { _, n } = snippets;
@@ -10166,7 +10182,7 @@ const HELPER_GENERATORS = {
10166
10182
  createNamespaceObject(t, t, snippets, liveBindings, freeze, namespaceToStringTag) +
10167
10183
  `}${n}${n}`);
10168
10184
  },
10169
- [MERGE_NAMESPACES_VARIABLE](t, snippets, liveBindings, freeze) {
10185
+ [MERGE_NAMESPACES_VARIABLE](t, snippets, liveBindings, freeze, namespaceToStringTag) {
10170
10186
  const { _, cnst, n } = snippets;
10171
10187
  const useForEach = cnst === 'var' && liveBindings;
10172
10188
  return (`function ${MERGE_NAMESPACES_VARIABLE}(n, m)${_}{${n}` +
@@ -10179,25 +10195,25 @@ const HELPER_GENERATORS = {
10179
10195
  : copyPropertyStatic)(t, t + t + t + t, snippets) +
10180
10196
  `${t}${t}${t}}${n}` +
10181
10197
  `${t}${t}}`, useForEach, t, snippets)}${n}` +
10182
- `${t}return ${getFrozen('n', freeze)};${n}` +
10198
+ `${t}return ${getFrozen(freeze, getWithToStringTag(namespaceToStringTag, 'n', snippets))};${n}` +
10183
10199
  `}${n}${n}`);
10184
10200
  }
10185
10201
  };
10186
10202
  const getDefaultLiveBinding = ({ _, getObject }) => `e${_}:${_}${getObject([['default', 'e']], { lineBreakIndent: null })}`;
10187
10203
  const getDefaultStatic = ({ _, getPropertyAccess }) => `e${getPropertyAccess('default')}${_}:${_}e`;
10188
10204
  const createNamespaceObject = (t, i, snippets, liveBindings, freeze, namespaceToStringTag) => {
10189
- const { _, cnst, getPropertyAccess, n, s } = snippets;
10205
+ const { _, cnst, getObject, getPropertyAccess, n, s } = snippets;
10190
10206
  const copyProperty = `{${n}` +
10191
10207
  (liveBindings ? copyNonDefaultOwnPropertyLiveBinding : copyPropertyStatic)(t, i + t + t, snippets) +
10192
10208
  `${i}${t}}`;
10193
- return (`${i}${cnst} n${_}=${_}${namespaceToStringTag
10194
- ? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}`
10195
- : 'Object.create(null)'};${n}` +
10209
+ return (`${i}${cnst} n${_}=${_}Object.create(null${namespaceToStringTag
10210
+ ? `,${_}{${_}[Symbol.toStringTag]:${_}${getToStringTagValue(getObject)}${_}}`
10211
+ : ''});${n}` +
10196
10212
  `${i}if${_}(e)${_}{${n}` +
10197
10213
  `${i}${t}${loopOverKeys(copyProperty, !liveBindings, snippets)}${n}` +
10198
10214
  `${i}}${n}` +
10199
10215
  `${i}n${getPropertyAccess('default')}${_}=${_}e;${n}` +
10200
- `${i}return ${getFrozen('n', freeze)}${s}${n}`);
10216
+ `${i}return ${getFrozen(freeze, 'n')}${s}${n}`);
10201
10217
  };
10202
10218
  const loopOverKeys = (body, allowVarLoopVariable, { _, cnst, getFunctionIntro, s }) => cnst !== 'var' || allowVarLoopVariable
10203
10219
  ? `for${_}(${cnst} k in e)${_}${body}`
@@ -10255,8 +10271,16 @@ const copyPropertyLiveBinding = (t, i, { _, cnst, getDirectReturnFunction, n })
10255
10271
  `${i}}${n}`);
10256
10272
  };
10257
10273
  const copyPropertyStatic = (_t, i, { _, n }) => `${i}n[k]${_}=${_}e[k];${n}`;
10258
- 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;
10259
10278
  const HELPER_NAMES = Object.keys(HELPER_GENERATORS);
10279
+ function getToStringTagValue(getObject) {
10280
+ return getObject([['value', "'Module'"]], {
10281
+ lineBreakIndent: null
10282
+ });
10283
+ }
10260
10284
 
10261
10285
  class ImportExpression extends NodeBase {
10262
10286
  constructor() {
@@ -10633,7 +10657,7 @@ class MetaProperty extends NodeBase {
10633
10657
  getReferencedFileName(outputPluginDriver) {
10634
10658
  const metaProperty = this.metaProperty;
10635
10659
  if (metaProperty && metaProperty.startsWith(FILE_PREFIX)) {
10636
- return outputPluginDriver.getFileName(metaProperty.substr(FILE_PREFIX.length));
10660
+ return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length));
10637
10661
  }
10638
10662
  return null;
10639
10663
  }
@@ -10669,17 +10693,17 @@ class MetaProperty extends NodeBase {
10669
10693
  let chunkReferenceId = null;
10670
10694
  let fileName;
10671
10695
  if (metaProperty.startsWith(FILE_PREFIX)) {
10672
- referenceId = metaProperty.substr(FILE_PREFIX.length);
10696
+ referenceId = metaProperty.substring(FILE_PREFIX.length);
10673
10697
  fileName = outputPluginDriver.getFileName(referenceId);
10674
10698
  }
10675
10699
  else if (metaProperty.startsWith(ASSET_PREFIX)) {
10676
10700
  warnDeprecation(`Using the "${ASSET_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
10677
- assetReferenceId = metaProperty.substr(ASSET_PREFIX.length);
10701
+ assetReferenceId = metaProperty.substring(ASSET_PREFIX.length);
10678
10702
  fileName = outputPluginDriver.getFileName(assetReferenceId);
10679
10703
  }
10680
10704
  else {
10681
10705
  warnDeprecation(`Using the "${CHUNK_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, true, this.context.options);
10682
- chunkReferenceId = metaProperty.substr(CHUNK_PREFIX.length);
10706
+ chunkReferenceId = metaProperty.substring(CHUNK_PREFIX.length);
10683
10707
  fileName = outputPluginDriver.getFileName(chunkReferenceId);
10684
10708
  }
10685
10709
  const relativePath = normalize(require$$0.relative(require$$0.dirname(chunkId), fileName));
@@ -12035,17 +12059,20 @@ class NamespaceVariable extends Variable {
12035
12059
  }
12036
12060
  return [name, original.getName(getPropertyAccess)];
12037
12061
  });
12038
- if (namespaceToStringTag) {
12039
- members.unshift([null, `[Symbol.toStringTag]:${_}'Module'`]);
12040
- }
12041
12062
  members.unshift([null, `__proto__:${_}null`]);
12042
12063
  let output = getObject(members, { lineBreakIndent: { base: '', t } });
12043
12064
  if (this.mergedNamespaces.length > 0) {
12044
12065
  const assignmentArgs = this.mergedNamespaces.map(variable => variable.getName(getPropertyAccess));
12045
- output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output}, [${assignmentArgs.join(`,${_}`)}])`;
12066
+ output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output},${_}[${assignmentArgs.join(`,${_}`)}])`;
12046
12067
  }
12047
- if (freeze) {
12048
- 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
+ }
12049
12076
  }
12050
12077
  const name = this.getName(getPropertyAccess);
12051
12078
  output = `${cnst} ${name}${_}=${_}${output};`;
@@ -12355,7 +12382,7 @@ class Module {
12355
12382
  this.preserveSignature = this.options.preserveEntrySignatures;
12356
12383
  // eslint-disable-next-line @typescript-eslint/no-this-alias
12357
12384
  const module = this;
12358
- const { dynamicImports, dynamicImporters, reexportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, sources, importers } = this;
12385
+ const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sources } = this;
12359
12386
  this.info = {
12360
12387
  ast: null,
12361
12388
  code: null,
@@ -12367,13 +12394,7 @@ class Module {
12367
12394
  get dynamicallyImportedIds() {
12368
12395
  // We cannot use this.dynamicDependencies because this is needed before
12369
12396
  // dynamicDependencies are populated
12370
- const dynamicallyImportedIds = [];
12371
- for (const { id } of dynamicImports) {
12372
- if (id) {
12373
- dynamicallyImportedIds.push(id);
12374
- }
12375
- }
12376
- return dynamicallyImportedIds;
12397
+ return dynamicImports.map(({ id }) => id).filter((id) => id != null);
12377
12398
  },
12378
12399
  get dynamicImporters() {
12379
12400
  return dynamicImporters.sort();
@@ -12387,7 +12408,7 @@ class Module {
12387
12408
  },
12388
12409
  get hasModuleSideEffects() {
12389
12410
  warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', false, options);
12390
- return module.info.moduleSideEffects;
12411
+ return this.moduleSideEffects;
12391
12412
  },
12392
12413
  id,
12393
12414
  get implicitlyLoadedAfterOneOf() {
@@ -13222,26 +13243,29 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
13222
13243
  }
13223
13244
  return `${moduleVariableName}${getPropertyAccess(imported)}`;
13224
13245
  }
13225
- function getEsModuleExport(_) {
13226
- return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`;
13227
- }
13228
- function getNamespaceToStringExport(_) {
13229
- return `exports[Symbol.toStringTag]${_}=${_}'Module';`;
13246
+ function getEsModuleValue(getObject) {
13247
+ return getObject([['value', 'true']], {
13248
+ lineBreakIndent: null
13249
+ });
13230
13250
  }
13231
- function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, _, n) {
13232
- let namespaceMarkers = '';
13251
+ function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringTag, { _, getObject }) {
13233
13252
  if (hasNamedExports) {
13234
13253
  if (addEsModule) {
13235
- namespaceMarkers += getEsModuleExport(_);
13254
+ if (addNamespaceToStringTag) {
13255
+ return `Object.defineProperties(exports,${_}${getObject([
13256
+ ['__esModule', getEsModuleValue(getObject)],
13257
+ [null, `[Symbol.toStringTag]:${_}${getToStringTagValue(getObject)}`]
13258
+ ], {
13259
+ lineBreakIndent: null
13260
+ })});`;
13261
+ }
13262
+ return `Object.defineProperty(exports,${_}'__esModule',${_}${getEsModuleValue(getObject)});`;
13236
13263
  }
13237
13264
  if (addNamespaceToStringTag) {
13238
- if (namespaceMarkers) {
13239
- namespaceMarkers += n;
13240
- }
13241
- namespaceMarkers += getNamespaceToStringExport(_);
13265
+ return `Object.defineProperty(exports,${_}Symbol.toStringTag,${_}${getToStringTagValue(getObject)});`;
13242
13266
  }
13243
13267
  }
13244
- return namespaceMarkers;
13268
+ return '';
13245
13269
  }
13246
13270
  const getDefineProperty = (name, needsLiveBinding, t, { _, getDirectReturnFunction, n }) => {
13247
13271
  if (needsLiveBinding) {
@@ -13378,7 +13402,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13378
13402
  const useStrict = strict ? `${_}'use strict';` : '';
13379
13403
  magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
13380
13404
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13381
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
13405
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
13382
13406
  if (namespaceMarkers) {
13383
13407
  namespaceMarkers = n + n + namespaceMarkers;
13384
13408
  }
@@ -13397,7 +13421,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13397
13421
  function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
13398
13422
  const { _, n } = snippets;
13399
13423
  const useStrict = strict ? `'use strict';${n}${n}` : '';
13400
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, _, n);
13424
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
13401
13425
  if (namespaceMarkers) {
13402
13426
  namespaceMarkers += n + n;
13403
13427
  }
@@ -13641,7 +13665,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
13641
13665
  wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`;
13642
13666
  }
13643
13667
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13644
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
13668
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
13645
13669
  if (namespaceMarkers) {
13646
13670
  namespaceMarkers = n + n + namespaceMarkers;
13647
13671
  }
@@ -13875,7 +13899,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13875
13899
  const wrapperOutro = n + n + '}));';
13876
13900
  magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
13877
13901
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13878
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, _, n);
13902
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
13879
13903
  if (namespaceMarkers) {
13880
13904
  namespaceMarkers = n + n + namespaceMarkers;
13881
13905
  }
@@ -14355,7 +14379,7 @@ function makeUnique(name, existingNames) {
14355
14379
  if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
14356
14380
  return name;
14357
14381
  const ext = require$$0.extname(name);
14358
- name = name.substr(0, name.length - ext.length);
14382
+ name = name.substring(0, name.length - ext.length);
14359
14383
  let uniqueName, uniqueIndex = 1;
14360
14384
  while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
14361
14385
  ;
@@ -14521,7 +14545,7 @@ class Chunk {
14521
14545
  var _a;
14522
14546
  const facades = [];
14523
14547
  const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]);
14524
- const exposedVariables = new Set(this.dynamicEntryModules.map(module => module.namespace));
14548
+ const exposedVariables = new Set(this.dynamicEntryModules.map(({ namespace }) => namespace));
14525
14549
  for (const module of entryModules) {
14526
14550
  if (module.preserveSignature) {
14527
14551
  for (const exportedVariable of module.getExportNamesByVariable().keys()) {
@@ -14530,7 +14554,9 @@ class Chunk {
14530
14554
  }
14531
14555
  }
14532
14556
  for (const module of entryModules) {
14533
- const requiredFacades = Array.from(new Set(module.chunkNames.filter(({ isUserDefined }) => isUserDefined).map(({ name }) => name)), name => ({
14557
+ const requiredFacades = Array.from(new Set(module.chunkNames.filter(({ isUserDefined }) => isUserDefined).map(({ name }) => name)),
14558
+ // mapping must run after Set 'name' dedupe
14559
+ name => ({
14534
14560
  name
14535
14561
  }));
14536
14562
  if (requiredFacades.length === 0 && module.isUserDefinedEntryPoint) {
@@ -14608,7 +14634,7 @@ class Chunk {
14608
14634
  const extension = require$$0.extname(sanitizedId);
14609
14635
  const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
14610
14636
  assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
14611
- ext: () => extension.substr(1),
14637
+ ext: () => extension.substring(1),
14612
14638
  extname: () => extension,
14613
14639
  format: () => options.format,
14614
14640
  name: () => this.getChunkName()
@@ -14626,7 +14652,7 @@ class Chunk {
14626
14652
  const extension = require$$0.extname(sanitizedId);
14627
14653
  const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
14628
14654
  assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
14629
- ext: () => extension.substr(1),
14655
+ ext: () => extension.substring(1),
14630
14656
  extname: () => extension,
14631
14657
  format: () => options.format,
14632
14658
  name: () => getAliasName(sanitizedId)
@@ -14808,22 +14834,24 @@ class Chunk {
14808
14834
  const renderedDependency = this.renderedDependencies.get(dependency);
14809
14835
  if (dependency instanceof ExternalModule) {
14810
14836
  const originalId = dependency.renderPath;
14811
- renderedDependency.id = escapeId(dependency.renormalizeRenderPath ? this.getRelativePath(originalId, false) : originalId);
14837
+ renderedDependency.id = escapeId(dependency.renormalizeRenderPath
14838
+ ? getImportPath(this.id, originalId, false, false)
14839
+ : originalId);
14812
14840
  }
14813
14841
  else {
14814
14842
  renderedDependency.namedExportsMode = dependency.exportMode !== 'default';
14815
- renderedDependency.id = escapeId(this.getRelativePath(dependency.id, false));
14843
+ renderedDependency.id = escapeId(getImportPath(this.id, dependency.id, false, true));
14816
14844
  }
14817
14845
  }
14818
14846
  this.finaliseDynamicImports(options, snippets);
14819
14847
  this.finaliseImportMetas(format, snippets);
14820
14848
  const hasExports = this.renderedExports.length !== 0 ||
14821
14849
  [...this.renderedDependencies.values()].some(dep => (dep.reexports && dep.reexports.length !== 0));
14822
- let usesTopLevelAwait = false;
14850
+ let topLevelAwaitModule = null;
14823
14851
  const accessedGlobals = new Set();
14824
14852
  for (const module of this.orderedModules) {
14825
14853
  if (module.usesTopLevelAwait) {
14826
- usesTopLevelAwait = true;
14854
+ topLevelAwaitModule = module.id;
14827
14855
  }
14828
14856
  const accessedGlobalVariables = this.accessedGlobalsByScope.get(module.scope);
14829
14857
  if (accessedGlobalVariables) {
@@ -14832,9 +14860,10 @@ class Chunk {
14832
14860
  }
14833
14861
  }
14834
14862
  }
14835
- if (usesTopLevelAwait && format !== 'es' && format !== 'system') {
14863
+ if (topLevelAwaitModule !== null && format !== 'es' && format !== 'system') {
14836
14864
  return error({
14837
14865
  code: 'INVALID_TLA_FORMAT',
14866
+ id: topLevelAwaitModule,
14838
14867
  message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
14839
14868
  });
14840
14869
  }
@@ -14856,7 +14885,7 @@ class Chunk {
14856
14885
  namedExportsMode: this.exportMode !== 'default',
14857
14886
  outro: addons.outro,
14858
14887
  snippets,
14859
- usesTopLevelAwait,
14888
+ usesTopLevelAwait: topLevelAwaitModule !== null,
14860
14889
  warn: this.inputOptions.onwarn
14861
14890
  }, options);
14862
14891
  if (addons.banner)
@@ -14995,10 +15024,10 @@ class Chunk {
14995
15024
  continue;
14996
15025
  }
14997
15026
  const renderedResolution = resolution instanceof Module
14998
- ? `'${escapeId(this.getRelativePath((facadeChunk || chunk).id, stripKnownJsExtensions))}'`
15027
+ ? `'${escapeId(getImportPath(this.id, (facadeChunk || chunk).id, stripKnownJsExtensions, true))}'`
14999
15028
  : resolution instanceof ExternalModule
15000
15029
  ? `'${escapeId(resolution.renormalizeRenderPath
15001
- ? this.getRelativePath(resolution.renderPath, stripKnownJsExtensions)
15030
+ ? getImportPath(this.id, resolution.renderPath, stripKnownJsExtensions, false)
15002
15031
  : resolution.renderPath)}'`
15003
15032
  : resolution;
15004
15033
  node.renderFinalResolution(code, renderedResolution, resolution instanceof Module &&
@@ -15195,7 +15224,7 @@ class Chunk {
15195
15224
  let imported;
15196
15225
  let needsLiveBinding = false;
15197
15226
  if (exportName[0] === '*') {
15198
- const id = exportName.substr(1);
15227
+ const id = exportName.substring(1);
15199
15228
  if (interop(id) === 'defaultOnly') {
15200
15229
  this.inputOptions.onwarn(errUnexpectedNamespaceReexport(id));
15201
15230
  }
@@ -15246,17 +15275,6 @@ class Chunk {
15246
15275
  }
15247
15276
  return referencedFiles;
15248
15277
  }
15249
- getRelativePath(targetPath, stripJsExtension) {
15250
- let relativePath = normalize(relative(require$$0.dirname(this.id), targetPath));
15251
- if (stripJsExtension && relativePath.endsWith('.js')) {
15252
- relativePath = relativePath.slice(0, -3);
15253
- }
15254
- if (relativePath === '..')
15255
- return '../../' + require$$0.basename(targetPath);
15256
- if (relativePath === '')
15257
- return '../' + require$$0.basename(targetPath);
15258
- return relativePath.startsWith('../') ? relativePath : './' + relativePath;
15259
- }
15260
15278
  inlineChunkDependencies(chunk) {
15261
15279
  for (const dep of chunk.dependencies) {
15262
15280
  if (this.dependencies.has(dep))
@@ -15405,16 +15423,17 @@ function generateAssetFileName(name, source, outputOptions, bundle) {
15405
15423
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
15406
15424
  ? outputOptions.assetFileNames({ name, source, type: 'asset' })
15407
15425
  : outputOptions.assetFileNames, 'output.assetFileNames', {
15408
- ext: () => require$$0.extname(emittedName).substr(1),
15426
+ ext: () => require$$0.extname(emittedName).substring(1),
15409
15427
  extname: () => require$$0.extname(emittedName),
15410
15428
  hash() {
15411
- const hash = createHash();
15412
- hash.update(emittedName);
15413
- hash.update(':');
15414
- hash.update(source);
15415
- return hash.digest('hex').substr(0, 8);
15429
+ return createHash()
15430
+ .update(emittedName)
15431
+ .update(':')
15432
+ .update(source)
15433
+ .digest('hex')
15434
+ .substring(0, 8);
15416
15435
  },
15417
- name: () => emittedName.substr(0, emittedName.length - require$$0.extname(emittedName).length)
15436
+ name: () => emittedName.substring(0, emittedName.length - require$$0.extname(emittedName).length)
15418
15437
  }), bundle);
15419
15438
  }
15420
15439
  function reserveFileNameInBundle(fileName, bundle, warn) {
@@ -15463,7 +15482,7 @@ class FileEmitter {
15463
15482
  this.facadeChunkByModule = null;
15464
15483
  this.outputOptions = null;
15465
15484
  this.assertAssetsFinalized = () => {
15466
- for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) {
15485
+ for (const [referenceId, emittedFile] of this.filesByReferenceId) {
15467
15486
  if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
15468
15487
  return error(errNoAssetSourceSet(emittedFile.name || referenceId));
15469
15488
  }
@@ -15478,9 +15497,7 @@ class FileEmitter {
15478
15497
  if (emittedFile.type === 'chunk') {
15479
15498
  return this.emitChunk(emittedFile);
15480
15499
  }
15481
- else {
15482
- return this.emitAsset(emittedFile);
15483
- }
15500
+ return this.emitAsset(emittedFile);
15484
15501
  };
15485
15502
  this.getFileName = (fileReferenceId) => {
15486
15503
  const emittedFile = this.filesByReferenceId.get(fileReferenceId);
@@ -15489,9 +15506,7 @@ class FileEmitter {
15489
15506
  if (emittedFile.type === 'chunk') {
15490
15507
  return getChunkFileName(emittedFile, this.facadeChunkByModule);
15491
15508
  }
15492
- else {
15493
- return getAssetFileName(emittedFile, fileReferenceId);
15494
- }
15509
+ return getAssetFileName(emittedFile, fileReferenceId);
15495
15510
  };
15496
15511
  this.setAssetSource = (referenceId, requestedSource) => {
15497
15512
  const consumedFile = this.filesByReferenceId.get(referenceId);
@@ -15520,7 +15535,7 @@ class FileEmitter {
15520
15535
  reserveFileNameInBundle(emittedFile.fileName, this.bundle, this.options.onwarn);
15521
15536
  }
15522
15537
  }
15523
- for (const [referenceId, consumedFile] of this.filesByReferenceId.entries()) {
15538
+ for (const [referenceId, consumedFile] of this.filesByReferenceId) {
15524
15539
  if (consumedFile.type === 'asset' && consumedFile.source !== undefined) {
15525
15540
  this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.bundle);
15526
15541
  }
@@ -15533,14 +15548,10 @@ class FileEmitter {
15533
15548
  assignReferenceId(file, idBase) {
15534
15549
  let referenceId;
15535
15550
  do {
15536
- const hash = createHash();
15537
- if (referenceId) {
15538
- hash.update(referenceId);
15539
- }
15540
- else {
15541
- hash.update(idBase);
15542
- }
15543
- referenceId = hash.digest('hex').substr(0, 8);
15551
+ referenceId = createHash()
15552
+ .update(referenceId || idBase)
15553
+ .digest('hex')
15554
+ .substring(0, 8);
15544
15555
  } while (this.filesByReferenceId.has(referenceId));
15545
15556
  this.filesByReferenceId.set(referenceId, file);
15546
15557
  return referenceId;
@@ -16064,7 +16075,7 @@ class Bundle {
16064
16075
  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);
16065
16076
  file.type = 'asset';
16066
16077
  }
16067
- if (this.outputOptions.validate && typeof file.code == 'string') {
16078
+ if (this.outputOptions.validate && 'code' in file) {
16068
16079
  try {
16069
16080
  this.graph.contextParse(file.code, {
16070
16081
  allowHashBang: true,
@@ -22281,9 +22292,7 @@ class ModuleLoader {
22281
22292
  }
22282
22293
  return Promise.resolve(externalModule);
22283
22294
  }
22284
- else {
22285
- return this.fetchModule(resolvedId, importer, false, false);
22286
- }
22295
+ return this.fetchModule(resolvedId, importer, false, false);
22287
22296
  }
22288
22297
  async fetchStaticDependencies(module, resolveStaticDependencyPromises) {
22289
22298
  for (const dependency of await Promise.all(resolveStaticDependencyPromises.map(resolveStaticDependencyPromise => resolveStaticDependencyPromise.then(([source, resolvedId]) => this.fetchResolvedDependency(source, module.id, resolvedId))))) {
@@ -22421,6 +22430,8 @@ class ModuleLoader {
22421
22430
  : { id: resolveIdResult }), undefined, isEntry, false);
22422
22431
  }
22423
22432
  async resolveDynamicImport(module, specifier, importer) {
22433
+ var _a;
22434
+ var _b;
22424
22435
  const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [
22425
22436
  specifier,
22426
22437
  importer
@@ -22439,9 +22450,7 @@ class ModuleLoader {
22439
22450
  };
22440
22451
  }
22441
22452
  if (resolution == null) {
22442
- return (module.resolvedIds[specifier] =
22443
- module.resolvedIds[specifier] ||
22444
- this.handleResolveId(await this.resolveId(specifier, module.id, EMPTY_OBJECT, false), specifier, module.id));
22453
+ 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)));
22445
22454
  }
22446
22455
  return this.handleResolveId(this.getResolvedIdWithDefaults(this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier)), specifier, importer);
22447
22456
  }
@@ -22492,7 +22501,6 @@ class GlobalScope extends Scope$1 {
22492
22501
  }
22493
22502
  }
22494
22503
 
22495
- // eslint-disable-next-line @typescript-eslint/ban-types
22496
22504
  function getDeprecatedContextHandler(handler, handlerName, newHandlerName, pluginName, activeDeprecation, options) {
22497
22505
  let deprecationWarningShown = false;
22498
22506
  return ((...args) => {
@@ -22598,24 +22606,19 @@ function resolveAction(actionTuple) {
22598
22606
  unfulfilledActions.delete(actionTuple);
22599
22607
  }
22600
22608
  function formatAction([pluginName, hookName, args]) {
22601
- let action = `(${pluginName}) ${hookName}`;
22609
+ const action = `(${pluginName}) ${hookName}`;
22602
22610
  const s = JSON.stringify;
22603
22611
  switch (hookName) {
22604
22612
  case 'resolveId':
22605
- action += ` ${s(args[0])} ${s(args[1])}`;
22606
- break;
22613
+ return `${action} ${s(args[0])} ${s(args[1])}`;
22607
22614
  case 'load':
22608
- action += ` ${s(args[0])}`;
22609
- break;
22615
+ return `${action} ${s(args[0])}`;
22610
22616
  case 'transform':
22611
- action += ` ${s(args[1])}`;
22612
- break;
22617
+ return `${action} ${s(args[1])}`;
22613
22618
  case 'shouldTransformCachedModule':
22614
- action += ` ${s(args[0].id)}`;
22615
- break;
22619
+ return `${action} ${s(args[0].id)}`;
22616
22620
  case 'moduleParsed':
22617
- action += ` ${s(args[0].id)}`;
22618
- break;
22621
+ return `${action} ${s(args[0].id)}`;
22619
22622
  }
22620
22623
  return action;
22621
22624
  }
@@ -23271,6 +23274,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23271
23274
  const preserveModules = getPreserveModules(config, inlineDynamicImports, inputOptions);
23272
23275
  const file = getFile(config, preserveModules, inputOptions);
23273
23276
  const preferConst = getPreferConst(config, inputOptions);
23277
+ const generatedCode = getGeneratedCode(config, preferConst);
23274
23278
  const outputOptions = {
23275
23279
  amd: getAmd(config),
23276
23280
  assetFileNames: (_a = config.assetFileNames) !== null && _a !== void 0 ? _a : 'assets/[name]-[hash][extname]',
@@ -23288,7 +23292,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23288
23292
  footer: getAddon(config, 'footer'),
23289
23293
  format,
23290
23294
  freeze: (_e = config.freeze) !== null && _e !== void 0 ? _e : true,
23291
- generatedCode: getGeneratedCode(config, preferConst),
23295
+ generatedCode,
23292
23296
  globals: config.globals || {},
23293
23297
  hoistTransitiveImports: (_f = config.hoistTransitiveImports) !== null && _f !== void 0 ? _f : true,
23294
23298
  indent: getIndent(config, compact),
@@ -23298,7 +23302,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23298
23302
  manualChunks: getManualChunks(config, inlineDynamicImports, preserveModules, inputOptions),
23299
23303
  minifyInternalExports: getMinifyInternalExports(config, format, compact),
23300
23304
  name: config.name,
23301
- namespaceToStringTag: config.namespaceToStringTag || false,
23305
+ namespaceToStringTag: getNamespaceToStringTag(config, generatedCode, inputOptions),
23302
23306
  noConflict: config.noConflict || false,
23303
23307
  outro: getAddon(config, 'outro'),
23304
23308
  paths: config.paths || {},
@@ -23468,7 +23472,8 @@ const getGeneratedCode = (config, preferConst) => {
23468
23472
  arrowFunctions: configWithPreset.arrowFunctions === true,
23469
23473
  constBindings: configWithPreset.constBindings === true || preferConst,
23470
23474
  objectShorthand: configWithPreset.objectShorthand === true,
23471
- reservedNamesAsProps: configWithPreset.reservedNamesAsProps === true
23475
+ reservedNamesAsProps: configWithPreset.reservedNamesAsProps === true,
23476
+ symbols: configWithPreset.symbols === true
23472
23477
  };
23473
23478
  };
23474
23479
  const getIndent = (config, compact) => {
@@ -23493,7 +23498,7 @@ const getInterop = (config, inputOptions) => {
23493
23498
  if (!validatedInteropTypes.has(interop)) {
23494
23499
  validatedInteropTypes.add(interop);
23495
23500
  if (!ALLOWED_INTEROP_TYPES.has(interop)) {
23496
- return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES.values(), value => JSON.stringify(value)).join(', ')}`, interop));
23501
+ return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
23497
23502
  }
23498
23503
  if (typeof interop === 'boolean') {
23499
23504
  warnDeprecation({
@@ -23528,6 +23533,14 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
23528
23533
  return configManualChunks || {};
23529
23534
  };
23530
23535
  const getMinifyInternalExports = (config, format, compact) => { var _a; return (_a = config.minifyInternalExports) !== null && _a !== void 0 ? _a : (compact || format === 'es' || format === 'system'); };
23536
+ const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
23537
+ const configNamespaceToStringTag = config.namespaceToStringTag;
23538
+ if (configNamespaceToStringTag != null) {
23539
+ warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`, false, inputOptions);
23540
+ return configNamespaceToStringTag;
23541
+ }
23542
+ return generatedCode.symbols || false;
23543
+ };
23531
23544
 
23532
23545
  function rollup(rawInputOptions) {
23533
23546
  return rollupInternal(rawInputOptions, null);
@@ -23599,12 +23612,11 @@ function applyOptionHook(watchMode) {
23599
23612
  };
23600
23613
  }
23601
23614
  function normalizePlugins(plugins, anonymousPrefix) {
23602
- for (let pluginIndex = 0; pluginIndex < plugins.length; pluginIndex++) {
23603
- const plugin = plugins[pluginIndex];
23615
+ plugins.forEach((plugin, index) => {
23604
23616
  if (!plugin.name) {
23605
- plugin.name = `${anonymousPrefix}${pluginIndex + 1}`;
23617
+ plugin.name = `${anonymousPrefix}${index + 1}`;
23606
23618
  }
23607
- }
23619
+ });
23608
23620
  }
23609
23621
  async function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutputOptions, graph) {
23610
23622
  const { options: outputOptions, outputPluginDriver, unsetOptions } = getOutputOptionsAndPluginDriver(rawOutputOptions, graph.pluginDriver, inputOptions, unsetInputOptions);