@rollup/wasm-node 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,13 +1,13 @@
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
 
8
8
  Released under the MIT License.
9
9
  */
10
- import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, FunctionExpression as FunctionExpression$1, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, logMissingExport, normalize, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, RestElement as RestElement$1, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, isAbsolute as isAbsolute$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logMissingEntryExport, logSyntheticNamedExportsNeedNamespaceExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logInvalidFormatForTopLevelAwait, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logErrorInHook, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, URL_LOAD, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
10
+ import { EMPTY_OBJECT, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ArrowFunctionExpression as ArrowFunctionExpression$1, FunctionExpression as FunctionExpression$1, Identifier as Identifier$1, ExpressionStatement as ExpressionStatement$1, AwaitExpression as AwaitExpression$1, MemberExpression as MemberExpression$1, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, ObjectPattern as ObjectPattern$1, ArrayPattern as ArrayPattern$1, BLANK, AssignmentPattern as AssignmentPattern$1, RestElement as RestElement$1, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, UnaryExpression as UnaryExpression$1, ChainExpression as ChainExpression$1, logMissingExport, normalize, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, isAbsolute as isAbsolute$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logMissingEntryExport, logSyntheticNamedExportsNeedNamespaceExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logCircularReexport, logInvalidFormatForTopLevelAwait, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, getDynamicAliasName, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logErrorInHook, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logFileNameOutsideOutputDirectory, logCannotAssignModuleToChunk, logCircularChunk, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logAnonymousPluginCache, logDuplicatePluginName, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, warnDeprecation, URL_TRANSFORM, relativeId, logBadLoader, logNonExternalSourcePhaseImport, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logExternalModulesCannotBeTransformedToModules, URL_LOAD, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logChunkNotGeneratedForFileName, logAssetNotFinalisedForFileName, logFileNameConflict, URL_GENERATEBUNDLE, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidAddonPluginHook, logInvalidFunctionPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_GENERATEDCODE, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_MANUALCHUNKS, logInvalidExportOptionValue, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_INTEROP, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
11
11
  import { relative, dirname, basename, extname, resolve as resolve$1, join } from 'node:path';
12
12
  import { isAbsolute, posix, win32, resolve } from 'path';
13
13
  import { parseAsync, xxhashBase16, xxhashBase64Url, xxhashBase36 } from '../../native.js';
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
27
27
  return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
28
28
  }
29
29
 
30
- var version = "4.67.5";
30
+ var version = "4.68.1";
31
31
  const pkg = {
32
32
  version: version};
33
33
 
@@ -2086,6 +2086,109 @@ var Bundle$1 = class Bundle {
2086
2086
  }
2087
2087
  };
2088
2088
 
2089
+ const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
2090
+ const base = 64;
2091
+ function toBase64(value) {
2092
+ let outString = '';
2093
+ do {
2094
+ const currentDigit = value % base;
2095
+ value = (value / base) | 0;
2096
+ outString = chars[currentDigit] + outString;
2097
+ } while (value !== 0);
2098
+ return outString;
2099
+ }
2100
+
2101
+ const RESERVED_NAMES = new Set([
2102
+ 'await',
2103
+ 'break',
2104
+ 'case',
2105
+ 'catch',
2106
+ 'class',
2107
+ 'const',
2108
+ 'continue',
2109
+ 'debugger',
2110
+ 'default',
2111
+ 'delete',
2112
+ 'do',
2113
+ 'else',
2114
+ 'enum',
2115
+ 'eval',
2116
+ 'export',
2117
+ 'extends',
2118
+ 'false',
2119
+ 'finally',
2120
+ 'for',
2121
+ 'function',
2122
+ 'if',
2123
+ 'implements',
2124
+ 'import',
2125
+ 'in',
2126
+ 'instanceof',
2127
+ 'interface',
2128
+ 'let',
2129
+ 'NaN',
2130
+ 'new',
2131
+ 'null',
2132
+ 'package',
2133
+ 'private',
2134
+ 'protected',
2135
+ 'public',
2136
+ 'return',
2137
+ 'static',
2138
+ 'super',
2139
+ 'switch',
2140
+ 'this',
2141
+ 'throw',
2142
+ 'true',
2143
+ 'try',
2144
+ 'typeof',
2145
+ 'undefined',
2146
+ 'var',
2147
+ 'void',
2148
+ 'while',
2149
+ 'with',
2150
+ 'yield'
2151
+ ]);
2152
+
2153
+ function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
2154
+ let nameIndex = 0;
2155
+ for (const variable of exports) {
2156
+ let [exportName] = variable.name;
2157
+ if (exportsByName.has(exportName)) {
2158
+ do {
2159
+ exportName = toBase64(++nameIndex);
2160
+ // skip past leading number identifiers
2161
+ if (exportName.charCodeAt(0) === 49 /* '1' */) {
2162
+ nameIndex += 9 * 64 ** (exportName.length - 1);
2163
+ exportName = toBase64(nameIndex);
2164
+ }
2165
+ } while (RESERVED_NAMES.has(exportName) || exportsByName.has(exportName));
2166
+ }
2167
+ exportsByName.set(exportName, variable);
2168
+ exportNamesByVariable.set(variable, [exportName]);
2169
+ }
2170
+ }
2171
+ function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
2172
+ for (const variable of exports) {
2173
+ let nameIndex = 0;
2174
+ let exportName = variable.name;
2175
+ while (exportsByName.has(exportName)) {
2176
+ exportName = variable.name + '$' + ++nameIndex;
2177
+ }
2178
+ exportsByName.set(exportName, variable);
2179
+ exportNamesByVariable.set(variable, [exportName]);
2180
+ }
2181
+ }
2182
+ // Names starting with "*" are used internally, e.g. "*" for namespaces and "*"
2183
+ // followed by an id for namespaces reexported from external modules. To avoid
2184
+ // conflicts, actual export names starting with "*" get an additional "*", and
2185
+ // external ids starting with "*" or "\0" are prefixed with "\0".
2186
+ const escapeExportName = (name) => (name[0] === '*' ? `*${name}` : name);
2187
+ const unescapeExportName = (name) => name.startsWith('**') ? name.slice(1) : name;
2188
+ const isNamespaceExportName = (name) => name[0] === '*' && name[1] !== '*';
2189
+ const getExternalNamespaceExportName = (id) => id[0] === '*' || id[0] === '\0' ? `*\0${id}` : `*${id}`;
2190
+ const getExternalNamespaceId = (exportName) => exportName.slice(exportName[1] === '\0' ? 2 : 1);
2191
+
2089
2192
  function treeshakeNode(node, code, start, end) {
2090
2193
  code.remove(start, end);
2091
2194
  node.removeAnnotations(code);
@@ -2252,13 +2355,16 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
2252
2355
  if (exportedVariables.length === 1 &&
2253
2356
  exportNamesByVariable.get(exportedVariables[0]).length === 1) {
2254
2357
  const variable = exportedVariables[0];
2255
- return `exports(${JSON.stringify(exportNamesByVariable.get(variable)[0])},${_}${variable.getName(getPropertyAccess)}${modifier})`;
2358
+ return `exports(${JSON.stringify(unescapeExportName(exportNamesByVariable.get(variable)[0]))},${_}${variable.getName(getPropertyAccess)}${modifier})`;
2256
2359
  }
2257
2360
  else {
2258
2361
  const fields = [];
2259
2362
  for (const variable of exportedVariables) {
2260
2363
  for (const exportName of exportNamesByVariable.get(variable)) {
2261
- fields.push([exportName, variable.getName(getPropertyAccess) + modifier]);
2364
+ fields.push([
2365
+ unescapeExportName(exportName),
2366
+ variable.getName(getPropertyAccess) + modifier
2367
+ ]);
2262
2368
  }
2263
2369
  }
2264
2370
  return `exports(${getObject(fields, { lineBreakIndent: null })})`;
@@ -2266,7 +2372,7 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
2266
2372
  }
2267
2373
  // This is only invoked if there is exactly one export name
2268
2374
  function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
2269
- code.prependRight(expressionStart, `exports(${JSON.stringify(exportNamesByVariable.get(exportedVariable)[0])},${_}`);
2375
+ code.prependRight(expressionStart, `exports(${JSON.stringify(unescapeExportName(exportNamesByVariable.get(exportedVariable)[0]))},${_}`);
2270
2376
  code.appendLeft(expressionEnd, ')');
2271
2377
  }
