rollup 4.67.4 → 4.68.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 v4.67.4
4
- Sun, 01 Nov 2026 07:42:20 GMT - commit 18b5cb60e55926f6d917cc1aeb17fd81d0da5cc6
3
+ Rollup.js v4.68.0
4
+ Fri, 06 Nov 2026 16:52:39 GMT - commit b93d9a40e1eed7a78069a58ca191260f5c094727
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
42
42
 
43
43
  const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
44
44
 
45
- var version = "4.67.4";
45
+ var version = "4.68.0";
46
46
  const package_ = {
47
47
  version: version};
48
48
 
@@ -6276,6 +6276,97 @@ var Bundle$1 = class Bundle {
6276
6276
  }
6277
6277
  };
6278
6278
 
6279
+ const RESERVED_NAMES = new Set([
6280
+ 'await',
6281
+ 'break',
6282
+ 'case',
6283
+ 'catch',
6284
+ 'class',
6285
+ 'const',
6286
+ 'continue',
6287
+ 'debugger',
6288
+ 'default',
6289
+ 'delete',
6290
+ 'do',
6291
+ 'else',
6292
+ 'enum',
6293
+ 'eval',
6294
+ 'export',
6295
+ 'extends',
6296
+ 'false',
6297
+ 'finally',
6298
+ 'for',
6299
+ 'function',
6300
+ 'if',
6301
+ 'implements',
6302
+ 'import',
6303
+ 'in',
6304
+ 'instanceof',
6305
+ 'interface',
6306
+ 'let',
6307
+ 'NaN',
6308
+ 'new',
6309
+ 'null',
6310
+ 'package',
6311
+ 'private',
6312
+ 'protected',
6313
+ 'public',
6314
+ 'return',
6315
+ 'static',
6316
+ 'super',
6317
+ 'switch',
6318
+ 'this',
6319
+ 'throw',
6320
+ 'true',
6321
+ 'try',
6322
+ 'typeof',
6323
+ 'undefined',
6324
+ 'var',
6325
+ 'void',
6326
+ 'while',
6327
+ 'with',
6328
+ 'yield'
6329
+ ]);
6330
+
6331
+ function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
6332
+ let nameIndex = 0;
6333
+ for (const variable of exports) {
6334
+ let [exportName] = variable.name;
6335
+ if (exportsByName.has(exportName)) {
6336
+ do {
6337
+ exportName = toBase64(++nameIndex);
6338
+ // skip past leading number identifiers
6339
+ if (exportName.charCodeAt(0) === 49 /* '1' */) {
6340
+ nameIndex += 9 * 64 ** (exportName.length - 1);
6341
+ exportName = toBase64(nameIndex);
6342
+ }
6343
+ } while (RESERVED_NAMES.has(exportName) || exportsByName.has(exportName));
6344
+ }
6345
+ exportsByName.set(exportName, variable);
6346
+ exportNamesByVariable.set(variable, [exportName]);
6347
+ }
6348
+ }
6349
+ function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
6350
+ for (const variable of exports) {
6351
+ let nameIndex = 0;
6352
+ let exportName = variable.name;
6353
+ while (exportsByName.has(exportName)) {
6354
+ exportName = variable.name + '$' + ++nameIndex;
6355
+ }
6356
+ exportsByName.set(exportName, variable);
6357
+ exportNamesByVariable.set(variable, [exportName]);
6358
+ }
6359
+ }
6360
+ // Names starting with "*" are used internally, e.g. "*" for namespaces and "*"
6361
+ // followed by an id for namespaces reexported from external modules. To avoid
6362
+ // conflicts, actual export names starting with "*" get an additional "*", and
6363
+ // external ids starting with "*" or "\0" are prefixed with "\0".
6364
+ const escapeExportName = (name) => (name[0] === '*' ? `*${name}` : name);
6365
+ const unescapeExportName = (name) => name.startsWith('**') ? name.slice(1) : name;
6366
+ const isNamespaceExportName = (name) => name[0] === '*' && name[1] !== '*';
6367
+ const getExternalNamespaceExportName = (id) => id[0] === '*' || id[0] === '\0' ? `*\0${id}` : `*${id}`;
6368
+ const getExternalNamespaceId = (exportName) => exportName.slice(exportName[1] === '\0' ? 2 : 1);
6369
+
6279
6370
  function treeshakeNode(node, code, start, end) {
6280
6371
  code.remove(start, end);
6281
6372
  node.removeAnnotations(code);
@@ -6442,13 +6533,16 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
6442
6533
  if (exportedVariables.length === 1 &&
6443
6534
  exportNamesByVariable.get(exportedVariables[0]).length === 1) {
6444
6535
  const variable = exportedVariables[0];
6445
- return `exports(${JSON.stringify(exportNamesByVariable.get(variable)[0])},${_}${variable.getName(getPropertyAccess)}${modifier})`;
6536
+ return `exports(${JSON.stringify(unescapeExportName(exportNamesByVariable.get(variable)[0]))},${_}${variable.getName(getPropertyAccess)}${modifier})`;
6446
6537
  }
6447
6538
  else {
6448
6539
  const fields = [];
6449
6540
  for (const variable of exportedVariables) {
6450
6541
  for (const exportName of exportNamesByVariable.get(variable)) {
6451
- fields.push([exportName, variable.getName(getPropertyAccess) + modifier]);
6542
+ fields.push([
6543
+ unescapeExportName(exportName),
6544
+ variable.getName(getPropertyAccess) + modifier
6545
+ ]);
6452
6546
  }
6453
6547
  }
6454
6548
  return `exports(${getObject(fields, { lineBreakIndent: null })})`;
@@ -6456,7 +6550,7 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
6456
6550
  }
6457
6551
  // This is only invoked if there is exactly one export name
6458
6552
  function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
6459
- code.prependRight(expressionStart, `exports(${JSON.stringify(exportNamesByVariable.get(exportedVariable)[0])},${_}`);
6553
+ code.prependRight(expressionStart, `exports(${JSON.stringify(unescapeExportName(exportNamesByVariable.get(exportedVariable)[0]))},${_}`);
6460
6554
  code.appendLeft(expressionEnd, ')');
6461
6555
  }
