rollup 4.67.5 → 4.68.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 v4.67.5
4
- Wed, 04 Nov 2026 09:26:19 GMT - commit 6b1937666ffaffd346992115283d63336bd2464a
3
+ Rollup.js v4.68.1
4
+ Mon, 09 Nov 2026 05:27:12 GMT - commit d1728b6a134c3a70f53a6961b20b19d4a148d236
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.5";
45
+ var version = "4.68.1";
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
 
@@ -10124,6 +10166,15 @@ class Identifier extends IdentifierBase {
10124
10166
  markDeclarationReached() {
10125
10167
  this.variable.initReached = true;
10126
10168
  }
10169
+ isDeclarationInDestructuringPattern() {
10170
+ let parent = this.parent;
10171
+ while (parent.type === parseAst_js.Property ||
10172
+ parent.type === parseAst_js.AssignmentPattern ||
10173
+ parent.type === parseAst_js.RestElement) {
10174
+ parent = parent.parent;
10175
+ }
10176
+ return parent.type === parseAst_js.ObjectPattern || parent.type === parseAst_js.ArrayPattern;
10177
+ }
10127
10178
  render(code, { snippets: { getPropertyAccess }, useOriginalName }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = parseAst_js.BLANK) {
10128
10179
  if (this.variable) {
10129
10180
  const name = this.variable.getName(getPropertyAccess, useOriginalName);
@@ -11793,7 +11844,7 @@ class ExportDefaultDeclaration extends NodeBase {
11793
11844
  const hasTrailingSemicolon = code.original.charCodeAt(this.end - 1) === 59; /*";"*/
11794
11845
  const systemExportNames = format === 'system' && exportNamesByVariable.get(this.variable);
11795
11846
  if (systemExportNames) {
11796
- code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(systemExportNames[0])}, `);
11847
+ code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(unescapeExportName(systemExportNames[0]))}, `);
11797
11848
  code.appendRight(hasTrailingSemicolon ? this.end - 1 : this.end, ')' + (hasTrailingSemicolon ? '' : ';'));
11798
11849
  return false;
11799
11850
  }
@@ -12028,6 +12079,111 @@ function getToStringTagValue(getObject) {
12028
12079
  });
12029
12080
  }
12030
12081
 