2272
2378
  function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
@@ -2843,58 +2949,6 @@ function cacheObjectGetters(object, getterProperties) {
2843
2949
  }
2844
2950
  }
2845
2951
 
2846
- const RESERVED_NAMES = new Set([
2847
- 'await',
2848
- 'break',
2849
- 'case',
2850
- 'catch',
2851
- 'class',
2852
- 'const',
2853
- 'continue',
2854
- 'debugger',
2855
- 'default',
2856
- 'delete',
2857
- 'do',
2858
- 'else',
2859
- 'enum',
2860
- 'eval',
2861
- 'export',
2862
- 'extends',
2863
- 'false',
2864
- 'finally',
2865
- 'for',
2866
- 'function',
2867
- 'if',
2868
- 'implements',
2869
- 'import',
2870
- 'in',
2871
- 'instanceof',
2872
- 'interface',
2873
- 'let',
2874
- 'NaN',
2875
- 'new',
2876
- 'null',
2877
- 'package',
2878
- 'private',
2879
- 'protected',
2880
- 'public',
2881
- 'return',
2882
- 'static',
2883
- 'super',
2884
- 'switch',
2885
- 'this',
2886
- 'throw',
2887
- 'true',
2888
- 'try',
2889
- 'typeof',
2890
- 'undefined',
2891
- 'var',
2892
- 'void',
2893
- 'while',
2894
- 'with',
2895
- 'yield'
2896
- ]);
2897
-
2898
2952
  const illegalCharacters = /[^\w$]/g;
2899
2953
  const illegalCharacter = /[^\w$]/;
2900
2954
  const startsWithDigit = (value) => /\d/.test(value[0]);
@@ -3016,7 +3070,7 @@ class ExternalModule {
3016
3070
  }
3017
3071
  }
3018
3072
  const importersArray = [...importersSet];
3019
- this.options.onLog(LOGLEVEL_WARN, logUnusedExternalImports(this.id, unused, importersArray));
3073
+ this.options.onLog(LOGLEVEL_WARN, logUnusedExternalImports(this.id, unused.map(unescapeExportName), importersArray));
3020
3074
  }
3021
3075
  }
3022
3076
 