6462
6556
  function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
@@ -7017,58 +7111,6 @@ function cacheObjectGetters(object, getterProperties) {
7017
7111
  }
7018
7112
  }
7019
7113
 
7020
- const RESERVED_NAMES = new Set([
7021
- 'await',
7022
- 'break',
7023
- 'case',
7024
- 'catch',
7025
- 'class',
7026
- 'const',
7027
- 'continue',
7028
- 'debugger',
7029
- 'default',
7030
- 'delete',
7031
- 'do',
7032
- 'else',
7033
- 'enum',
7034
- 'eval',
7035
- 'export',
7036
- 'extends',
7037
- 'false',
7038
- 'finally',
7039
- 'for',
7040
- 'function',
7041
- 'if',
7042
- 'implements',
7043
- 'import',
7044
- 'in',
7045
- 'instanceof',
7046
- 'interface',
7047
- 'let',
7048
- 'NaN',
7049
- 'new',
7050
- 'null',
7051
- 'package',
7052
- 'private',
7053
- 'protected',
7054
- 'public',
7055
- 'return',
7056
- 'static',
7057
- 'super',
7058
- 'switch',
7059
- 'this',
7060
- 'throw',
7061
- 'true',
7062
- 'try',
7063
- 'typeof',
7064
- 'undefined',
7065
- 'var',
7066
- 'void',
7067
- 'while',
7068
- 'with',
7069
- 'yield'
7070
- ]);
7071
-
7072
7114
  const illegalCharacters = /[^\w$]/g;
7073
7115
  const illegalCharacter = /[^\w$]/;
7074
7116
  const startsWithDigit = (value) => /\d/.test(value[0]);
@@ -7190,7 +7232,7 @@ class ExternalModule {
7190
7232
  }
7191
7233
  }
7192
7234
  const importersArray = [...importersSet];
7193
- this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnusedExternalImports(this.id, unused, importersArray));
7235
+ this.options.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnusedExternalImports(this.id, unused.map(unescapeExportName), importersArray));
7194
7236
  }
7195
7237
  }
7196
7238
 
@@ -11793,7 +11835,7 @@ class ExportDefaultDeclaration extends NodeBase {
11793
11835
  const hasTrailingSemicolon = code.original.charCodeAt(this.end - 1) === 59; /*";"*/
11794
11836
  const systemExportNames = format === 'system' && exportNamesByVariable.get(this.variable);
11795
11837
  if (systemExportNames) {
11796
- code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(systemExportNames[0])}, `);
11838
+ code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(unescapeExportName(systemExportNames[0]))}, `);
11797
11839
  code.appendRight(hasTrailingSemicolon ? this.end - 1 : this.end, ')' + (hasTrailingSemicolon ? '' : ';'));
11798
11840
  return false;
11799
11841
  }
@@ -12028,6 +12070,111 @@ function getToStringTagValue(getObject) {
12028
12070
  });
12029
12071
  }
12030
12072
 