12082
+ class UndefinedVariable extends Variable {
12083
+ constructor() {
12084
+ super('undefined');
12085
+ }
12086
+ getLiteralValueAtPath() {
12087
+ return undefined;
12088
+ }
12089
+ }
12090
+
12091
+ class ExportDefaultVariable extends LocalVariable {
12092
+ constructor(exportDefaultDeclaration, context) {
12093
+ super('default', exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
12094
+ this.hasId = false;
12095
+ this.originalId = null;
12096
+ this.originalVariable = null;
12097
+ const declaration = exportDefaultDeclaration.declaration;
12098
+ if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
12099
+ declaration.id) {
12100
+ this.hasId = true;
12101
+ this.originalId = declaration.id;
12102
+ }
12103
+ else if (declaration instanceof Identifier) {
12104
+ this.originalId = declaration;
12105
+ }
12106
+ }
12107
+ addReference(identifier) {
12108
+ if (!this.hasId) {
12109
+ this.name = identifier.name;
12110
+ }
12111
+ }
12112
+ addUsedPlace(usedPlace) {
12113
+ const original = this.getOriginalVariable();
12114
+ if (original === this) {
12115
+ super.addUsedPlace(usedPlace);
12116
+ }
12117
+ else {
12118
+ original.addUsedPlace(usedPlace);
12119
+ }
12120
+ }
12121
+ forbidName(name) {
12122
+ const original = this.getOriginalVariable();
12123
+ if (original === this) {
12124
+ super.forbidName(name);
12125
+ }
12126
+ else {
12127
+ original.forbidName(name);
12128
+ }
12129
+ }
12130
+ getAssignedVariableName() {
12131
+ return (this.originalId && this.originalId.name) || null;
12132
+ }
12133
+ getBaseVariableName() {
12134
+ const original = this.getOriginalVariable();
12135
+ return original === this ? super.getBaseVariableName() : original.getBaseVariableName();
12136
+ }
12137
+ getDirectOriginalVariable() {
12138
+ return this.originalId &&
12139
+ (this.hasId ||
12140
+ !(this.originalId.isPossibleTDZ() ||
12141
+ this.originalId.variable.isReassigned ||
12142
+ this.originalId.variable instanceof UndefinedVariable ||
12143
+ // this avoids a circular dependency
12144
+ 'syntheticNamespace' in this.originalId.variable))
12145
+ ? this.originalId.variable
12146
+ : null;
12147
+ }
12148
+ /**
12149
+ * Returns the namespace if this default export is just a re-export of a
12150
+ * namespace import. Namespace variables can neither be reassigned nor be
12151
+ * accessed in their TDZ, so this is safe to call while binding.
12152
+ */
12153
+ getOriginalNamespaceVariable() {
12154
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
12155
+ let current = this;
12156
+ const checkedVariables = new Set();
12157
+ while (current instanceof ExportDefaultVariable && !checkedVariables.has(current)) {
12158
+ checkedVariables.add(current);
12159
+ if (current.hasId || !current.originalId)
12160
+ return null;
12161
+ current = current.originalId.variable;
12162
+ }
12163
+ return current?.isNamespace ? current : null;
12164
+ }
12165
+ getName(getPropertyAccess) {
12166
+ const original = this.getOriginalVariable();
12167
+ return original === this
12168
+ ? super.getName(getPropertyAccess)
12169
+ : original.getName(getPropertyAccess);
12170
+ }
12171
+ getOriginalVariable() {
12172
+ if (this.originalVariable)
12173
+ return this.originalVariable;
12174
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
12175
+ let original = this;
12176
+ let currentVariable;
12177
+ const checkedVariables = new Set();
12178
+ do {
12179
+ checkedVariables.add(original);
12180
+ currentVariable = original;
12181
+ original = currentVariable.getDirectOriginalVariable();
12182
+ } while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
12183
+ return (this.originalVariable = original || currentVariable);
12184
+ }
12185
+ }
12186
+
12031
12187
  class Literal extends NodeBase {
12032
12188
  deoptimizeArgumentsOnInteractionAtPath() { }
12033
12189
  getLiteralValueAtPath(path) {
@@ -12162,6 +12318,12 @@ class MemberExpression extends NodeBase {
12162
12318
  set bound(value) {
12163
12319
  this.flags = setFlag(this.flags, 32 /* Flag.bound */, value);
12164
12320
  }
12321
+ get deleteOfMissingNamespaceMember() {
12322
+ return isFlagSet(this.flags, 536870912 /* Flag.deleteOfMissingNamespaceMember */);
12323
+ }
12324
+ set deleteOfMissingNamespaceMember(value) {
12325
+ this.flags = setFlag(this.flags, 536870912 /* Flag.deleteOfMissingNamespaceMember */, value);
12326
+ }
12165
12327
  get isUndefined() {
12166
12328
  return isFlagSet(this.flags, 64 /* Flag.isUndefined */);
12167
12329
  }
@@ -12171,10 +12333,15 @@ class MemberExpression extends NodeBase {
12171
12333
  bind() {
12172
12334
  this.bound = true;
12173
12335
  const path = getPathIfNotComputed(this);
12174
- const baseVariable = path && this.scope.findVariable(path[0].key);
12336
+ let baseVariable = path && this.scope.findVariable(path[0].key);
12337
+ if (baseVariable instanceof ExportDefaultVariable) {
12338
+ baseVariable = baseVariable.getOriginalNamespaceVariable() || baseVariable;
12339
+ }
12175
12340
  if (baseVariable?.isNamespace) {
12176
12341
  const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.scope.context);
12177
- if (!resolvedVariable) {
12342
+ const isDelete = this.isDeleteTarget();
12343
+ if (!resolvedVariable || this.assignmentInteraction || isDelete) {
12344
+ this.deleteOfMissingNamespaceMember = isDelete && resolvedVariable === 'undefined';
12178
12345
  super.bind();
12179
12346
  }
12180
12347
  else if (resolvedVariable === 'undefined') {
@@ -12483,15 +12650,9 @@ class MemberExpression extends NodeBase {
12483
12650
  }
12484
12651
  }
12485
12652
  disallowNamespaceReassignment() {
12486
- if (this.object instanceof Identifier) {
12487
- const variable = this.scope.findVariable(this.object.name);
12488
- if (variable.isNamespace) {
12489
- if (this.variable) {
12490
- this.scope.context.includeVariableInModule(this.variable, UNKNOWN_PATH, createInclusionContext());
12491
- }
12492
- this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
12493
- }
12494
- }
12653
+ if (!this.getNamespaceVariableOfObject() || this.deleteOfMissingNamespaceMember)
12654
+ return;
12655
+ this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logIllegalImportReassignment(this.getNamespaceName(), this.scope.context.module.id), this.start);
12495
12656
  }
12496
12657
  getDynamicPropertyKey() {
12497
12658
  if (this.dynamicPropertyKey === null) {
@@ -12506,6 +12667,27 @@ class MemberExpression extends NodeBase {
12506
12667
  }
12507
12668
  return this.dynamicPropertyKey;
12508
12669
  }
12670
+ getNamespaceName() {
12671
+ return this.object instanceof Identifier
12672
+ ? this.object.name
12673
+ : getStringFromPath(getPathIfNotComputed(this.object));
12674
+ }
12675
+ getNamespaceVariableOfObject() {
12676
+ let variable;
12677
+ if (this.object instanceof Identifier) {
12678
+ variable = this.scope.findVariable(this.object.name);
12679
+ }
12680
+ else if (this.object instanceof MemberExpression) {
12681
+ variable = this.object.variable;
12682
+ }
12683
+ else {
12684
+ return null;
12685
+ }
12686
+ if (variable instanceof ExportDefaultVariable) {
12687
+ variable = variable.getOriginalNamespaceVariable() || variable;
12688
+ }
12689
+ return variable?.isNamespace ? variable : null;
12690
+ }
12509
12691
  hasAccessEffect(context) {
12510
12692
  const { propertyReadSideEffects } = this.scope.context.options
12511
12693
  .treeshake;
@@ -12514,6 +12696,10 @@ class MemberExpression extends NodeBase {
12514
12696
  (propertyReadSideEffects === 'always' ||
12515
12697
  this.object.hasEffectsOnInteractionAtPath([this.getDynamicPropertyKey()], this.accessInteraction, context)));
12516
12698
  }
12699
+ isDeleteTarget() {
12700
+ const parent = this.parent.type === parseAst_js.ChainExpression ? this.parent.parent : this.parent;
12701
+ return (parent.type === parseAst_js.UnaryExpression && parent.operator === 'delete');
12702
+ }
12517
12703
  }
12518
12704
  function resolveNamespaceVariables(baseVariable, path, astContext) {
12519
12705
  if (path.length === 0)
@@ -12677,94 +12863,6 @@ const importMetaMechanisms = {
12677
12863
  umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename', false)} : ${getUrlFromDocument(chunkId, true)})`)
12678
12864
  };
12679
12865
 
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
12866
  class NamespaceVariable extends Variable {
12769
12867
  constructor(context) {
12770
12868
  super(context.getModuleName());
@@ -12784,10 +12882,7 @@ class NamespaceVariable extends Variable {
12784
12882
  if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) {
12785
12883
  const key = path[0];
12786
12884
  if (typeof key === 'string') {
12787
- this.module
12788
- .getExportedVariablesByName()
12789
- .get(key)
12790
- ?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
12885
+ this.getMemberVariable(key)?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
12791
12886
  }
12792
12887
  else {
12793
12888
  deoptimizeInteraction(interaction);
@@ -12798,7 +12893,7 @@ class NamespaceVariable extends Variable {
12798
12893
  if (path.length > 1) {
12799
12894
  const key = path[0];
12800
12895
  if (typeof key === 'string') {
12801
- this.module.getExportedVariablesByName().get(key)?.deoptimizePath(path.slice(1));
12896
+ this.getMemberVariable(key)?.deoptimizePath(path.slice(1));
12802
12897
  }
12803
12898
  else if (!this.areAllMembersDeoptimized) {
12804
12899
  this.areAllMembersDeoptimized = true;
@@ -12827,7 +12922,7 @@ class NamespaceVariable extends Variable {
12827
12922
  if (typeof key !== 'string') {
12828
12923
  return true;
12829
12924
  }
12830
- const memberVariable = this.module.getExportedVariablesByName().get(key);
12925
+ const memberVariable = this.getMemberVariable(key);
12831
12926
  return (!memberVariable ||
12832
12927
  memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
12833
12928
  }
@@ -12839,7 +12934,7 @@ class NamespaceVariable extends Variable {
12839
12934
  if (path.length > 0) {
12840
12935
  const [name, ...remainingPath] = path;
12841
12936
  if (typeof name === 'string') {
12842
- const variable = this.module.getExportedVariablesByName().get(name);
12937
+ const variable = this.getMemberVariable(name);
12843
12938
  if (variable) {
12844
12939
  this.context.includeVariableInModule(variable, remainingPath, context);
12845
12940
  }
@@ -12862,15 +12957,21 @@ class NamespaceVariable extends Variable {
12862
12957
  const { exportNamesByVariable, format, freeze, indent: t, symbols, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
12863
12958
  const memberVariables = this.module.getExportedVariablesByName();
12864
12959
  const members = [...memberVariables.entries()]
12865
- .filter(([name, variable]) => !name.startsWith('*') && variable.included)
12960
+ .filter(([name, variable]) => !isNamespaceExportName(name) && variable.included)
12866
12961
  .map(([name, variable]) => {
12867
- if (this.referencedEarly || variable.isReassigned || variable === this) {
12962
+ const key = unescapeExportName(name);
12963
+ if (this.referencedEarly ||
12964
+ variable.isReassigned ||
12965
+ variable === this ||
12966
+ (variable.module &&
12967
+ !variable.module.info.isExternal &&
12968
+ variable.module.execIndex > this.module.execIndex)) {
12868
12969
  return [
12869
12970
  null,
12870
- `get ${stringifyObjectKeyIfNeeded(name)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
12971
+ `get ${stringifyObjectKeyIfNeeded(key)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
12871
12972
  ];
12872
12973
  }
12873
- return [name, variable.getName(getPropertyAccess)];
12974
+ return [key, variable.getName(getPropertyAccess)];
12874
12975
  });
12875
12976
  members.unshift([null, `__proto__:${_}null`]);
12876
12977
  let output = getObject(members, { lineBreakIndent: { base: '', t } });
@@ -12908,6 +13009,9 @@ class NamespaceVariable extends Variable {
12908
13009
  }
12909
13010
  }
12910
13011
  }
13012
+ getMemberVariable(name) {
13013
+ return this.module.getExportedVariablesByName().get(escapeExportName(name));
13014
+ }
12911
13015
  includeNonExplicitNamespaces() {
12912
13016
  if (!this.nonExplicitNamespacesIncluded) {
12913
13017
  this.nonExplicitNamespacesIncluded = true;
@@ -13042,7 +13146,7 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
13042
13146
  if (exportBlock)
13043
13147
  exportBlock += n;
13044
13148
  if (specifier.imported !== '*' && specifier.needsLiveBinding) {
13045
- exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(specifier.reexported)},${_}${getGetter(importName, false, t, snippets)});`;
13149
+ exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(specifier.reexported))},${_}${getGetter(importName, false, t, snippets)});`;
13046
13150
  }
13047
13151
  else if (specifier.reexported === '__proto__') {
13048
13152
  exportBlock +=
@@ -13051,20 +13155,20 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
13051
13155
  `${t}value:${_}${importName}${n}});`;
13052
13156
  }
13053
13157
  else {
13054
- exportBlock += `exports${getPropertyAccess(specifier.reexported)}${_}=${_}${importName};`;
13158
+ exportBlock += `exports${getPropertyAccess(unescapeExportName(specifier.reexported))}${_}=${_}${importName};`;
13055
13159
  }
13056
13160
  }
13057
13161
  }
13058
13162
  }
13059
13163
  }
13060
13164
  for (const { exported, local, needsLiveBinding } of exports) {
13061
- const lhs = `exports${getPropertyAccess(exported)}`;
13165
+ const lhs = `exports${getPropertyAccess(unescapeExportName(exported))}`;
13062
13166
  const rhs = local;
13063
13167
  if (lhs !== rhs) {
13064
13168
  if (exportBlock)
13065
13169
  exportBlock += n;
13066
13170
  if (needsLiveBinding) {
13067
- exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(exported)},${_}${getGetter(rhs, true, t, snippets)});`;
13171
+ exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(exported))},${_}${getGetter(rhs, true, t, snippets)});`;
13068
13172
  continue;
13069
13173
  }
13070
13174
  exportBlock +=
@@ -13142,7 +13246,7 @@ function getReexportedImportName(moduleVariableName, imported, dependencyNamedEx
13142
13246
  ? namespaceVariableName
13143
13247
  : moduleVariableName;
13144
13248
  }
13145
- return `${moduleVariableName}${getPropertyAccess(imported)}`;
13249
+ return `${moduleVariableName}${getPropertyAccess(unescapeExportName(imported))}`;
13146
13250
  }
13147
13251
  function getEsModuleValue(getObject) {
13148
13252
  return getObject([['value', 'true']], {
@@ -13318,6 +13422,8 @@ const builtinModules = [
13318
13422
  "module",
13319
13423
  "node:net",
13320
13424
  "net",
13425
+ "node:net/promises",
13426
+ "net/promises",
13321
13427
  "node:os",
13322
13428
  "os",
13323
13429
  "node:path",
@@ -13527,7 +13633,7 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
13527
13633
  importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
13528
13634
  .map(specifier => specifier.imported === specifier.local
13529
13635
  ? specifier.imported
13530
- : `${stringifyIdentifierIfNeeded(specifier.imported)} as ${specifier.local}`)
13636
+ : `${stringifyExportName(specifier.imported)} as ${specifier.local}`)
13531
13637
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13532
13638
  }
13533
13639
  }
@@ -13557,14 +13663,14 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
13557
13663
  for (const specifier of namespaceReexports) {
13558
13664
  importBlock.push(`export${_}{${_}${name === specifier.reexported
13559
13665
  ? name
13560
- : `${name} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`} };`);
13666
+ : `${name} as ${stringifyExportName(specifier.reexported)}`} };`);
13561
13667
  }
13562
13668
  }
13563
13669
  if (namedReexports.length > 0) {
13564
13670
  importBlock.push(`export${_}{${_}${namedReexports
13565
13671
  .map(specifier => specifier.imported === specifier.reexported
13566
- ? stringifyIdentifierIfNeeded(specifier.imported)
13567
- : `${stringifyIdentifierIfNeeded(specifier.imported)} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`)
13672
+ ? stringifyExportName(specifier.imported)
13673
+ : `${stringifyExportName(specifier.imported)} as ${stringifyExportName(specifier.reexported)}`)
13568
13674
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13569
13675
  }
13570
13676
  }
@@ -13582,13 +13688,14 @@ function getExportBlock(exports, { _, cnst }) {
13582
13688
  exportDeclaration[index++] =
13583
13689
  specifier.exported === specifier.local
13584
13690
  ? specifier.local
13585
- : `${specifier.local} as ${stringifyIdentifierIfNeeded(specifier.exported)}`;
13691
+ : `${specifier.local} as ${stringifyExportName(specifier.exported)}`;
13586
13692
  }
13587
13693
  if (exportDeclaration.length > 0) {
13588
13694
  exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
13589
13695
  }
13590
13696
  return exportBlock;
13591
13697
  }
13698
+ const stringifyExportName = (name) => stringifyIdentifierIfNeeded(unescapeExportName(name));
13592
13699
 
13593
13700
  const keypath = (keypath, getPropertyAccess) => keypath.split('.').map(getPropertyAccess).join('');
13594
13701
 
@@ -13774,7 +13881,7 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
13774
13881
  setter.push(`${specifier.local}${_}=${_}module;`);
13775
13882
  }
13776
13883
  else {
13777
- setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(specifier.imported)};`);
13884
+ setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(unescapeExportName(specifier.imported))};`);
13778
13885
  }
13779
13886
  }
13780
13887
  }
@@ -13787,8 +13894,8 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
13787
13894
  }
13788
13895
  else {
13789
13896
  reexportedNames.push([
13790
- reexported,
13791
- imported === '*' ? 'module' : `module${getPropertyAccess(imported)}`
13897
+ unescapeExportName(reexported),
13898
+ imported === '*' ? 'module' : `module${getPropertyAccess(unescapeExportName(imported))}`
13792
13899
  ]);
13793
13900
  }
13794
13901
  }
@@ -13816,13 +13923,13 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
13816
13923
  return { importBindings, setters, starExcludes };
13817
13924
  }
13818
13925
  const getStarExcludes = ({ dependencies, exports }) => {
13819
- const starExcludes = new Set(exports.map(expt => expt.exported));
13926
+ const starExcludes = new Set(exports.map(expt => unescapeExportName(expt.exported)));
13820
13927
  starExcludes.add('default');
13821
13928
  for (const { reexports } of dependencies) {
13822
13929
  if (reexports) {
13823
13930
  for (const reexport of reexports) {
13824
13931
  if (reexport.reexported !== '*')
13825
- starExcludes.add(reexport.reexported);
13932
+ starExcludes.add(unescapeExportName(reexport.reexported));
13826
13933
  }
13827
13934
  }
13828
13935
  }
@@ -13848,11 +13955,11 @@ function getExportsBlock(exports, t, { _, n }) {
13848
13955
  return '';
13849
13956
  }
13850
13957
  if (exports.length === 1) {
13851
- return `exports(${JSON.stringify(exports[0].name)},${_}${exports[0].value});${n}${n}`;
13958
+ return `exports(${JSON.stringify(unescapeExportName(exports[0].name))},${_}${exports[0].value});${n}${n}`;
13852
13959
  }
13853
13960
  return (`exports({${n}` +
13854
13961
  exports
13855
- .map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(name)}:${_}${value}`)
13962
+ .map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(unescapeExportName(name))}:${_}${value}`)
13856
13963
  .join(`,${n}`) +
13857
13964
  `${n}});${n}${n}`);
13858
13965
  }
@@ -15026,6 +15133,9 @@ CatchClause.prototype.includeNode = onlyIncludeSelf;
15026
15133
  class ChainExpression extends NodeBase {
15027
15134
  // deoptimizations are not relevant as we are not caching values
15028
15135
  deoptimizeCache() { }
15136
+ deoptimizePath(path) {
15137
+ this.expression.deoptimizePath(path);
15138
+ }
15029
15139
  getLiteralValueAtPath(path, recursionTracker, origin) {
15030
15140
  const literalValue = this.expression.getLiteralValueAtPathAsChainElement(path, recursionTracker, origin);
15031
15141
  return literalValue === IS_SKIPPED_CHAIN ? undefined : literalValue;
@@ -19334,6 +19444,11 @@ function decodedSourcemap(map) {
19334
19444
  if (typeof map === 'string') {
19335
19445
  map = JSON.parse(map);
19336
19446
  }
19447
+ // A map this function already returned, e.g. one restored from the cache of a previous build, is
19448
+ // lazy. Reading its mappings below would decode it.
19449
+ if (sourceMapCache.has(map)) {
19450
+ return map;
19451
+ }
19337
19452
  if ('sections' in map) {
19338
19453
  map = flattenIndexSourceMap(map);
19339
19454
  }
@@ -19912,7 +20027,7 @@ class Module {
19912
20027
  exportedVariablesByName.set(name, exportedVariable);
19913
20028
  }
19914
20029
  else {
19915
- return parseAst_js.error(parseAst_js.logMissingEntryExport(name, this.id));
20030
+ return parseAst_js.error(parseAst_js.logMissingEntryExport(unescapeExportName(name), this.id));
19916
20031
  }
19917
20032
  }
19918
20033
  }
@@ -19924,7 +20039,7 @@ class Module {
19924
20039
  }
19925
20040
  for (const module of this.exportAllModules) {
19926
20041
  if (module instanceof ExternalModule) {
19927
- exportedVariablesByName.set(`*${module.id}`, module.getVariableForExportName('*', {
20042
+ exportedVariablesByName.set(getExternalNamespaceExportName(module.id), module.getVariableForExportName('*', {
19928
20043
  importChain: [this.id]
19929
20044
  })[0]);
19930
20045
  continue;
@@ -19984,13 +20099,13 @@ class Module {
19984
20099
  return this.syntheticNamespace;
19985
20100
  }
19986
20101
  getVariableForExportName(name, { importerForSideEffects, importChain = [], isExportAllSearch, onlyExplicit, searchedNamesAndModules, sideEffectModules, exportOrReexportModules } = parseAst_js.EMPTY_OBJECT) {
19987
- if (name[0] === '*') {
20102
+ if (isNamespaceExportName(name)) {
19988
20103
  if (name.length === 1) {
19989
20104
  // export * from './other'
19990
20105
  return [this.namespace];
19991
20106
  }
19992
20107
  // export * from 'external'
19993
- const module = this.graph.modulesById.get(name.slice(1));
20108
+ const module = this.graph.modulesById.get(getExternalNamespaceId(name));
19994
20109
  return module.getVariableForExportName('*', {
19995
20110
  importChain: [...importChain, this.id]
19996
20111
  });
@@ -20000,7 +20115,7 @@ class Module {
20000
20115
  if (reexportDeclaration) {
20001
20116
  const [variable, options] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, [...importChain, this.id], sideEffectModules, exportOrReexportModules);
20002
20117
  if (!variable) {
20003
- return this.error(parseAst_js.logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
20118
+ return this.error(parseAst_js.logMissingExport(unescapeExportName(reexportDeclaration.localName), this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
20004
20119
  }
20005
20120
  if (importerForSideEffects) {
20006
20121
  setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
@@ -20063,7 +20178,7 @@ class Module {
20063
20178
  }
20064
20179
  if (this.info.syntheticNamedExports) {
20065
20180
  return [
20066
- getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, name, this.getSyntheticNamespace()))
20181
+ getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, unescapeExportName(name), this.getSyntheticNamespace()))
20067
20182
  ];
20068
20183
  }
20069
20184
  // we don't want to create shims when we are just
@@ -20202,7 +20317,7 @@ class Module {
20202
20317
  newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
20203
20318
  options: this.options,
20204
20319
  requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
20205
- traceExport: (name) => this.getVariableForExportName(name),
20320
+ traceExport: (name) => this.getVariableForExportName(escapeExportName(name)),
20206
20321
  traceVariable: this.traceVariable.bind(this),
20207
20322
  usesTopLevelAwait: false
20208
20323
  };
@@ -20278,7 +20393,7 @@ class Module {
20278
20393
  }
20279
20394
  const [declaration, options] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules, [this.id], sideEffectModules, exportOrReexportModules);
20280
20395
  if (!declaration) {
20281
- return this.error(parseAst_js.logMissingExport(importDescription.name, this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
20396
+ return this.error(parseAst_js.logMissingExport(unescapeExportName(importDescription.name), this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
20282
20397
  }
20283
20398
  return declaration;
20284
20399
  }
@@ -20316,7 +20431,7 @@ class Module {
20316
20431
  }
20317
20432
  assertUniqueExportName(name, nodeStart) {
20318
20433
  if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
20319
- this.error(parseAst_js.logDuplicateExportError(name), nodeStart);
20434
+ this.error(parseAst_js.logDuplicateExportError(unescapeExportName(name)), nodeStart);
20320
20435
  }
20321
20436
  }
20322
20437
  addExport(node) {
@@ -20333,7 +20448,7 @@ class Module {
20333
20448
  this.addSource(source, node);
20334
20449
  if (node.exported) {
20335
20450
  // export * as name from './other'
20336
- const name = node.exported instanceof Literal ? node.exported.value : node.exported.name;
20451
+ const name = escapeExportName(node.exported instanceof Literal ? node.exported.value : node.exported.name);
20337
20452
  this.assertUniqueExportName(name, node.exported.start);
20338
20453
  this.reexportDescriptions.set(name, {
20339
20454
  localName: '*',
@@ -20352,10 +20467,10 @@ class Module {
20352
20467
  const source = node.source.value;
20353
20468
  this.addSource(source, node);
20354
20469
  for (const { exported, local, start } of node.specifiers) {
20355
- const name = exported instanceof Literal ? exported.value : exported.name;
20470
+ const name = escapeExportName(exported instanceof Literal ? exported.value : exported.name);
20356
20471
  this.assertUniqueExportName(name, start);
20357
20472
  this.reexportDescriptions.set(name, {
20358
- localName: local instanceof Literal ? local.value : local.name,
20473
+ localName: escapeExportName(local instanceof Literal ? local.value : local.name),
20359
20474
  module: null, // filled in later,
20360
20475
  source,
20361
20476
  start
@@ -20386,7 +20501,7 @@ class Module {
20386
20501
  for (const { local, exported } of node.specifiers) {
20387
20502
  // except for reexports, local must be an Identifier
20388
20503
  const localName = local.name;
20389
- const exportedName = exported instanceof Identifier ? exported.name : exported.value;
20504
+ const exportedName = escapeExportName(exported instanceof Identifier ? exported.name : exported.value);
20390
20505
  this.assertUniqueExportName(exportedName, exported.start);
20391
20506
  this.exportDescriptions.set(exportedName, { identifier: null, localName });
20392
20507
  }
@@ -20408,7 +20523,7 @@ class Module {
20408
20523
  ? '*'
20409
20524
  : specifier.imported instanceof Identifier
20410
20525
  ? specifier.imported.name
20411
- : specifier.imported.value;
20526
+ : escapeExportName(specifier.imported.value);
20412
20527
  this.importDescriptions.set(localName, {
20413
20528
  module: null, // filled in later
20414
20529
  name,
@@ -20760,8 +20875,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
20760
20875
  : chunk.variableName);
20761
20876
  }
20762
20877
  else {
20763
- // if the second parameter is `null`, it uses its "name" for the property name
20764
- variable.setRenderNames(chunk.variableName, null);
20878
+ variable.setRenderNames(chunk.variableName, unescapeExportName(name));
20765
20879
  }
20766
20880
  }
20767
20881
  else {
@@ -20773,7 +20887,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
20773
20887
  variable.setRenderNames(null, chunk.variableName);
20774
20888
  }
20775
20889
  else {
20776
- variable.setRenderNames(chunk.variableName, chunk.getVariableExportName(variable));
20890
+ variable.setRenderNames(chunk.variableName, unescapeExportName(chunk.getVariableExportName(variable)));
20777
20891
  }
20778
20892
  }
20779
20893
  }
@@ -20805,36 +20919,6 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
20805
20919
  }
20806
20920
  }
20807
20921
 
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
20922
  function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, log) {
20839
20923
  const exportKeys = chunk.getExportNames();
20840
20924
  if (exportMode === 'default') {
@@ -21196,7 +21280,8 @@ class Chunk {
21196
21280
  this.facadeModule = module;
21197
21281
  this.facadeChunkByModule.set(module, this);
21198
21282
  this.strictFacade = true;
21199
- this.dynamicName = getChunkNameFromModule(module);
21283
+ this.dynamicName =
21284
+ getPredefinedChunkNameFromModule(module) ?? parseAst_js.getDynamicAliasName(module.id);
21200
21285
  }
21201
21286
  else if (this.facadeModule === module &&
21202
21287
  !this.strictFacade &&
@@ -21511,7 +21596,7 @@ class Chunk {
21511
21596
  getChunkExportDeclarations(format) {
21512
21597
  const exports = [];
21513
21598
  for (const exportName of this.getExportNames()) {
21514
- if (exportName[0] === '*')
21599
+ if (isNamespaceExportName(exportName))
21515
21600
  continue;
21516
21601
  const variable = this.exportsByName.get(exportName);
21517
21602
  if (!(variable instanceof SyntheticNamedExportVariable)) {
@@ -21559,7 +21644,10 @@ class Chunk {
21559
21644
  expression,
21560
21645
  hoisted,
21561
21646
  local,
21562
- needsLiveBinding: variable.isReassigned && this.exportNamesByVariable.get(variable).length > 1
21647
+ needsLiveBinding: (variable.isReassigned && this.exportNamesByVariable.get(variable).length > 1) ||
21648
+ // Pattern bindings are plain locals; a trailing assignment
21649
+ // would lose later reassignments.
21650
+ (variable.isTargetOfAssignment && isDeclaredInDestructuringPattern(variable))
21563
21651
  });
21564
21652
  }
21565
21653
  return exports;
@@ -21583,7 +21671,7 @@ class Chunk {
21583
21671
  else if (variable.isNamespace &&
21584
21672
  namespaceInteropHelpersByInteropType[interop(module.id)] &&
21585
21673
  (this.imports.has(variable) ||
21586
- !this.exportNamesByVariable.get(variable)?.every(name => name[0] === '*'))) {
21674
+ !this.exportNamesByVariable.get(variable)?.every(isNamespaceExportName))) {
21587
21675
  // We only need to deconflict it if the namespace is actually
21588
21676
  // created as a variable, i.e. because it is used internally or
21589
21677
  // because it is reexported as an object
@@ -21768,8 +21856,8 @@ class Chunk {
21768
21856
  let dependency;
21769
21857
  let imported;
21770
21858
  let needsLiveBinding;
21771
- if (exportName[0] === '*') {
21772
- const id = exportName.slice(1);
21859
+ if (isNamespaceExportName(exportName)) {
21860
+ const id = getExternalNamespaceId(exportName);
21773
21861
  if (interop(id) === 'defaultOnly') {
21774
21862
  this.inputOptions.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnexpectedNamespaceReexport(id));
21775
21863
  }
@@ -22000,8 +22088,9 @@ class Chunk {
22000
22088
  if (format !== 'es' &&
22001
22089
  format !== 'system' &&
22002
22090
  exportVariable.isReassigned &&
22003
- !exportVariable.isId) {
22004
- exportVariable.setRenderNames('exports', exportName);
22091
+ !exportVariable.isId &&
22092
+ !isDeclaredInDestructuringPattern(exportVariable)) {
22093
+ exportVariable.setRenderNames('exports', unescapeExportName(exportName));
22005
22094
  }
22006
22095
  else if (exportVariable instanceof SyntheticNamedExportVariable) {
22007
22096
  syntheticExports.add(exportVariable);
@@ -22086,6 +22175,10 @@ class Chunk {
22086
22175
  function getChunkNameFromModule(module) {
22087
22176
  return getPredefinedChunkNameFromModule(module) ?? parseAst_js.getAliasName(module.id);
22088
22177
  }
22178
+ function isDeclaredInDestructuringPattern(variable) {
22179
+ return (variable instanceof LocalVariable &&
22180
+ variable.declarations.some(declaration => declaration instanceof Identifier && declaration.isDeclarationInDestructuringPattern()));
22181
+ }
22089
22182
  function getPredefinedChunkNameFromModule(module) {
22090
22183
  return (module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? module.chunkNames[0]?.name);
22091
22184
  }
@@ -22329,16 +22422,19 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
22329
22422
  staticDependencies.add(dependency);
22330
22423
  }
22331
22424
  }
22332
- for (const { node: { resolution } } of module.dynamicImports) {
22425
+ for (const { node } of module.dynamicImports) {
22426
+ const { resolution } = node;
22333
22427
  if (resolution instanceof Module &&
22334
22428
  resolution.includedDynamicImporters.length > 0 &&
22335
22429
  (dynamicEntryModules.has(resolution) || !allEntriesSet.has(resolution))) {
22336
22430
  dynamicEntriesForCurrentEntry.add(resolution);
22431
+ if (node.included) {
22432
+ dynamicImportsForCurrentEntry.add(resolution);
22433
+ }
22337
22434
  if (!allEntriesSet.has(resolution)) {
22338
22435
  dynamicEntryModules.add(resolution);
22339
22436
  allEntriesSet.add(resolution);
22340
22437
  allEntriesAndManualChunks.push([resolution]);
22341
- dynamicImportsForCurrentEntry.add(resolution);
22342
22438
  }
22343
22439
  }
22344
22440
  }
@@ -22348,6 +22444,9 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
22348
22444
  allEntriesSet.add(dependency);
22349
22445
  allEntriesAndManualChunks.push([dependency]);
22350
22446
  }
22447
+ if (dynamicEntryModules.has(dependency)) {
22448
+ dynamicImportsForCurrentEntry.add(dependency);
22449
+ }
22351
22450
  }
22352
22451
  }
22353
22452
  // A dynamic import can be awaited indirectly through a static dependency.
@@ -24706,7 +24805,7 @@ class Graph {
24706
24805
  if (importDescription.name !== '*' && importDescription.phase !== 'source') {
24707
24806
  const [variable, options] = importDescription.module.getVariableForExportName(importDescription.name, { importChain: [module.id] });
24708
24807
  if (!variable) {
24709
- module.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logMissingExport(importDescription.name, module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
24808
+ module.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logMissingExport(unescapeExportName(importDescription.name), module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
24710
24809
  }
24711
24810
  }
24712
24811
  }