@@ -5952,6 +6006,15 @@ class Identifier extends IdentifierBase {
5952
6006
  markDeclarationReached() {
5953
6007
  this.variable.initReached = true;
5954
6008
  }
6009
+ isDeclarationInDestructuringPattern() {
6010
+ let parent = this.parent;
6011
+ while (parent.type === Property$1 ||
6012
+ parent.type === AssignmentPattern$1 ||
6013
+ parent.type === RestElement$1) {
6014
+ parent = parent.parent;
6015
+ }
6016
+ return parent.type === ObjectPattern$1 || parent.type === ArrayPattern$1;
6017
+ }
5955
6018
  render(code, { snippets: { getPropertyAccess }, useOriginalName }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
5956
6019
  if (this.variable) {
5957
6020
  const name = this.variable.getName(getPropertyAccess, useOriginalName);
@@ -5974,18 +6037,6 @@ class Identifier extends IdentifierBase {
5974
6037
  }
5975
6038
  }
5976
6039
 
5977
- const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
5978
- const base = 64;
5979
- function toBase64(value) {
5980
- let outString = '';
5981
- do {
5982
- const currentDigit = value % base;
5983
- value = (value / base) | 0;
5984
- outString = chars[currentDigit] + outString;
5985
- } while (value !== 0);
5986
- return outString;
5987
- }
5988
-
5989
6040
  function getSafeName(baseName, usedNames, forbiddenNames) {
5990
6041
  let safeName = baseName;
5991
6042
  let count = 1;
@@ -7633,7 +7684,7 @@ class ExportDefaultDeclaration extends NodeBase {
7633
7684
  const hasTrailingSemicolon = code.original.charCodeAt(this.end - 1) === 59; /*";"*/
7634
7685
  const systemExportNames = format === 'system' && exportNamesByVariable.get(this.variable);
7635
7686
  if (systemExportNames) {
7636
- code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(systemExportNames[0])}, `);
7687
+ code.overwrite(this.start, declarationStart, `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify(unescapeExportName(systemExportNames[0]))}, `);
7637
7688
  code.appendRight(hasTrailingSemicolon ? this.end - 1 : this.end, ')' + (hasTrailingSemicolon ? '' : ';'));
7638
7689
  return false;
7639
7690
  }
@@ -7868,6 +7919,111 @@ function getToStringTagValue(getObject) {
7868
7919
  });
7869
7920
  }
7870
7921
 
7922
+ class UndefinedVariable extends Variable {
7923
+ constructor() {
7924
+ super('undefined');
7925
+ }
7926
+ getLiteralValueAtPath() {
7927
+ return undefined;
7928
+ }
7929
+ }
7930
+
7931
+ class ExportDefaultVariable extends LocalVariable {
7932
+ constructor(exportDefaultDeclaration, context) {
7933
+ super('default', exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
7934
+ this.hasId = false;
7935
+ this.originalId = null;
7936
+ this.originalVariable = null;
7937
+ const declaration = exportDefaultDeclaration.declaration;
7938
+ if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
7939
+ declaration.id) {
7940
+ this.hasId = true;
7941
+ this.originalId = declaration.id;
7942
+ }
7943
+ else if (declaration instanceof Identifier) {
7944
+ this.originalId = declaration;
7945
+ }
7946
+ }
7947
+ addReference(identifier) {
7948
+ if (!this.hasId) {
7949
+ this.name = identifier.name;
7950
+ }
7951
+ }
7952
+ addUsedPlace(usedPlace) {
7953
+ const original = this.getOriginalVariable();
7954
+ if (original === this) {
7955
+ super.addUsedPlace(usedPlace);
7956
+ }
7957
+ else {
7958
+ original.addUsedPlace(usedPlace);
7959
+ }
7960
+ }
7961
+ forbidName(name) {
7962
+ const original = this.getOriginalVariable();
7963
+ if (original === this) {
7964
+ super.forbidName(name);
7965
+ }
7966
+ else {
7967
+ original.forbidName(name);
7968
+ }
7969
+ }
7970
+ getAssignedVariableName() {
7971
+ return (this.originalId && this.originalId.name) || null;
7972
+ }
7973
+ getBaseVariableName() {
7974
+ const original = this.getOriginalVariable();
7975
+ return original === this ? super.getBaseVariableName() : original.getBaseVariableName();
7976
+ }
7977
+ getDirectOriginalVariable() {
7978
+ return this.originalId &&
7979
+ (this.hasId ||
7980
+ !(this.originalId.isPossibleTDZ() ||
7981
+ this.originalId.variable.isReassigned ||
7982
+ this.originalId.variable instanceof UndefinedVariable ||
7983
+ // this avoids a circular dependency
7984
+ 'syntheticNamespace' in this.originalId.variable))
7985
+ ? this.originalId.variable
7986
+ : null;
7987
+ }
7988
+ /**
7989
+ * Returns the namespace if this default export is just a re-export of a
7990
+ * namespace import. Namespace variables can neither be reassigned nor be
7991
+ * accessed in their TDZ, so this is safe to call while binding.
7992
+ */
7993
+ getOriginalNamespaceVariable() {
7994
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
7995
+ let current = this;
7996
+ const checkedVariables = new Set();
7997
+ while (current instanceof ExportDefaultVariable && !checkedVariables.has(current)) {
7998
+ checkedVariables.add(current);
7999
+ if (current.hasId || !current.originalId)
8000
+ return null;
8001
+ current = current.originalId.variable;
8002
+ }
8003
+ return current?.isNamespace ? current : null;
8004
+ }
8005
+ getName(getPropertyAccess) {
8006
+ const original = this.getOriginalVariable();
8007
+ return original === this
8008
+ ? super.getName(getPropertyAccess)
8009
+ : original.getName(getPropertyAccess);
8010
+ }
8011
+ getOriginalVariable() {
8012
+ if (this.originalVariable)
8013
+ return this.originalVariable;
8014
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
8015
+ let original = this;
8016
+ let currentVariable;
8017
+ const checkedVariables = new Set();
8018
+ do {
8019
+ checkedVariables.add(original);
8020
+ currentVariable = original;
8021
+ original = currentVariable.getDirectOriginalVariable();
8022
+ } while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
8023
+ return (this.originalVariable = original || currentVariable);
8024
+ }
8025
+ }
8026
+
7871
8027
  class Literal extends NodeBase {
7872
8028
  deoptimizeArgumentsOnInteractionAtPath() { }
7873
8029
  getLiteralValueAtPath(path) {
@@ -8002,6 +8158,12 @@ class MemberExpression extends NodeBase {
8002
8158
  set bound(value) {
8003
8159
  this.flags = setFlag(this.flags, 32 /* Flag.bound */, value);
8004
8160
  }
8161
+ get deleteOfMissingNamespaceMember() {
8162
+ return isFlagSet(this.flags, 536870912 /* Flag.deleteOfMissingNamespaceMember */);
8163
+ }
8164
+ set deleteOfMissingNamespaceMember(value) {
8165
+ this.flags = setFlag(this.flags, 536870912 /* Flag.deleteOfMissingNamespaceMember */, value);
8166
+ }
8005
8167
  get isUndefined() {
8006
8168
  return isFlagSet(this.flags, 64 /* Flag.isUndefined */);
8007
8169
  }
@@ -8011,10 +8173,15 @@ class MemberExpression extends NodeBase {
8011
8173
  bind() {
8012
8174
  this.bound = true;
8013
8175
  const path = getPathIfNotComputed(this);
8014
- const baseVariable = path && this.scope.findVariable(path[0].key);
8176
+ let baseVariable = path && this.scope.findVariable(path[0].key);
8177
+ if (baseVariable instanceof ExportDefaultVariable) {
8178
+ baseVariable = baseVariable.getOriginalNamespaceVariable() || baseVariable;
8179
+ }
8015
8180
  if (baseVariable?.isNamespace) {
8016
8181
  const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.scope.context);
8017
- if (!resolvedVariable) {
8182
+ const isDelete = this.isDeleteTarget();
8183
+ if (!resolvedVariable || this.assignmentInteraction || isDelete) {
8184
+ this.deleteOfMissingNamespaceMember = isDelete && resolvedVariable === 'undefined';
8018
8185
  super.bind();
8019
8186
  }
8020
8187
  else if (resolvedVariable === 'undefined') {
@@ -8323,15 +8490,9 @@ class MemberExpression extends NodeBase {
8323
8490
  }
8324
8491
  }
8325
8492
  disallowNamespaceReassignment() {
8326
- if (this.object instanceof Identifier) {
8327
- const variable = this.scope.findVariable(this.object.name);
8328
- if (variable.isNamespace) {
8329
- if (this.variable) {
8330
- this.scope.context.includeVariableInModule(this.variable, UNKNOWN_PATH, createInclusionContext());
8331
- }
8332
- this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
8333
- }
8334
- }
8493
+ if (!this.getNamespaceVariableOfObject() || this.deleteOfMissingNamespaceMember)
8494
+ return;
8495
+ this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.getNamespaceName(), this.scope.context.module.id), this.start);
8335
8496
  }
8336
8497
  getDynamicPropertyKey() {
8337
8498
  if (this.dynamicPropertyKey === null) {
@@ -8346,6 +8507,27 @@ class MemberExpression extends NodeBase {
8346
8507
  }
8347
8508
  return this.dynamicPropertyKey;
8348
8509
  }
8510
+ getNamespaceName() {
8511
+ return this.object instanceof Identifier
8512
+ ? this.object.name
8513
+ : getStringFromPath(getPathIfNotComputed(this.object));
8514
+ }
8515
+ getNamespaceVariableOfObject() {
8516
+ let variable;
8517
+ if (this.object instanceof Identifier) {
8518
+ variable = this.scope.findVariable(this.object.name);
8519
+ }
8520
+ else if (this.object instanceof MemberExpression) {
8521
+ variable = this.object.variable;
8522
+ }
8523
+ else {
8524
+ return null;
8525
+ }
8526
+ if (variable instanceof ExportDefaultVariable) {
8527
+ variable = variable.getOriginalNamespaceVariable() || variable;
8528
+ }
8529
+ return variable?.isNamespace ? variable : null;
8530
+ }
8349
8531
  hasAccessEffect(context) {
8350
8532
  const { propertyReadSideEffects } = this.scope.context.options
8351
8533
  .treeshake;
@@ -8354,6 +8536,10 @@ class MemberExpression extends NodeBase {
8354
8536
  (propertyReadSideEffects === 'always' ||
8355
8537
  this.object.hasEffectsOnInteractionAtPath([this.getDynamicPropertyKey()], this.accessInteraction, context)));
8356
8538
  }
8539
+ isDeleteTarget() {
8540
+ const parent = this.parent.type === ChainExpression$1 ? this.parent.parent : this.parent;
8541
+ return (parent.type === UnaryExpression$1 && parent.operator === 'delete');
8542
+ }
8357
8543
  }
8358
8544
  function resolveNamespaceVariables(baseVariable, path, astContext) {
8359
8545
  if (path.length === 0)
@@ -8517,94 +8703,6 @@ const importMetaMechanisms = {
8517
8703
  umd: getGenericImportMetaMechanism(chunkId => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename', false)} : ${getUrlFromDocument(chunkId, true)})`)
8518
8704
  };
8519
8705
 
8520
- class UndefinedVariable extends Variable {
8521
- constructor() {
8522
- super('undefined');
8523
- }
8524
- getLiteralValueAtPath() {
8525
- return undefined;
8526
- }
8527
- }
8528
-
8529
- class ExportDefaultVariable extends LocalVariable {
8530
- constructor(exportDefaultDeclaration, context) {
8531
- super('default', exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
8532
- this.hasId = false;
8533
- this.originalId = null;
8534
- this.originalVariable = null;
8535
- const declaration = exportDefaultDeclaration.declaration;
8536
- if ((declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) &&
8537
- declaration.id) {
8538
- this.hasId = true;
8539
- this.originalId = declaration.id;
8540
- }
8541
- else if (declaration instanceof Identifier) {
8542
- this.originalId = declaration;
8543
- }
8544
- }
8545
- addReference(identifier) {
8546
- if (!this.hasId) {
8547
- this.name = identifier.name;
8548
- }
8549
- }
8550
- addUsedPlace(usedPlace) {
8551
- const original = this.getOriginalVariable();
8552
- if (original === this) {
8553
- super.addUsedPlace(usedPlace);
8554
- }
8555
- else {
8556
- original.addUsedPlace(usedPlace);
8557
- }
8558
- }
8559
- forbidName(name) {
8560
- const original = this.getOriginalVariable();
8561
- if (original === this) {
8562
- super.forbidName(name);
8563
- }
8564
- else {
8565
- original.forbidName(name);
8566
- }
8567
- }
8568
- getAssignedVariableName() {
8569
- return (this.originalId && this.originalId.name) || null;
8570
- }
8571
- getBaseVariableName() {
8572
- const original = this.getOriginalVariable();
8573
- return original === this ? super.getBaseVariableName() : original.getBaseVariableName();
8574
- }
8575
- getDirectOriginalVariable() {
8576
- return this.originalId &&
8577
- (this.hasId ||
8578
- !(this.originalId.isPossibleTDZ() ||
8579
- this.originalId.variable.isReassigned ||
8580
- this.originalId.variable instanceof UndefinedVariable ||
8581
- // this avoids a circular dependency
8582
- 'syntheticNamespace' in this.originalId.variable))
8583
- ? this.originalId.variable
8584
- : null;
8585
- }
8586
- getName(getPropertyAccess) {
8587
- const original = this.getOriginalVariable();
8588
- return original === this
8589
- ? super.getName(getPropertyAccess)
8590
- : original.getName(getPropertyAccess);
8591
- }
8592
- getOriginalVariable() {
8593
- if (this.originalVariable)
8594
- return this.originalVariable;
8595
- // eslint-disable-next-line @typescript-eslint/no-this-alias
8596
- let original = this;
8597
- let currentVariable;
8598
- const checkedVariables = new Set();
8599
- do {
8600
- checkedVariables.add(original);
8601
- currentVariable = original;
8602
- original = currentVariable.getDirectOriginalVariable();
8603
- } while (original instanceof ExportDefaultVariable && !checkedVariables.has(original));
8604
- return (this.originalVariable = original || currentVariable);
8605
- }
8606
- }
8607
-
8608
8706
  class NamespaceVariable extends Variable {
8609
8707
  constructor(context) {
8610
8708
  super(context.getModuleName());
@@ -8624,10 +8722,7 @@ class NamespaceVariable extends Variable {
8624
8722
  if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) {
8625
8723
  const key = path[0];
8626
8724
  if (typeof key === 'string') {
8627
- this.module
8628
- .getExportedVariablesByName()
8629
- .get(key)
8630
- ?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
8725
+ this.getMemberVariable(key)?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker);
8631
8726
  }
8632
8727
  else {
8633
8728
  deoptimizeInteraction(interaction);
@@ -8638,7 +8733,7 @@ class NamespaceVariable extends Variable {
8638
8733
  if (path.length > 1) {
8639
8734
  const key = path[0];
8640
8735
  if (typeof key === 'string') {
8641
- this.module.getExportedVariablesByName().get(key)?.deoptimizePath(path.slice(1));
8736
+ this.getMemberVariable(key)?.deoptimizePath(path.slice(1));
8642
8737
  }
8643
8738
  else if (!this.areAllMembersDeoptimized) {
8644
8739
  this.areAllMembersDeoptimized = true;
@@ -8667,7 +8762,7 @@ class NamespaceVariable extends Variable {
8667
8762
  if (typeof key !== 'string') {
8668
8763
  return true;
8669
8764
  }
8670
- const memberVariable = this.module.getExportedVariablesByName().get(key);
8765
+ const memberVariable = this.getMemberVariable(key);
8671
8766
  return (!memberVariable ||
8672
8767
  memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
8673
8768
  }
@@ -8679,7 +8774,7 @@ class NamespaceVariable extends Variable {
8679
8774
  if (path.length > 0) {
8680
8775
  const [name, ...remainingPath] = path;
8681
8776
  if (typeof name === 'string') {
8682
- const variable = this.module.getExportedVariablesByName().get(name);
8777
+ const variable = this.getMemberVariable(name);
8683
8778
  if (variable) {
8684
8779
  this.context.includeVariableInModule(variable, remainingPath, context);
8685
8780
  }
@@ -8702,15 +8797,21 @@ class NamespaceVariable extends Variable {
8702
8797
  const { exportNamesByVariable, format, freeze, indent: t, symbols, snippets: { _, cnst, getObject, getPropertyAccess, n, s } } = options;
8703
8798
  const memberVariables = this.module.getExportedVariablesByName();
8704
8799
  const members = [...memberVariables.entries()]
8705
- .filter(([name, variable]) => !name.startsWith('*') && variable.included)
8800
+ .filter(([name, variable]) => !isNamespaceExportName(name) && variable.included)
8706
8801
  .map(([name, variable]) => {
8707
- if (this.referencedEarly || variable.isReassigned || variable === this) {
8802
+ const key = unescapeExportName(name);
8803
+ if (this.referencedEarly ||
8804
+ variable.isReassigned ||
8805
+ variable === this ||
8806
+ (variable.module &&
8807
+ !variable.module.info.isExternal &&
8808
+ variable.module.execIndex > this.module.execIndex)) {
8708
8809
  return [
8709
8810
  null,
8710
- `get ${stringifyObjectKeyIfNeeded(name)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
8811
+ `get ${stringifyObjectKeyIfNeeded(key)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
8711
8812
  ];
8712
8813
  }
8713
- return [name, variable.getName(getPropertyAccess)];
8814
+ return [key, variable.getName(getPropertyAccess)];
8714
8815
  });
8715
8816
  members.unshift([null, `__proto__:${_}null`]);
8716
8817
  let output = getObject(members, { lineBreakIndent: { base: '', t } });
@@ -8748,6 +8849,9 @@ class NamespaceVariable extends Variable {
8748
8849
  }
8749
8850
  }
8750
8851
  }
8852
+ getMemberVariable(name) {
8853
+ return this.module.getExportedVariablesByName().get(escapeExportName(name));
8854
+ }
8751
8855
  includeNonExplicitNamespaces() {
8752
8856
  if (!this.nonExplicitNamespacesIncluded) {
8753
8857
  this.nonExplicitNamespacesIncluded = true;
@@ -8882,7 +8986,7 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
8882
8986
  if (exportBlock)
8883
8987
  exportBlock += n;
8884
8988
  if (specifier.imported !== '*' && specifier.needsLiveBinding) {
8885
- exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(specifier.reexported)},${_}${getGetter(importName, false, t, snippets)});`;
8989
+ exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(specifier.reexported))},${_}${getGetter(importName, false, t, snippets)});`;
8886
8990
  }
8887
8991
  else if (specifier.reexported === '__proto__') {
8888
8992
  exportBlock +=
@@ -8891,20 +8995,20 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
8891
8995
  `${t}value:${_}${importName}${n}});`;
8892
8996
  }
8893
8997
  else {
8894
- exportBlock += `exports${getPropertyAccess(specifier.reexported)}${_}=${_}${importName};`;
8998
+ exportBlock += `exports${getPropertyAccess(unescapeExportName(specifier.reexported))}${_}=${_}${importName};`;
8895
8999
  }
8896
9000
  }
8897
9001
  }
8898
9002
  }
8899
9003
  }
8900
9004
  for (const { exported, local, needsLiveBinding } of exports) {
8901
- const lhs = `exports${getPropertyAccess(exported)}`;
9005
+ const lhs = `exports${getPropertyAccess(unescapeExportName(exported))}`;
8902
9006
  const rhs = local;
8903
9007
  if (lhs !== rhs) {
8904
9008
  if (exportBlock)
8905
9009
  exportBlock += n;
8906
9010
  if (needsLiveBinding) {
8907
- exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(exported)},${_}${getGetter(rhs, true, t, snippets)});`;
9011
+ exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(unescapeExportName(exported))},${_}${getGetter(rhs, true, t, snippets)});`;
8908
9012
  continue;
8909
9013
  }
8910
9014
  exportBlock +=
@@ -8982,7 +9086,7 @@ function getReexportedImportName(moduleVariableName, imported, dependencyNamedEx
8982
9086
  ? namespaceVariableName
8983
9087
  : moduleVariableName;
8984
9088
  }
8985
- return `${moduleVariableName}${getPropertyAccess(imported)}`;
9089
+ return `${moduleVariableName}${getPropertyAccess(unescapeExportName(imported))}`;
8986
9090
  }
8987
9091
  function getEsModuleValue(getObject) {
8988
9092
  return getObject([['value', 'true']], {
@@ -9158,6 +9262,8 @@ const builtinModules = [
9158
9262
  "module",
9159
9263
  "node:net",
9160
9264
  "net",
9265
+ "node:net/promises",
9266
+ "net/promises",
9161
9267
  "node:os",
9162
9268
  "os",
9163
9269
  "node:path",
@@ -9367,7 +9473,7 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
9367
9473
  importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
9368
9474
  .map(specifier => specifier.imported === specifier.local
9369
9475
  ? specifier.imported
9370
- : `${stringifyIdentifierIfNeeded(specifier.imported)} as ${specifier.local}`)
9476
+ : `${stringifyExportName(specifier.imported)} as ${specifier.local}`)
9371
9477
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
9372
9478
  }
9373
9479
  }
@@ -9397,14 +9503,14 @@ function getImportBlock(dependencies, importAttributesKey, { _ }) {
9397
9503
  for (const specifier of namespaceReexports) {
9398
9504
  importBlock.push(`export${_}{${_}${name === specifier.reexported
9399
9505
  ? name
9400
- : `${name} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`} };`);
9506
+ : `${name} as ${stringifyExportName(specifier.reexported)}`} };`);
9401
9507
  }
9402
9508
  }
9403
9509
  if (namedReexports.length > 0) {
9404
9510
  importBlock.push(`export${_}{${_}${namedReexports
9405
9511
  .map(specifier => specifier.imported === specifier.reexported
9406
- ? stringifyIdentifierIfNeeded(specifier.imported)
9407
- : `${stringifyIdentifierIfNeeded(specifier.imported)} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`)
9512
+ ? stringifyExportName(specifier.imported)
9513
+ : `${stringifyExportName(specifier.imported)} as ${stringifyExportName(specifier.reexported)}`)
9408
9514
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
9409
9515
  }
9410
9516
  }
@@ -9422,13 +9528,14 @@ function getExportBlock(exports, { _, cnst }) {
9422
9528
  exportDeclaration[index++] =
9423
9529
  specifier.exported === specifier.local
9424
9530
  ? specifier.local
9425
- : `${specifier.local} as ${stringifyIdentifierIfNeeded(specifier.exported)}`;
9531
+ : `${specifier.local} as ${stringifyExportName(specifier.exported)}`;
9426
9532
  }
9427
9533
  if (exportDeclaration.length > 0) {
9428
9534
  exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
9429
9535
  }
9430
9536
  return exportBlock;
9431
9537
  }
9538
+ const stringifyExportName = (name) => stringifyIdentifierIfNeeded(unescapeExportName(name));
9432
9539
 
9433
9540
  const keypath = (keypath, getPropertyAccess) => keypath.split('.').map(getPropertyAccess).join('');
9434
9541
 
@@ -9614,7 +9721,7 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
9614
9721
  setter.push(`${specifier.local}${_}=${_}module;`);
9615
9722
  }
9616
9723
  else {
9617
- setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(specifier.imported)};`);
9724
+ setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(unescapeExportName(specifier.imported))};`);
9618
9725
  }
9619
9726
  }
9620
9727
  }
@@ -9627,8 +9734,8 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
9627
9734
  }
9628
9735
  else {
9629
9736
  reexportedNames.push([
9630
- reexported,
9631
- imported === '*' ? 'module' : `module${getPropertyAccess(imported)}`
9737
+ unescapeExportName(reexported),
9738
+ imported === '*' ? 'module' : `module${getPropertyAccess(unescapeExportName(imported))}`
9632
9739
  ]);
9633
9740
  }
9634
9741
  }