12073
+ class UndefinedVariable extends Variable {
12074
+ constructor() {
12075
+ super('undefined');
12076
+ }
12077
+ getLiteralValueAtPath() {
12078
+ return undefined;
12079
+ }
12080
+ }
12081
+
12082
+ class ExportDefaultVariable extends LocalVariable {
12083
+ constructor(exportDefaultDeclaration, context) {
12084
+ super('default', exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
12085
+ this.hasId = false;
12086
+ this.originalId = null;
12087
+ this.originalVariable = null;
12088
+ const declaration = exportDefaultDeclaration.declaration;
12089
+ if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
12090
+ declaration.id) {
12091
+ this.hasId = true;
12092
+ this.originalId = declaration.id;
12093
+ }
12094
+ else if (declaration instanceof Identifier) {
12095
+ this.originalId = declaration;
12096
+ }
12097
+ }
12098
+ addReference(identifier) {
12099
+ if (!this.hasId) {
12100
+ this.name = identifier.name;
12101
+ }
12102
+ }
12103
+ addUsedPlace(usedPlace) {
12104
+ const original = this.getOriginalVariable();
12105
+ if (original === this) {
12106
+ super.addUsedPlace(usedPlace);
12107
+ }
12108
+ else {
12109
+ original.addUsedPlace(usedPlace);
12110
+ }
12111
+ }
12112
+ forbidName(name) {
12113
+ const original = this.getOriginalVariable();
12114
+ if (original === this) {
12115
+ super.forbidName(name);
12116
+ }
12117
+ else {
12118
+ original.forbidName(name);
12119
+ }
12120
+ }
12121
+ getAssignedVariableName() {
12122
+ return (this.originalId && this.originalId.name) || null;
12123
+ }
12124
+ getBaseVariableName() {
12125
+ const original = this.getOriginalVariable();
12126
+ return original === this ? super.getBaseVariableName() : original.getBaseVariableName();
12127
+ }
12128
+ getDirectOriginalVariable() {
12129
+ return this.originalId &&
12130
+ (this.hasId ||
12131
+ !(this.originalId.isPossibleTDZ() ||
12132
+ this.originalId.variable.isReassigned ||
12133
+ this.originalId.variable instanceof UndefinedVariable ||
12134
+ // this avoids a circular dependency
12135
+ 'syntheticNamespace' in this.originalId.variable))
12136
+ ? this.originalId.variable
12137
+ : null;
12138
+ }
12139
+ /**
12140
+ * Returns the namespace if this default export is just a re-export of a
12141
+ * namespace import. Namespace variables can neither be reassigned nor be
12142
+ * accessed in their TDZ, so this is safe to call while binding.
12143
+ */
12144
+ getOriginalNamespaceVariable() {
12145
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
12146
+ let current = this;
12147
+ const checkedVariables = new Set();
12148
+ while (current instanceof ExportDefaultVariable && !checkedVariables.has(current)) {
12149
+ checkedVariables.add(current);
12150
+ if (current.hasId || !current.originalId)
12151
+ return null;
12152
+ current = current.originalId.variable;
12153
+ }
12154
+ return current?.isNamespace ? current : null;
12155
+ }
12156
+ getName(getPropertyAccess) {
12157
+ const original = this.getOriginalVariable();
12158
+ return original === this
12159
+ ? super.getName(getPropertyAccess)
12160
+ : original.getName(getPropertyAccess);
12161
+ }
12162
+ getOriginalVariable() {
12163
+ if (this.originalVariable)
12164
+ return this.originalVariable;
12165
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
12166
+ let original = this;
12167
+ let currentVariable;
12168
+ const checkedVariables = new Set();
12169
+ do {
12170
+ checkedVariables.add(original);
12171
+ currentVariable = original;
12172
+ original = currentVariable.getDirectOriginalVariable();
12173
+ } while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
12174
+ return (this.originalVariable = original || currentVariable);
12175
+ }
12176
+ }
12177
+
12031
12178
  class Literal extends NodeBase {
12032
12179
  deoptimizeArgumentsOnInteractionAtPath() { }
12033
12180
  getLiteralValueAtPath(path) {
@@ -12171,7 +12318,10 @@ class MemberExpression extends NodeBase {
12171
12318
  bind() {
12172
12319
  this.bound = true;
12173
12320
  const path = getPathIfNotComputed(this);
12174
- const baseVariable = path && this.scope.findVariable(path[0].key);
12321
+ let baseVariable = path && this.scope.findVariable(path[0].key);
12322
+ if (baseVariable instanceof ExportDefaultVariable) {
12323
+ baseVariable = baseVariable.getOriginalNamespaceVariable() || baseVariable;
12324
+ }
12175
12325
  if (baseVariable?.isNamespace) {
12176
12326
  const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.scope.context);
12177
12327
  if (!resolvedVariable) {
@@ -12677,94 +12827,6 @@ const importMetaMechanisms = {
12677
12827
  umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename', false)} : ${getUrlFromDocument(chunkId, true)})`)
12678
12828
  };
12679
12829
 
12680
- class UndefinedVariable extends Variable {
12681
- constructor() {
12682
- super('undefined');
12683
- }
12684
- getLiteralValueAtPath() {
12685
- return undefined;
12686
- }
12687
- }
12688
-
12689
- class ExportDefaultVariable extends LocalVariable {
12690
- constructor(exportDefaultDeclaration, context) {
12691
- super('default', exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
12692
- this.hasId = false;
12693
- this.originalId = null;
12694
- this.originalVariable = null;
12695
- const declaration = exportDefaultDeclaration.declaration;
12696
- if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
12697
- declaration.id) {
12698
- this.hasId = true;
12699
- this.originalId = declaration.id;
12700
- }
12701
- else if (declaration instanceof Identifier) {
12702
- this.originalId = declaration;
12703
- }
12704
- }
12705
- addReference(identifier) {
12706
- if (!this.hasId) {
12707
- this.name = identifier.name;
12708
- }
12709
- }
12710
- addUsedPlace(usedPlace) {
12711
- const original = this.getOriginalVariable();
12712
- if (original === this) {
12713
- super.addUsedPlace(usedPlace);
12714
- }
12715
- else {
12716
- original.addUsedPlace(usedPlace);
12717
- }
12718
- }
12719
- forbidName(name) {
12720
- const original = this.getOriginalVariable();
12721
- if (original === this) {
12722
- super.forbidName(name);
12723
- }
12724
- else {
12725
- original.forbidName(name);
12726
- }
12727
- }
12728
- getAssignedVariableName() {
12729
- return (this.originalId && this.originalId.name) || null;
12730
- }
12731
- getBaseVariableName() {
12732
- const original = this.getOriginalVariable();
12733
- return original === this ? super.getBaseVariableName() : original.getBaseVariableName();
12734
- }
12735
- getDirectOriginalVariable() {
12736
- return this.originalId &&
12737
- (this.hasId ||
12738
- !(this.originalId.isPossibleTDZ() ||
12739
- this.originalId.variable.isReassigned ||
12740
- this.originalId.variable instanceof UndefinedVariable ||
12741
- // this avoids a circular dependency
12742
- 'syntheticNamespace' in this.originalId.variable))
12743
- ? this.originalId.variable
12744
- : null;
12745
- }
12746
- getName(getPropertyAccess) {
12747
- const original = this.getOriginalVariable();
12748
- return original === this
12749
- ? super.getName(getPropertyAccess)
12750
- : original.getName(getPropertyAccess);
12751
- }
12752
- getOriginalVariable() {
12753
- if (this.originalVariable)
12754
- return this.originalVariable;
12755
- // eslint-disable-next-line @typescript-eslint/no-this-alias
12756
- let original = this;
12757
- let currentVariable;
12758
- const checkedVariables = new Set();
12759
- do {
12760
- checkedVariables.add(original);
12761
- currentVariable = original;
12762
- original = currentVariable.getDirectOriginalVariable();
12763
- } while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
12764
- return (this.originalVariable = original || currentVariable);
12765
- }
12766
- }
12767
-
12768
12830
  class NamespaceVariable extends Variable {
12769
12831
  constructor(context) {
12770
12832
  super(context.getModuleName());
@@ -12784,10 +12846,7 @@ class NamespaceVariable extends Variable {
12784
12846
  if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) {
12785
12847
  const key = path[0];
12786
12848
  if (typeof key === 'string') {
12787
- this.module
12788
- .getExportedVariablesByName()
12789
- .get(key)
12790
- ?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
12849
+ this.getMemberVariable(key)?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
12791
12850
  }
12792
12851
  else {
12793
12852
  deoptimizeInteraction(interaction);
@@ -12798,7 +12857,7 @@ class NamespaceVariable extends Variable {
12798
12857
  if (path.length > 1) {
12799
12858
  const key = path[0];
12800
12859
  if (typeof key === 'string') {
12801
- this.module.getExportedVariablesByName().get(key)?.deoptimizePath(path.slice(1));
12860
+ this.getMemberVariable(key)?.deoptimizePath(path.slice(1));
12802
12861
  }
12803
12862
  else if (!this.areAllMembersDeoptimized) {
12804
12863
  this.areAllMembersDeoptimized = true;
@@ -12827,7 +12886,7 @@ class NamespaceVariable extends Variable {
12827
12886
  if (typeof key !== 'string') {
12828
12887
  return true;
12829
12888
  }
12830
- const memberVariable = this.module.getExportedVariablesByName().get(key);
12889
+ const memberVariable = this.getMemberVariable(key);
12831
12890
  return (!memberVariable ||
12832
12891
  memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
12833
12892
  }
@@ -12839,7 +12898,7 @@ class NamespaceVariable extends Variable {
12839
12898
  if (path.length > 0) {
12840
12899
  const [name, ...remainingPath] = path;
12841
12900
  if (typeof name === 'string') {
12842
- const variable = this.module.getExportedVariablesByName().get(name);
12901
+ const variable = this.getMemberVariable(name);
12843
12902
  if (variable) {
12844
12903
  this.context.includeVariableInModule(variable, remainingPath, context);
12845
12904
  }
@@ -12862,15 +12921,16 @@ class NamespaceVariable extends Variable {
12862
12921
  const { exportNamesByVariable, format, freeze, indent: t, symbols, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
12863
12922
  const memberVariables = this.module.getExportedVariablesByName();
12864
12923
  const members = [...memberVariables.entries()]
12865
- .filter(([name, variable]) => !name.startsWith('*') && variable.included)
12924
+ .filter(([name, variable]) => !isNamespaceExportName(name) && variable.included)
12866
12925
  .map(([name, variable]) => {
12926
+ const key = unescapeExportName(name);
12867
12927
  if (this.referencedEarly || variable.isReassigned || variable === this) {
12868
12928
  return [
12869
12929
  null,
12870
- `get ${stringifyObjectKeyIfNeeded(name)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
12930
+ `get ${stringifyObjectKeyIfNeeded(key)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
12871
12931
  ];
12872
12932
  }
12873
- return [name, variable.getName(getPropertyAccess)];
12933
+ return [key, variable.getName(getPropertyAccess)];
12874
12934
  });
12875
12935
  members.unshift([null, `__proto__:${_}null`]);
12876
12936
  let output = getObject(members, { lineBreakIndent: { base: '', t } });
@@ -12908,6 +12968,9 @@ class NamespaceVariable extends Variable {
12908
12968
  }
12909
12969
  }
12910
12970
  }
12971
+ getMemberVariable(name) {
12972
+ return this.module.getExportedVariablesByName().get(escapeExportName(name));
12973
+ }
12911
12974
  includeNonExplicitNamespaces() {
12912
12975
  if (!this.nonExplicitNamespacesIncluded) {
12913
12976
  this.nonExplicitNamespacesIncluded = true;
@@ -13042,7 +13105,7 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
13042
13105
  if (exportBlock)
13043
13106
  exportBlock += n;
13044
13107
  if (specifier.imported !== '*' && specifier.needsLiveBinding) {
13045
- exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(specifier.reexported)},${_}${getGetter(importName, false, t, snippets)});`;
13108
+ exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(specifier.reexported))},${_}${getGetter(importName, false, t, snippets)});`;
13046
13109
  }
13047
13110
  else if (specifier.reexported === '__proto__') {
13048
13111
  exportBlock +=
@@ -13051,20 +13114,20 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
13051
13114
  `${t}value:${_}${importName}${n}});`;
13052
13115
  }
13053
13116
  else {
13054
- exportBlock += `exports${getPropertyAccess(specifier.reexported)}${_}=${_}${importName};`;
13117
+ exportBlock += `exports${getPropertyAccess(unescapeExportName(specifier.reexported))}${_}=${_}${importName};`;
13055
13118
  }
13056
13119
  }
13057
13120
  }
13058
13121
  }
13059
13122
  }
13060
13123
  for (const { exported, local, needsLiveBinding } of exports) {
13061
- const lhs = `exports${getPropertyAccess(exported)}`;
13124
+ const lhs = `exports${getPropertyAccess(unescapeExportName(exported))}`;
13062
13125
  const rhs = local;
13063
13126
  if (lhs !== rhs) {
13064
13127
  if (exportBlock)
13065
13128
  exportBlock += n;
13066
13129
  if (needsLiveBinding) {
13067
- exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(exported)},${_}${getGetter(rhs, true, t, snippets)});`;
13130
+ exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(exported))},${_}${getGetter(rhs, true, t, snippets)});`;
13068
13131
  continue;
13069
13132
  }
13070
13133
  exportBlock +=
@@ -13142,7 +13205,7 @@ function getReexportedImportName(moduleVariableName, imported, dependencyNamedEx
13142
13205
  ? namespaceVariableName
13143
13206
  : moduleVariableName;
13144
13207
  }
13145
- return `${moduleVariableName}${getPropertyAccess(imported)}`;
13208
+ return `${moduleVariableName}${getPropertyAccess(unescapeExportName(imported))}`;
13146
13209
  }
13147
13210
  function getEsModuleValue(getObject) {
13148
13211
  return getObject([['value', 'true']], {
@@ -13318,6 +13381,8 @@ const builtinModules = [
13318
13381
  "module",
13319
13382
  "node:net",
13320
13383
  "net",
13384
+ "node:net/promises",
13385
+ "net/promises",
13321
13386
  "node:os",
13322
13387
  "os",
13323
13388
  "node:path",
@@ -13527,7 +13592,7 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
13527
13592
  importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
13528
13593
  .map(specifier => specifier.imported === specifier.local
13529
13594
  ? specifier.imported
13530
- : `${stringifyIdentifierIfNeeded(specifier.imported)} as ${specifier.local}`)
13595
+ : `${stringifyExportName(specifier.imported)} as ${specifier.local}`)
13531
13596
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13532
13597
  }
13533
13598
  }
@@ -13557,14 +13622,14 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
13557
13622
  for (const specifier of namespaceReexports) {
13558
13623
  importBlock.push(`export${_}{${_}${name === specifier.reexported
13559
13624
  ? name
13560
- : `${name} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`} };`);
13625
+ : `${name} as ${stringifyExportName(specifier.reexported)}`} };`);
13561
13626
  }
13562
13627
  }
13563
13628
  if (namedReexports.length > 0) {
13564
13629
  importBlock.push(`export${_}{${_}${namedReexports
13565
13630
  .map(specifier => specifier.imported === specifier.reexported
13566
- ? stringifyIdentifierIfNeeded(specifier.imported)
13567
- : `${stringifyIdentifierIfNeeded(specifier.imported)} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`)
13631
+ ? stringifyExportName(specifier.imported)
13632
+ : `${stringifyExportName(specifier.imported)} as ${stringifyExportName(specifier.reexported)}`)
13568
13633
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13569
13634
  }
13570
13635
  }
@@ -13582,13 +13647,14 @@ function getExportBlock(exports, { _, cnst }) {
13582
13647
  exportDeclaration[index++] =
13583
13648
  specifier.exported === specifier.local
13584
13649
  ? specifier.local
13585
- : `${specifier.local} as ${stringifyIdentifierIfNeeded(specifier.exported)}`;
13650
+ : `${specifier.local} as ${stringifyExportName(specifier.exported)}`;
13586
13651
  }
13587
13652
  if (exportDeclaration.length > 0) {
13588
13653
  exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
13589
13654
  }
13590
13655
  return exportBlock;
13591
13656
  }
13657
+ const stringifyExportName = (name) => stringifyIdentifierIfNeeded(unescapeExportName(name));
13592
13658
 
13593
13659
  const keypath = (keypath, getPropertyAccess) => keypath.split('.').map(getPropertyAccess).join('');
13594
13660
 
@@ -13774,7 +13840,7 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
13774
13840
  setter.push(`${specifier.local}${_}=${_}module;`);
13775
13841
  }
13776
13842
  else {
13777
- setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(specifier.imported)};`);
13843
+ setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(unescapeExportName(specifier.imported))};`);
13778
13844
  }
13779
13845
  }
13780
13846
  }
@@ -13787,8 +13853,8 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
13787
13853
  }
13788
13854
  else {
13789
13855
  reexportedNames.push([
13790
- reexported,
13791
- imported === '*' ? 'module' : `module${getPropertyAccess(imported)}`
13856
+ unescapeExportName(reexported),
13857
+ imported === '*' ? 'module' : `module${getPropertyAccess(unescapeExportName(imported))}`
13792
13858
  ]);
13793
13859
  }
13794
13860
  }
@@ -13816,13 +13882,13 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
13816
13882
  return { importBindings, setters, starExcludes };
13817
13883
  }
13818
13884
  const getStarExcludes = ({ dependencies, exports }) => {
13819
- const starExcludes = new Set(exports.map(expt => expt.exported));
13885
+ const starExcludes = new Set(exports.map(expt => unescapeExportName(expt.exported)));
13820
13886
  starExcludes.add('default');
13821
13887
  for (const { reexports } of dependencies) {
13822
13888
  if (reexports) {
13823
13889
  for (const reexport of reexports) {
13824
13890
  if (reexport.reexported !== '*')
13825
- starExcludes.add(reexport.reexported);
13891
+ starExcludes.add(unescapeExportName(reexport.reexported));
13826
13892
  }
13827
13893
  }
13828
13894
  }
@@ -13848,11 +13914,11 @@ function getExportsBlock(exports, t, { _, n }) {
13848
13914
  return '';
13849
13915
  }
13850
13916
  if (exports.length === 1) {
13851
- return `exports(${JSON.stringify(exports[0].name)},${_}${exports[0].value});${n}${n}`;
13917
+ return `exports(${JSON.stringify(unescapeExportName(exports[0].name))},${_}${exports[0].value});${n}${n}`;
13852
13918
  }
13853
13919
  return (`exports({${n}` +
13854
13920
  exports
13855
- .map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(name)}:${_}${value}`)
13921
+ .map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(unescapeExportName(name))}:${_}${value}`)
13856
13922
  .join(`,${n}`) +
13857
13923
  `${n}});${n}${n}`);
13858
13924
  }