@@ -9656,13 +9763,13 @@ function analyzeDependencies(dependencies, exports, t, { _, cnst, getObject, get
9656
9763
  return { importBindings, setters, starExcludes };
9657
9764
  }
9658
9765
  const getStarExcludes = ({ dependencies, exports }) => {
9659
- const starExcludes = new Set(exports.map(expt => expt.exported));
9766
+ const starExcludes = new Set(exports.map(expt => unescapeExportName(expt.exported)));
9660
9767
  starExcludes.add('default');
9661
9768
  for (const { reexports } of dependencies) {
9662
9769
  if (reexports) {
9663
9770
  for (const reexport of reexports) {
9664
9771
  if (reexport.reexported !== '*')
9665
- starExcludes.add(reexport.reexported);
9772
+ starExcludes.add(unescapeExportName(reexport.reexported));
9666
9773
  }
9667
9774
  }
9668
9775
  }
@@ -9688,11 +9795,11 @@ function getExportsBlock(exports, t, { _, n }) {
9688
9795
  return '';
9689
9796
  }
9690
9797
  if (exports.length === 1) {
9691
- return `exports(${JSON.stringify(exports[0].name)},${_}${exports[0].value});${n}${n}`;
9798
+ return `exports(${JSON.stringify(unescapeExportName(exports[0].name))},${_}${exports[0].value});${n}${n}`;
9692
9799
  }
9693
9800
  return (`exports({${n}` +
9694
9801
  exports
9695
- .map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(name)}:${_}${value}`)
9802
+ .map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(unescapeExportName(name))}:${_}${value}`)
9696
9803
  .join(`,${n}`) +
9697
9804
  `${n}});${n}${n}`);
9698
9805
  }
@@ -13409,6 +13516,9 @@ CatchClause.prototype.includeNode = onlyIncludeSelf;
13409
13516
  class ChainExpression extends NodeBase {
13410
13517
  // deoptimizations are not relevant as we are not caching values
13411
13518
  deoptimizeCache() { }
13519
+ deoptimizePath(path) {
13520
+ this.expression.deoptimizePath(path);
13521
+ }
13412
13522
  getLiteralValueAtPath(path, recursionTracker, origin) {
13413
13523
  const literalValue = this.expression.getLiteralValueAtPathAsChainElement(path, recursionTracker, origin);
13414
13524
  return literalValue === IS_SKIPPED_CHAIN ? undefined : literalValue;
@@ -17724,6 +17834,11 @@ function decodedSourcemap(map) {
17724
17834
  if (typeof map === 'string') {
17725
17835
  map = JSON.parse(map);
17726
17836
  }
17837
+ // A map this function already returned, e.g. one restored from the cache of a previous build, is
17838
+ // lazy. Reading its mappings below would decode it.
17839
+ if (sourceMapCache.has(map)) {
17840
+ return map;
17841
+ }
17727
17842
  if ('sections' in map) {
17728
17843
  map = flattenIndexSourceMap(map);
17729
17844
  }
@@ -18302,7 +18417,7 @@ class Module {
18302
18417
  exportedVariablesByName.set(name, exportedVariable);
18303
18418
  }
18304
18419
  else {
18305
- return error(logMissingEntryExport(name, this.id));
18420
+ return error(logMissingEntryExport(unescapeExportName(name), this.id));
18306
18421
  }
18307
18422
  }
18308
18423
  }
@@ -18314,7 +18429,7 @@ class Module {
18314
18429
  }
18315
18430
  for (const module of this.exportAllModules) {
18316
18431
  if (module instanceof ExternalModule) {
18317
- exportedVariablesByName.set(`*${module.id}`, module.getVariableForExportName('*', {
18432
+ exportedVariablesByName.set(getExternalNamespaceExportName(module.id), module.getVariableForExportName('*', {
18318
18433
  importChain: [this.id]
18319
18434
  })[0]);
18320
18435
  continue;
@@ -18374,13 +18489,13 @@ class Module {
18374
18489
  return this.syntheticNamespace;
18375
18490
  }
18376
18491
  getVariableForExportName(name, { importerForSideEffects, importChain = [], isExportAllSearch, onlyExplicit, searchedNamesAndModules, sideEffectModules, exportOrReexportModules } = EMPTY_OBJECT) {
18377
- if (name[0] === '*') {
18492
+ if (isNamespaceExportName(name)) {
18378
18493
  if (name.length === 1) {
18379
18494
  // export * from './other'
18380
18495
  return [this.namespace];
18381
18496
  }
18382
18497
  // export * from 'external'
18383
- const module = this.graph.modulesById.get(name.slice(1));
18498
+ const module = this.graph.modulesById.get(getExternalNamespaceId(name));
18384
18499
  return module.getVariableForExportName('*', {
18385
18500
  importChain: [...importChain, this.id]
18386
18501
  });
@@ -18390,7 +18505,7 @@ class Module {
18390
18505
  if (reexportDeclaration) {
18391
18506
  const [variable, options] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules, [...importChain, this.id], sideEffectModules, exportOrReexportModules);
18392
18507
  if (!variable) {
18393
- return this.error(logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
18508
+ return this.error(logMissingExport(unescapeExportName(reexportDeclaration.localName), this.id, reexportDeclaration.module.id, !!options?.missingButExportExists), reexportDeclaration.start);
18394
18509
  }
18395
18510
  if (importerForSideEffects) {
18396
18511
  setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
@@ -18453,7 +18568,7 @@ class Module {
18453
18568
  }
18454
18569
  if (this.info.syntheticNamedExports) {
18455
18570
  return [
18456
- getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, name, this.getSyntheticNamespace()))
18571
+ getOrCreate(this.syntheticExports, name, () => new SyntheticNamedExportVariable(this.astContext, unescapeExportName(name), this.getSyntheticNamespace()))
18457
18572
  ];
18458
18573
  }
18459
18574
  // we don't want to create shims when we are just
@@ -18592,7 +18707,7 @@ class Module {
18592
18707
  newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
18593
18708
  options: this.options,
18594
18709
  requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
18595
- traceExport: (name) => this.getVariableForExportName(name),
18710
+ traceExport: (name) => this.getVariableForExportName(escapeExportName(name)),
18596
18711
  traceVariable: this.traceVariable.bind(this),
18597
18712
  usesTopLevelAwait: false
18598
18713
  };
@@ -18668,7 +18783,7 @@ class Module {
18668
18783
  }
18669
18784
  const [declaration, options] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules, [this.id], sideEffectModules, exportOrReexportModules);
18670
18785
  if (!declaration) {
18671
- return this.error(logMissingExport(importDescription.name, this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
18786
+ return this.error(logMissingExport(unescapeExportName(importDescription.name), this.id, otherModule.id, !!options?.missingButExportExists), importDescription.start);
18672
18787
  }
18673
18788
  return declaration;
18674
18789
  }
@@ -18706,7 +18821,7 @@ class Module {
18706
18821
  }
18707
18822
  assertUniqueExportName(name, nodeStart) {
18708
18823
  if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) {
18709
- this.error(logDuplicateExportError(name), nodeStart);
18824
+ this.error(logDuplicateExportError(unescapeExportName(name)), nodeStart);
18710
18825
  }
18711
18826
  }
18712
18827
  addExport(node) {
@@ -18723,7 +18838,7 @@ class Module {
18723
18838
  this.addSource(source, node);
18724
18839
  if (node.exported) {
18725
18840
  // export * as name from './other'
18726
- const name = node.exported instanceof Literal ? node.exported.value : node.exported.name;
18841
+ const name = escapeExportName(node.exported instanceof Literal ? node.exported.value : node.exported.name);
18727
18842
  this.assertUniqueExportName(name, node.exported.start);
18728
18843
  this.reexportDescriptions.set(name, {
18729
18844
  localName: '*',
@@ -18742,10 +18857,10 @@ class Module {
18742
18857
  const source = node.source.value;
18743
18858
  this.addSource(source, node);
18744
18859
  for (const { exported, local, start } of node.specifiers) {
18745
- const name = exported instanceof Literal ? exported.value : exported.name;
18860
+ const name = escapeExportName(exported instanceof Literal ? exported.value : exported.name);
18746
18861
  this.assertUniqueExportName(name, start);
18747
18862
  this.reexportDescriptions.set(name, {
18748
- localName: local instanceof Literal ? local.value : local.name,
18863
+ localName: escapeExportName(local instanceof Literal ? local.value : local.name),
18749
18864
  module: null, // filled in later,
18750
18865
  source,
18751
18866
  start
@@ -18776,7 +18891,7 @@ class Module {
18776
18891
  for (const { local, exported } of node.specifiers) {
18777
18892
  // except for reexports, local must be an Identifier
18778
18893
  const localName = local.name;
18779
- const exportedName = exported instanceof Identifier ? exported.name : exported.value;
18894
+ const exportedName = escapeExportName(exported instanceof Identifier ? exported.name : exported.value);
18780
18895
  this.assertUniqueExportName(exportedName, exported.start);
18781
18896
  this.exportDescriptions.set(exportedName, { identifier: null, localName });
18782
18897
  }
@@ -18798,7 +18913,7 @@ class Module {
18798
18913
  ? '*'
18799
18914
  : specifier.imported instanceof Identifier
18800
18915
  ? specifier.imported.name
18801
- : specifier.imported.value;
18916
+ : escapeExportName(specifier.imported.value);
18802
18917
  this.importDescriptions.set(localName, {
18803
18918
  module: null, // filled in later
18804
18919
  name,
@@ -19150,8 +19265,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
19150
19265
  : chunk.variableName);
19151
19266
  }
19152
19267
  else {
19153
- // if the second parameter is `null`, it uses its "name" for the property name
19154
- variable.setRenderNames(chunk.variableName, null);
19268
+ variable.setRenderNames(chunk.variableName, unescapeExportName(name));
19155
19269
  }
19156
19270
  }
19157
19271
  else {
@@ -19163,7 +19277,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
19163
19277
  variable.setRenderNames(null, chunk.variableName);
19164
19278
  }
19165
19279
  else {
19166
- variable.setRenderNames(chunk.variableName, chunk.getVariableExportName(variable));
19280
+ variable.setRenderNames(chunk.variableName, unescapeExportName(chunk.getVariableExportName(variable)));
19167
19281
  }
19168
19282
  }
19169
19283
  }
@@ -19195,36 +19309,6 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
19195
19309
  }
19196
19310
  }
19197
19311
 
19198
- function assignExportsToMangledNames(exports, exportsByName, exportNamesByVariable) {
19199
- let nameIndex = 0;
19200
- for (const variable of exports) {
19201
- let [exportName] = variable.name;
19202
- if (exportsByName.has(exportName)) {
19203
- do {
19204
- exportName = toBase64(++nameIndex);
19205
- // skip past leading number identifiers
19206
- if (exportName.charCodeAt(0) === 49 /* '1' */) {
19207
- nameIndex += 9 * 64 ** (exportName.length - 1);
19208
- exportName = toBase64(nameIndex);
19209
- }
19210
- } while (RESERVED_NAMES.has(exportName) || exportsByName.has(exportName));
19211
- }
19212
- exportsByName.set(exportName, variable);
19213
- exportNamesByVariable.set(variable, [exportName]);
19214
- }
19215
- }
19216
- function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
19217
- for (const variable of exports) {
19218
- let nameIndex = 0;
19219
- let exportName = variable.name;
19220
- while (exportsByName.has(exportName)) {
19221
- exportName = variable.name + '$' + ++nameIndex;
19222
- }
19223
- exportsByName.set(exportName, variable);
19224
- exportNamesByVariable.set(variable, [exportName]);
19225
- }
19226
- }
19227
-
19228
19312
  function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, log) {
19229
19313
  const exportKeys = chunk.getExportNames();
19230
19314
  if (exportMode === 'default') {
@@ -19700,7 +19784,8 @@ class Chunk {
19700
19784
  this.facadeModule = module;
19701
19785
  this.facadeChunkByModule.set(module, this);
19702
19786
  this.strictFacade = true;
19703
- this.dynamicName = getChunkNameFromModule(module);
19787
+ this.dynamicName =
19788
+ getPredefinedChunkNameFromModule(module) ?? getDynamicAliasName(module.id);
19704
19789
  }
19705
19790
  else if (this.facadeModule === module &&
19706
19791
  !this.strictFacade &&
@@ -20015,7 +20100,7 @@ class Chunk {
20015
20100
  getChunkExportDeclarations(format) {
20016
20101
  const exports = [];
20017
20102
  for (const exportName of this.getExportNames()) {
20018
- if (exportName[0] === '*')
20103
+ if (isNamespaceExportName(exportName))
20019
20104
  continue;
20020
20105
  const variable = this.exportsByName.get(exportName);
20021
20106
  if (!(variable instanceof SyntheticNamedExportVariable)) {
@@ -20063,7 +20148,10 @@ class Chunk {
20063
20148
  expression,
20064
20149
  hoisted,
20065
20150
  local,
20066
- needsLiveBinding: variable.isReassigned && this.exportNamesByVariable.get(variable).length > 1
20151
+ needsLiveBinding: (variable.isReassigned && this.exportNamesByVariable.get(variable).length > 1) ||
20152
+ // Pattern bindings are plain locals; a trailing assignment
20153
+ // would lose later reassignments.
20154
+ (variable.isTargetOfAssignment && isDeclaredInDestructuringPattern(variable))
20067
20155
  });
20068
20156
  }
20069
20157
  return exports;
@@ -20087,7 +20175,7 @@ class Chunk {
20087
20175
  else if (variable.isNamespace &&
20088
20176
  namespaceInteropHelpersByInteropType[interop(module.id)] &&
20089
20177
  (this.imports.has(variable) ||
20090
- !this.exportNamesByVariable.get(variable)?.every(name => name[0] === '*'))) {
20178
+ !this.exportNamesByVariable.get(variable)?.every(isNamespaceExportName))) {
20091
20179
  // We only need to deconflict it if the namespace is actually
20092
20180
  // created as a variable, i.e. because it is used internally or
20093
20181
  // because it is reexported as an object
@@ -20272,8 +20360,8 @@ class Chunk {
20272
20360
  let dependency;
20273
20361
  let imported;
20274
20362
  let needsLiveBinding;
20275
- if (exportName[0] === '*') {
20276
- const id = exportName.slice(1);
20363
+ if (isNamespaceExportName(exportName)) {
20364
+ const id = getExternalNamespaceId(exportName);
20277
20365
  if (interop(id) === 'defaultOnly') {
20278
20366
  this.inputOptions.onLog(LOGLEVEL_WARN, logUnexpectedNamespaceReexport(id));
20279
20367
  }
@@ -20504,8 +20592,9 @@ class Chunk {
20504
20592
  if (format !== 'es' &&
20505
20593
  format !== 'system' &&
20506
20594
  exportVariable.isReassigned &&
20507
- !exportVariable.isId) {
20508
- exportVariable.setRenderNames('exports', exportName);
20595
+ !exportVariable.isId &&
20596
+ !isDeclaredInDestructuringPattern(exportVariable)) {
20597
+ exportVariable.setRenderNames('exports', unescapeExportName(exportName));
20509
20598
  }
20510
20599
  else if (exportVariable instanceof SyntheticNamedExportVariable) {
20511
20600
  syntheticExports.add(exportVariable);
@@ -20590,6 +20679,10 @@ class Chunk {
20590
20679
  function getChunkNameFromModule(module) {
20591
20680
  return getPredefinedChunkNameFromModule(module) ?? getAliasName(module.id);
20592
20681
  }
20682
+ function isDeclaredInDestructuringPattern(variable) {
20683
+ return (variable instanceof LocalVariable &&
20684
+ variable.declarations.some(declaration => declaration instanceof Identifier && declaration.isDeclarationInDestructuringPattern()));
20685
+ }
20593
20686
  function getPredefinedChunkNameFromModule(module) {
20594
20687
  return (module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? module.chunkNames[0]?.name);
20595
20688
  }
@@ -20833,16 +20926,19 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
20833
20926
  staticDependencies.add(dependency);
20834
20927
  }
20835
20928
  }
20836
- for (const { node: { resolution } } of module.dynamicImports) {
20929
+ for (const { node } of module.dynamicImports) {
20930
+ const { resolution } = node;
20837
20931
  if (resolution instanceof Module &&
20838
20932
  resolution.includedDynamicImporters.length > 0 &&
20839
20933
  (dynamicEntryModules.has(resolution) || !allEntriesSet.has(resolution))) {
20840
20934
  dynamicEntriesForCurrentEntry.add(resolution);
20935
+ if (node.included) {
20936
+ dynamicImportsForCurrentEntry.add(resolution);
20937
+ }
20841
20938
  if (!allEntriesSet.has(resolution)) {
20842
20939
  dynamicEntryModules.add(resolution);
20843
20940
  allEntriesSet.add(resolution);
20844
20941
  allEntriesAndManualChunks.push([resolution]);
20845
- dynamicImportsForCurrentEntry.add(resolution);
20846
20942
  }
20847
20943
  }
20848
20944
  }
@@ -20852,6 +20948,9 @@ function analyzeModuleGraph(entries, manualChunkModules, manualChunkModulesByMod
20852
20948
  allEntriesSet.add(dependency);
20853
20949
  allEntriesAndManualChunks.push([dependency]);
20854
20950
  }
20951
+ if (dynamicEntryModules.has(dependency)) {
20952
+ dynamicImportsForCurrentEntry.add(dependency);
20953
+ }
20855
20954
  }
20856
20955
  }
20857
20956
  // A dynamic import can be awaited indirectly through a static dependency.
@@ -24333,7 +24432,7 @@ class Graph {
24333
24432
  if (importDescription.name !== '*' && importDescription.phase !== 'source') {
24334
24433
  const [variable, options] = importDescription.module.getVariableForExportName(importDescription.name, { importChain: [module.id] });
24335
24434
  if (!variable) {
24336
- module.log(LOGLEVEL_WARN, logMissingExport(importDescription.name, module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
24435
+ module.log(LOGLEVEL_WARN, logMissingExport(unescapeExportName(importDescription.name), module.id, importDescription.module.id, !!options?.missingButExportExists), importDescription.start);
24337
24436
  }
24338
24437
  }
24339
24438
  }