@@ -19334,6 +19400,11 @@ function decodedSourcemap(map) {
19334
19400
  if (typeof map === 'string') {
19335
19401
  map = JSON.parse(map);
19336
19402
  }
19403
+ // A map this function already returned, e.g. one restored from the cache of a previous build, is
19404
+ // lazy. Reading its mappings below would decode it.
19405
+ if (sourceMapCache.has(map)) {
19406
+ return map;
19407
+ }
19337
19408
  if ('sections' in map) {
19338
19409
  map = flattenIndexSourceMap(map);
19339
19410
  }
@@ -19912,7 +19983,7 @@ class Module {
19912
19983
  exportedVariablesByName.set(name, exportedVariable);
19913
19984
  }
19914
19985
  else {
19915
- return parseAst_js.error(parseAst_js.logMissingEntryExport(name, this.id));
19986
+ return parseAst_js.error(parseAst_js.logMissingEntryExport(unescapeExportName(name), this.id));
19916
19987
  }
19917
19988
  }
19918
19989
  }
@@ -19924,7 +19995,7 @@ class Module {
19924
19995
  }
19925
19996
  for (const module of this.exportAllModules) {
19926
19997
  if (module instanceof ExternalModule) {
19927
- exportedVariablesByName.set(`*${module.id}`, module.getVariableForExportName('*', {
19998
+ exportedVariablesByName.set(getExternalNamespaceExportName(module.id), module.getVariableForExportName('*', {
19928
19999
  importChain: [this.id]
19929
20000
  })[0]);
19930
20001
  continue;
@@ -19984,13 +20055,13 @@ class Module {
19984
20055
  return this.syntheticNamespace;
19985
20056
  }
19986
20057
  getVariableForExportName(name, { importerForSideEffects, importChain = [], isExportAllSearch, onlyExplicit, searchedNamesAndModules, sideEffectModules, exportOrReexportModules } = parseAst_js.EMPTY_OBJECT) {
19987
- if (name[0] === '*') {
20058
+ if (isNamespaceExportName(name)) {
19988
20059
  if (name.length === 1) {
19989
20060
  // export * from './other'
19990
20061
  return [this.namespace];
19991
20062
  }
19992
20063
  // export * from 'external'
19993
- const module = this.graph.modulesById.get(name.slice(1));
20064
+ const module = this.graph.modulesById.get(getExternalNamespaceId(name));
19994
20065
  return module.getVariableForExportName('*', {
19995
20066
  importChain: [...importChain, this.id]
19996
20067
  });
@@ -20000,7 +20071,7 @@ class Module {
20000
20071
  if (reexportDeclaration) {
20001
20072
  const [variable, options] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, [...importChain, this.id], sideEffectModules, exportOrReexportModules);
20002
20073
  if (!variable) {
20003
- return this.error(parseAst_js.logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
20074
+ return this.error(parseAst_js.logMissingExport(unescapeExportName(reexportDeclaration.localName), this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
20004
20075
  }
20005
20076
  if (importerForSideEffects) {
20006
20077
  setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
@@ -20063,7 +20134,7 @@ class Module {
20063
20134
  }
20064
20135
  if (this.info.syntheticNamedExports) {
20065
20136
  return [
20066
- getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, name, this.getSyntheticNamespace()))
20137
+ getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, unescapeExportName(name), this.getSyntheticNamespace()))
20067
20138
  ];
20068
20139
  }
20069
20140
  // we don't want to create shims when we are just
@@ -20202,7 +20273,7 @@ class Module {
20202
20273
  newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
20203
20274
  options: this.options,
20204
20275
  requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
20205
- traceExport: (name) => this.getVariableForExportName(name),
20276
+ traceExport: (name) => this.getVariableForExportName(escapeExportName(name)),
20206
20277
  traceVariable: this.traceVariable.bind(this),
20207
20278
  usesTopLevelAwait: false
20208
20279
  };
@@ -20278,7 +20349,7 @@ class Module {
20278
20349
  }
20279
20350
  const [declaration, options] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules, [this.id], sideEffectModules, exportOrReexportModules);
20280
20351
  if (!declaration) {
20281
- return this.error(parseAst_js.logMissingExport(importDescription.name, this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
20352
+ return this.error(parseAst_js.logMissingExport(unescapeExportName(importDescription.name), this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
20282
20353
  }
20283
20354
  return declaration;
20284
20355
  }
@@ -20316,7 +20387,7 @@ class Module {
20316
20387
  }
20317
20388
  assertUniqueExportName(name, nodeStart) {
20318
20389
  if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
20319
- this.error(parseAst_js.logDuplicateExportError(name), nodeStart);
20390
+ this.error(parseAst_js.logDuplicateExportError(unescapeExportName(name)), nodeStart);
20320
20391
  }
20321
20392
  }
20322
20393
  addExport(node) {
@@ -20333,7 +20404,7 @@ class Module {
20333
20404
  this.addSource(source, node);
20334
20405
  if (node.exported) {
20335
20406
  // export * as name from './other'
20336
- const name = node.exported instanceof Literal ? node.exported.value : node.exported.name;
20407
+ const name = escapeExportName(node.exported instanceof Literal ? node.exported.value : node.exported.name);
20337
20408
  this.assertUniqueExportName(name, node.exported.start);
20338
20409
  this.reexportDescriptions.set(name, {
20339
20410
  localName: '*',
@@ -20352,10 +20423,10 @@ class Module {
20352
20423
  const source = node.source.value;
20353
20424
  this.addSource(source, node);
20354
20425
  for (const { exported, local, start } of node.specifiers) {
20355
- const name = exported instanceof Literal ? exported.value : exported.name;
20426
+ const name = escapeExportName(exported instanceof Literal ? exported.value : exported.name);
20356
20427
  this.assertUniqueExportName(name, start);
20357
20428
  this.reexportDescriptions.set(name, {
20358
- localName: local instanceof Literal ? local.value : local.name,
20429
+ localName: escapeExportName(local instanceof Literal ? local.value : local.name),
20359
20430
  module: null, // filled in later,
20360
20431
  source,
20361
20432
  start
@@ -20386,7 +20457,7 @@ class Module {
20386
20457
  for (const { local, exported } of node.specifiers) {
20387
20458
  // except for reexports, local must be an Identifier
20388
20459
  const localName = local.name;
20389
- const exportedName = exported instanceof Identifier ? exported.name : exported.value;
20460
+ const exportedName = escapeExportName(exported instanceof Identifier ? exported.name : exported.value);
20390
20461
  this.assertUniqueExportName(exportedName, exported.start);
20391
20462
  this.exportDescriptions.set(exportedName, { identifier: null, localName });
20392
20463
  }
@@ -20408,7 +20479,7 @@ class Module {
20408
20479
  ? '*'
20409
20480
  : specifier.imported instanceof Identifier
20410
20481
  ? specifier.imported.name
20411
- : specifier.imported.value;
20482
+ : escapeExportName(specifier.imported.value);
20412
20483
  this.importDescriptions.set(localName, {
20413
20484
  module: null, // filled in later
20414
20485
  name,
@@ -20760,8 +20831,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
20760
20831
  : chunk.variableName);
20761
20832
  }
20762
20833
  else {
20763
- // if the second parameter is `null`, it uses its "name" for the property name
20764
- variable.setRenderNames(chunk.variableName, null);
20834
+ variable.setRenderNames(chunk.variableName, unescapeExportName(name));
20765
20835
  }
20766
20836
  }
20767
20837
  else {
@@ -20773,7 +20843,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
20773
20843
  variable.setRenderNames(null, chunk.variableName);
20774
20844
  }
20775
20845
  else {
20776
- variable.setRenderNames(chunk.variableName, chunk.getVariableExportName(variable));
20846
+ variable.setRenderNames(chunk.variableName, unescapeExportName(chunk.getVariableExportName(variable)));
20777
20847
  }
20778
20848
  }
20779
20849
  }
@@ -20805,36 +20875,6 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
20805
20875
  }
20806
20876
  }
20807
20877
 
20808
- function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
20809
- let nameIndex = 0;
20810
- for (const variable of exports) {
20811
- let [exportName] = variable.name;
20812
- if (exportsByName.has(exportName)) {
20813
- do {
20814
- exportName = toBase64(++nameIndex);
20815
- // skip past leading number identifiers
20816
- if (exportName.charCodeAt(0) === 49 /* '1' */) {
20817
- nameIndex += 9 * 64 ** (exportName.length - 1);
20818
- exportName = toBase64(nameIndex);
20819
- }
20820
- } while (RESERVED_NAMES.has(exportName) || exportsByName.has(exportName));
20821
- }
20822
- exportsByName.set(exportName, variable);
20823
- exportNamesByVariable.set(variable, [exportName]);
20824
- }
20825
- }
20826
- function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
20827
- for (const variable of exports) {
20828
- let nameIndex = 0;
20829
- let exportName = variable.name;
20830
- while (exportsByName.has(exportName)) {
20831
- exportName = variable.name + '$' + ++nameIndex;
20832
- }
20833
- exportsByName.set(exportName, variable);
20834
- exportNamesByVariable.set(variable, [exportName]);
20835
- }
20836
- }
20837
-
20838
20878
  function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, log) {
20839
20879
  const exportKeys = chunk.getExportNames();
20840
20880
  if (exportMode === 'default') {
@@ -21196,7 +21236,8 @@ class Chunk {
21196
21236
  this.facadeModule = module;
21197
21237
  this.facadeChunkByModule.set(module, this);
21198
21238
  this.strictFacade = true;
21199
- this.dynamicName = getChunkNameFromModule(module);
21239
+ this.dynamicName =
21240
+ getPredefinedChunkNameFromModule(module) ?? parseAst_js.getDynamicAliasName(module.id);
21200
21241
  }
21201
21242
  else if (this.facadeModule === module &&
21202
21243
  !this.strictFacade &&
@@ -21511,7 +21552,7 @@ class Chunk {
21511
21552
  getChunkExportDeclarations(format) {
21512
21553
  const exports = [];
21513
21554
  for (const exportName of this.getExportNames()) {
21514
- if (exportName[0] === '*')
21555
+ if (isNamespaceExportName(exportName))
21515
21556
  continue;
21516
21557
  const variable = this.exportsByName.get(exportName);
21517
21558
  if (!(variable instanceof SyntheticNamedExportVariable)) {
@@ -21583,7 +21624,7 @@ class Chunk {
21583
21624
  else if (variable.isNamespace &&
21584
21625
  namespaceInteropHelpersByInteropType[interop(module.id)] &&
21585
21626
  (this.imports.has(variable) ||
21586
- !this.exportNamesByVariable.get(variable)?.every(name => name[0] === '*'))) {
21627
+ !this.exportNamesByVariable.get(variable)?.every(isNamespaceExportName))) {
21587
21628
  // We only need to deconflict it if the namespace is actually
21588
21629
  // created as a variable, i.e. because it is used internally or
21589
21630
  // because it is reexported as an object
@@ -21768,8 +21809,8 @@ class Chunk {
21768
21809
  let dependency;
21769
21810
  let imported;
21770
21811
  let needsLiveBinding;
21771
- if (exportName[0] === '*') {
21772
- const id = exportName.slice(1);
21812
+ if (isNamespaceExportName(exportName)) {
21813
+ const id = getExternalNamespaceId(exportName);
21773
21814
  if (interop(id) === 'defaultOnly') {
21774
21815
  this.inputOptions.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnexpectedNamespaceReexport(id));
21775
21816
  }
@@ -22001,7 +22042,7 @@ class Chunk {
22001
22042
  format !== 'system' &&
22002
22043
  exportVariable.isReassigned &&
22003
22044
  !exportVariable.isId) {
22004
- exportVariable.setRenderNames('exports', exportName);
22045
+ exportVariable.setRenderNames('exports', unescapeExportName(exportName));
22005
22046
  }
22006
22047
  else if (exportVariable instanceof SyntheticNamedExportVariable) {
22007
22048
  syntheticExports.add(exportVariable);
@@ -22329,16 +22370,19 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
22329
22370
  staticDependencies.add(dependency);
22330
22371
  }
22331
22372
  }
22332
- for (const { node: { resolution } } of module.dynamicImports) {
22373
+ for (const { node } of module.dynamicImports) {
22374
+ const { resolution } = node;
22333
22375
  if (resolution instanceof Module &&
22334
22376
  resolution.includedDynamicImporters.length > 0 &&
22335
22377
  (dynamicEntryModules.has(resolution) || !allEntriesSet.has(resolution))) {
22336
22378
  dynamicEntriesForCurrentEntry.add(resolution);
22379
+ if (node.included) {
22380
+ dynamicImportsForCurrentEntry.add(resolution);
22381
+ }
22337
22382
  if (!allEntriesSet.has(resolution)) {
22338
22383
  dynamicEntryModules.add(resolution);
22339
22384
  allEntriesSet.add(resolution);
22340
22385
  allEntriesAndManualChunks.push([resolution]);
22341
- dynamicImportsForCurrentEntry.add(resolution);
22342
22386
  }
22343
22387
  }
22344
22388
  }
@@ -22348,6 +22392,9 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
22348
22392
  allEntriesSet.add(dependency);
22349
22393
  allEntriesAndManualChunks.push([dependency]);
22350
22394
  }
22395
+ if (dynamicEntryModules.has(dependency)) {
22396
+ dynamicImportsForCurrentEntry.add(dependency);
22397
+ }
22351
22398
  }
22352
22399
  }
22353
22400
  // A dynamic import can be awaited indirectly through a static dependency.
@@ -23285,8 +23332,10 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
23285
23332
  if (sourcemap) {
23286
23333
  timeStart('sourcemaps', 3);
23287
23334
  let resultingFile;
23288
- if (file)
23289
- resultingFile = path.resolve(sourcemapFile || file);
23335
+ if (sourcemapFile)
23336
+ resultingFile = path.resolve(sourcemapFile);
23337
+ else if (file)
23338
+ resultingFile = path.resolve(file);
23290
23339
  else if (dir)
23291
23340
  resultingFile = path.resolve(dir, fileName);
23292
23341
  else
@@ -23382,6 +23431,9 @@ function getChunkHash({ code, map, fileName, sourcemapFileName }, outputOptions,
23382
23431
  // replaced with the same value before hashing
23383
23432
  const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
23384
23433
  let contentToHash = transformedCode;
23434
+ if (map && outputOptions.sourcemapDebugIds) {
23435
+ contentToHash += '//# debugId=\n';
23436
+ }
23385
23437
  if (map && outputOptions.sourcemap !== 'hidden') {
23386
23438
  // Normalize raw map data and file names before base64 or URL encoding
23387
23439
  // can hide placeholders and make hashes depend on chunk order.
@@ -24701,7 +24753,7 @@ class Graph {
24701
24753
  if (importDescription.name !== '*' && importDescription.phase !== 'source') {
24702
24754
  const [variable, options] = importDescription.module.getVariableForExportName(importDescription.name, { importChain: [module.id] });
24703
24755
  if (!variable) {
24704
- module.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logMissingExport(importDescription.name, module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
24756
+ module.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logMissingExport(unescapeExportName(importDescription.name), module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
24705
24757
  }
24706
24758
  }
24707
24759
  }