@rollup/wasm-node 4.68.4 → 4.68.6

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.68.4
4
- Mon, 16 Nov 2026 08:59:19 GMT - commit 9b2de5068e925a3b07bea67c972de21a347af9d9
3
+ Rollup.js v4.68.6
4
+ Wed, 18 Nov 2026 08:15:34 GMT - commit 2aa77c89eef0113e61b8de29d54c086c1f21a72b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
8
8
  Released under the MIT License.
9
9
  */
10
- import { EmptyStatement as EmptyStatement$1, BlockStatement as BlockStatement$1, 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, ForOfStatement as ForOfStatement$1, ForInStatement as ForInStatement$1, SwitchCase as SwitchCase$1, ExportNamedDeclaration as ExportNamedDeclaration$1, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, 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';
10
+ import { EmptyStatement as EmptyStatement$1, BlockStatement as BlockStatement$1, 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, ForOfStatement as ForOfStatement$1, ForInStatement as ForInStatement$1, SwitchCase as SwitchCase$1, ExportNamedDeclaration as ExportNamedDeclaration$1, getImportPath, error, logSourcePhaseFormatUnsupported, logMissingNodeBuiltins, logReservedNamespace, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, EMPTY_SET, logCannotCallNamespace, logEval, logThisIsUndefined, getRollupError, logModuleParseError, logParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, 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.68.4";
30
+ var version = "4.68.6";
31
31
  const pkg = {
32
32
  version: version};
33
33
 
@@ -15301,16 +15301,331 @@ class ImportSpecifier extends NodeBase {
15301
15301
  ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
15302
15302
  ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
15303
15303
 
15304
+ class ModuleScope extends ChildScope {
15305
+ constructor(parent, context, importDescriptions) {
15306
+ super(parent, context);
15307
+ this.importDescriptions = importDescriptions;
15308
+ this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
15309
+ }
15310
+ addDeclaration(identifier, context, init, destructuredInitPath, kind) {
15311
+ if (this.importDescriptions.has(identifier.name)) {
15312
+ context.error(logRedeclarationError(identifier.name), identifier.start);
15313
+ }
15314
+ return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
15315
+ }
15316
+ addExportDefaultDeclaration(exportDefaultDeclaration, context) {
15317
+ const variable = new ExportDefaultVariable(exportDefaultDeclaration, context);
15318
+ this.variables.set('default', variable);
15319
+ return variable;
15320
+ }
15321
+ addNamespaceMemberAccess() { }
15322
+ deconflict(format, exportNamesByVariable, accessedGlobalsByScope) {
15323
+ // all module level variables are already deconflicted when deconflicting the chunk
15324
+ for (const scope of this.children)
15325
+ scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
15326
+ }
15327
+ findLexicalBoundary() {
15328
+ return this;
15329
+ }
15330
+ findVariable(name) {
15331
+ const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name);
15332
+ if (knownVariable) {
15333
+ return knownVariable;
15334
+ }
15335
+ const variable = this.context.traceVariable(name) || this.parent.findVariable(name);
15336
+ if (variable instanceof GlobalVariable) {
15337
+ this.accessedOutsideVariables.set(name, variable);
15338
+ }
15339
+ return variable;
15340
+ }
15341
+ }
15342
+
15343
+ class ObjectExpression extends NodeBase {
15344
+ constructor() {
15345
+ super(...arguments);
15346
+ this.objectEntity = null;
15347
+ this.protoProp = null;
15348
+ }
15349
+ deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
15350
+ this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
15351
+ }
15352
+ deoptimizeCache() {
15353
+ this.getObjectEntity().deoptimizeAllProperties();
15354
+ }
15355
+ deoptimizePath(path) {
15356
+ this.getObjectEntity().deoptimizePath(path);
15357
+ }
15358
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
15359
+ return this.getObjectEntity().getKnownFunctionAtPath(path, recursionTracker, origin);
15360
+ }
15361
+ getLiteralValueAtPath(path, recursionTracker, origin) {
15362
+ return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
15363
+ }
15364
+ getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
15365
+ return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
15366
+ }
15367
+ hasEffectsOnInteractionAtPath(path, interaction, context) {
15368
+ return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
15369
+ }
15370
+ include(context, includeChildrenRecursively) {
15371
+ if (!this.included)
15372
+ this.includeNode(context);
15373
+ this.getObjectEntity().include(context, includeChildrenRecursively);
15374
+ this.protoProp?.include(context, includeChildrenRecursively);
15375
+ }
15376
+ includeNode(context) {
15377
+ this.included = true;
15378
+ this.protoProp?.includePath(UNKNOWN_PATH, context);
15379
+ }
15380
+ includePath(path, context) {
15381
+ if (!this.included)
15382
+ this.includeNode(context);
15383
+ this.getObjectEntity().includePath(path, context);
15384
+ }
15385
+ includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
15386
+ this.getObjectEntity().includeCallArgumentsWhenCalledAtPath(path, interaction, context);
15387
+ }
15388
+ render(code, options, { renderedSurroundingElement } = BLANK) {
15389
+ if (renderedSurroundingElement === ExpressionStatement$1 ||
15390
+ renderedSurroundingElement === ArrowFunctionExpression$1) {
15391
+ code.appendRight(this.start, '(');
15392
+ code.prependLeft(this.end, ')');
15393
+ }
15394
+ if (this.properties.length > 0) {
15395
+ const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
15396
+ let lastSeparatorPos = null;
15397
+ for (const { node, separator, start, end } of separatedNodes) {
15398
+ if (!node.included) {
15399
+ treeshakeNode(node, code, start, end);
15400
+ continue;
15401
+ }
15402
+ lastSeparatorPos = separator;
15403
+ node.render(code, options);
15404
+ }
15405
+ if (lastSeparatorPos) {
15406
+ code.remove(lastSeparatorPos, this.end - 1);
15407
+ }
15408
+ }
15409
+ }
15410
+ getObjectEntity() {
15411
+ if (this.objectEntity !== null) {
15412
+ return this.objectEntity;
15413
+ }
15414
+ let prototype = OBJECT_PROTOTYPE;
15415
+ const properties = [];
15416
+ for (const property of this.properties) {
15417
+ if (property instanceof SpreadElement) {
15418
+ properties.push({ key: UnknownKey, kind: 'init', property });
15419
+ continue;
15420
+ }
15421
+ let key;
15422
+ if (property.computed) {
15423
+ const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
15424
+ if (typeof keyValue === 'symbol') {
15425
+ properties.push({
15426
+ key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey,
15427
+ kind: property.kind,
15428
+ property
15429
+ });
15430
+ continue;
15431
+ }
15432
+ else {
15433
+ key = String(keyValue);
15434
+ }
15435
+ }
15436
+ else {
15437
+ key =
15438
+ property.key instanceof Identifier
15439
+ ? property.key.name
15440
+ : String(property.key.value);
15441
+ if (key === '__proto__' && property.kind === 'init') {
15442
+ this.protoProp = property;
15443
+ prototype =
15444
+ property.value instanceof Literal && property.value.value === null
15445
+ ? null
15446
+ : property.value;
15447
+ continue;
15448
+ }
15449
+ }
15450
+ properties.push({ key, kind: property.kind, property });
15451
+ }
15452
+ return (this.objectEntity = new ObjectEntity(properties, prototype));
15453
+ }
15454
+ }
15455
+ ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
15456
+
15457
+ class Property extends MethodBase {
15458
+ //declare method: boolean;
15459
+ get method() {
15460
+ return isFlagSet(this.flags, 262144 /* Flag.method */);
15461
+ }
15462
+ set method(value) {
15463
+ this.flags = setFlag(this.flags, 262144 /* Flag.method */, value);
15464
+ }
15465
+ //declare shorthand: boolean;
15466
+ get shorthand() {
15467
+ return isFlagSet(this.flags, 524288 /* Flag.shorthand */);
15468
+ }
15469
+ set shorthand(value) {
15470
+ this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
15471
+ }
15472
+ declare(kind, destructuredInitPath, init) {
15473
+ return this.value.declare(kind, this.getPathInProperty(destructuredInitPath), init);
15474
+ }
15475
+ deoptimizeAssignment(destructuredInitPath, init) {
15476
+ this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
15477
+ }
15478
+ hasEffects(context) {
15479
+ return this.key.hasEffects(context) || this.value.hasEffects(context);
15480
+ }
15481
+ hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
15482
+ return this.value.hasEffectsWhenDestructuring?.(context, this.getPathInProperty(destructuredInitPath), init);
15483
+ }
15484
+ includeDestructuredIfNecessary(context, destructuredInitPath, init) {
15485
+ const path = this.getPathInProperty(destructuredInitPath);
15486
+ let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
15487
+ this.included;
15488
+ if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
15489
+ this.key.include(context, false);
15490
+ if (!this.value.included) {
15491
+ this.value.includeNode(context);
15492
+ // Unfortunately, we need to include the value again now, so that any
15493
+ // declared variables are properly included.
15494
+ this.value.includeDestructuredIfNecessary(context, path, init);
15495
+ }
15496
+ }
15497
+ if (!this.included && included) {
15498
+ this.includeNode(context);
15499
+ }
15500
+ return this.included;
15501
+ }
15502
+ include(context, includeChildrenRecursively) {
15503
+ this.included = true;
15504
+ this.key.include(context, includeChildrenRecursively);
15505
+ this.value.include(context, includeChildrenRecursively);
15506
+ }
15507
+ includePath(path, context) {
15508
+ this.included = true;
15509
+ this.value.includePath(path, context);
15510
+ }
15511
+ markDeclarationReached() {
15512
+ this.value.markDeclarationReached();
15513
+ }
15514
+ render(code, options) {
15515
+ if (!this.shorthand) {
15516
+ this.key.render(code, options);
15517
+ }
15518
+ this.value.render(code, options, { isShorthandProperty: this.shorthand });
15519
+ }
15520
+ setAssignedValue(value) {
15521
+ this.value.setAssignedValue(value);
15522
+ }
15523
+ getPathInProperty(destructuredInitPath) {
15524
+ return destructuredInitPath.at(-1) === UnknownKey
15525
+ ? destructuredInitPath
15526
+ : // For now, we only consider static paths as we do not know how to
15527
+ // deoptimize the path in the dynamic case.
15528
+ this.computed
15529
+ ? [...destructuredInitPath, UnknownKey]
15530
+ : this.key instanceof Identifier
15531
+ ? [...destructuredInitPath, this.key.name]
15532
+ : [...destructuredInitPath, String(this.key.value)];
15533
+ }
15534
+ }
15535
+ Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
15536
+ Property.prototype.applyDeoptimizations = doNotDeoptimize;
15537
+
15538
+ class ThisExpression extends NodeBase {
15539
+ bind() {
15540
+ this.variable = this.scope.findVariable('this');
15541
+ }
15542
+ deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
15543
+ this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
15544
+ }
15545
+ deoptimizePath(path) {
15546
+ this.variable.deoptimizePath(path);
15547
+ }
15548
+ hasEffectsOnInteractionAtPath(path, interaction, context) {
15549
+ if (path.length === 0) {
15550
+ return interaction.type !== INTERACTION_ACCESSED;
15551
+ }
15552
+ return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
15553
+ }
15554
+ include(context) {
15555
+ if (!this.included)
15556
+ this.includeNode(context);
15557
+ }
15558
+ includeNode(context) {
15559
+ this.included = true;
15560
+ if (!this.deoptimized)
15561
+ this.applyDeoptimizations();
15562
+ this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
15563
+ }
15564
+ includePath(path, context) {
15565
+ if (!this.included) {
15566
+ this.included = true;
15567
+ this.scope.context.includeVariableInModule(this.variable, path, context);
15568
+ }
15569
+ else if (path.length > 0) {
15570
+ this.variable.includePath(path, context);
15571
+ }
15572
+ includeThisPathInObjectLiteral(this.scope, this.variable, path, context);
15573
+ }
15574
+ initialise() {
15575
+ super.initialise();
15576
+ this.alias = getTopLevelThisAlias(this.scope, this.start);
15577
+ }
15578
+ render(code) {
15579
+ if (this.alias !== null) {
15580
+ code.overwrite(this.start, this.end, this.alias, {
15581
+ contentOnly: false,
15582
+ storeName: true
15583
+ });
15584
+ }
15585
+ }
15586
+ }
15587
+ function getTopLevelThisAlias(scope, position) {
15588
+ if (!(scope.findLexicalBoundary() instanceof ModuleScope)) {
15589
+ return null;
15590
+ }
15591
+ const { moduleContext } = scope.context;
15592
+ if (moduleContext === 'undefined') {
15593
+ scope.context.log(LOGLEVEL_WARN, logThisIsUndefined(), position);
15594
+ }
15595
+ return moduleContext;
15596
+ }
15597
+ function includeThisPathInObjectLiteral(scope, thisVariable, path, context) {
15598
+ const functionScope = findFunctionScope(scope, thisVariable);
15599
+ if (functionScope &&
15600
+ functionScope.functionNode.parent instanceof Property &&
15601
+ functionScope.functionNode.parent.parent instanceof ObjectExpression) {
15602
+ functionScope.functionNode.parent.parent.includePath(path, context);
15603
+ }
15604
+ }
15605
+ function findFunctionScope(scope, thisVariable) {
15606
+ while (!(scope instanceof FunctionScope && scope.thisVariable === thisVariable)) {
15607
+ if (!(scope instanceof ChildScope)) {
15608
+ return null;
15609
+ }
15610
+ scope = scope.parent;
15611
+ }
15612
+ return scope;
15613
+ }
15614
+
15304
15615
  class JSXIdentifier extends IdentifierBase {
15305
15616
  constructor() {
15306
15617
  super(...arguments);
15307
15618
  this.isNativeElement = false;
15619
+ this.thisAlias = null;
15308
15620
  }
15309
15621
  bind() {
15310
15622
  const type = this.getType();
15311
15623
  if (type === 0 /* IdentifierType.Reference */) {
15312
15624
  this.variable = this.scope.findVariable(this.name);
15313
15625
  this.variable.addReference(this);
15626
+ if (this.name === 'this') {
15627
+ this.thisAlias = getTopLevelThisAlias(this.scope, this.start);
15628
+ }
15314
15629
  }
15315
15630
  else if (type === 1 /* IdentifierType.NativeElementName */) {
15316
15631
  this.isNativeElement = true;
@@ -15338,10 +15653,15 @@ class JSXIdentifier extends IdentifierBase {
15338
15653
  else if (path.length > 0) {
15339
15654
  this.variable?.includePath(path, context);
15340
15655
  }
15656
+ if (this.name === 'this' && this.variable) {
15657
+ includeThisPathInObjectLiteral(this.scope, this.variable, path, context);
15658
+ }
15341
15659
  }
15342
15660
  render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
15343
15661
  if (this.variable) {
15344
- const name = this.variable.getName(getPropertyAccess, useOriginalName);
15662
+ const name = this.name === 'this'
15663
+ ? (this.thisAlias ?? this.name)
15664
+ : this.variable.getName(getPropertyAccess, useOriginalName);
15345
15665
  if (name !== this.name) {
15346
15666
  code.overwrite(this.start, this.end, name, {
15347
15667
  contentOnly: true,
@@ -16132,159 +16452,45 @@ class NewExpression extends NodeBase {
16132
16452
  hasEffectsOnInteractionAtPath(path, { type }) {
16133
16453
  return path.length > 0 || type !== INTERACTION_ACCESSED;
16134
16454
  }
16135
- include(context, includeChildrenRecursively) {
16136
- if (!this.included)
16137
- this.includeNode(context);
16138
- if (includeChildrenRecursively) {
16139
- super.include(context, true);
16140
- }
16141
- else {
16142
- this.callee.include(context, false);
16143
- this.callee.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, this.interaction, context);
16144
- }
16145
- }
16146
- includeNode(context) {
16147
- this.included = true;
16148
- if (!this.deoptimized)
16149
- this.applyDeoptimizations();
16150
- this.callee.includePath(UNKNOWN_PATH, context);
16151
- }
16152
- initialise() {
16153
- super.initialise();
16154
- this.interaction = {
16155
- args: [null, ...this.arguments],
16156
- type: INTERACTION_CALLED,
16157
- withNew: true
16158
- };
16159
- if (this.annotations &&
16160
- this.scope.context.options.treeshake.annotations) {
16161
- this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
16162
- }
16163
- }
16164
- render(code, options) {
16165
- this.callee.render(code, options);
16166
- renderCallArguments(code, options, this);
16167
- }
16168
- applyDeoptimizations() {
16169
- this.deoptimized = true;
16170
- this.callee.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
16171
- this.scope.context.requestTreeshakingPass();
16172
- }
16173
- }
16174
-
16175
- class ObjectExpression extends NodeBase {
16176
- constructor() {
16177
- super(...arguments);
16178
- this.objectEntity = null;
16179
- this.protoProp = null;
16180
- }
16181
- deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
16182
- this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
16183
- }
16184
- deoptimizeCache() {
16185
- this.getObjectEntity().deoptimizeAllProperties();
16186
- }
16187
- deoptimizePath(path) {
16188
- this.getObjectEntity().deoptimizePath(path);
16189
- }
16190
- getKnownFunctionAtPath(path, recursionTracker, origin) {
16191
- return this.getObjectEntity().getKnownFunctionAtPath(path, recursionTracker, origin);
16192
- }
16193
- getLiteralValueAtPath(path, recursionTracker, origin) {
16194
- return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
16195
- }
16196
- getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
16197
- return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
16198
- }
16199
- hasEffectsOnInteractionAtPath(path, interaction, context) {
16200
- return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
16201
- }
16202
- include(context, includeChildrenRecursively) {
16203
- if (!this.included)
16204
- this.includeNode(context);
16205
- this.getObjectEntity().include(context, includeChildrenRecursively);
16206
- this.protoProp?.include(context, includeChildrenRecursively);
16207
- }
16208
- includeNode(context) {
16209
- this.included = true;
16210
- this.protoProp?.includePath(UNKNOWN_PATH, context);
16211
- }
16212
- includePath(path, context) {
16213
- if (!this.included)
16214
- this.includeNode(context);
16215
- this.getObjectEntity().includePath(path, context);
16216
- }
16217
- includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
16218
- this.getObjectEntity().includeCallArgumentsWhenCalledAtPath(path, interaction, context);
16219
- }
16220
- render(code, options, { renderedSurroundingElement } = BLANK) {
16221
- if (renderedSurroundingElement === ExpressionStatement$1 ||
16222
- renderedSurroundingElement === ArrowFunctionExpression$1) {
16223
- code.appendRight(this.start, '(');
16224
- code.prependLeft(this.end, ')');
16225
- }
16226
- if (this.properties.length > 0) {
16227
- const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
16228
- let lastSeparatorPos = null;
16229
- for (const { node, separator, start, end } of separatedNodes) {
16230
- if (!node.included) {
16231
- treeshakeNode(node, code, start, end);
16232
- continue;
16233
- }
16234
- lastSeparatorPos = separator;
16235
- node.render(code, options);
16236
- }
16237
- if (lastSeparatorPos) {
16238
- code.remove(lastSeparatorPos, this.end - 1);
16239
- }
16240
- }
16241
- }
16242
- getObjectEntity() {
16243
- if (this.objectEntity !== null) {
16244
- return this.objectEntity;
16455
+ include(context, includeChildrenRecursively) {
16456
+ if (!this.included)
16457
+ this.includeNode(context);
16458
+ if (includeChildrenRecursively) {
16459
+ super.include(context, true);
16245
16460
  }
16246
- let prototype = OBJECT_PROTOTYPE;
16247
- const properties = [];
16248
- for (const property of this.properties) {
16249
- if (property instanceof SpreadElement) {
16250
- properties.push({ key: UnknownKey, kind: 'init', property });
16251
- continue;
16252
- }
16253
- let key;
16254
- if (property.computed) {
16255
- const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
16256
- if (typeof keyValue === 'symbol') {
16257
- properties.push({
16258
- key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey,
16259
- kind: property.kind,
16260
- property
16261
- });
16262
- continue;
16263
- }
16264
- else {
16265
- key = String(keyValue);
16266
- }
16267
- }
16268
- else {
16269
- key =
16270
- property.key instanceof Identifier
16271
- ? property.key.name
16272
- : String(property.key.value);
16273
- if (key === '__proto__' && property.kind === 'init') {
16274
- this.protoProp = property;
16275
- prototype =
16276
- property.value instanceof Literal && property.value.value === null
16277
- ? null
16278
- : property.value;
16279
- continue;
16280
- }
16281
- }
16282
- properties.push({ key, kind: property.kind, property });
16461
+ else {
16462
+ this.callee.include(context, false);
16463
+ this.callee.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, this.interaction, context);
16283
16464
  }
16284
- return (this.objectEntity = new ObjectEntity(properties, prototype));
16465
+ }
16466
+ includeNode(context) {
16467
+ this.included = true;
16468
+ if (!this.deoptimized)
16469
+ this.applyDeoptimizations();
16470
+ this.callee.includePath(UNKNOWN_PATH, context);
16471
+ }
16472
+ initialise() {
16473
+ super.initialise();
16474
+ this.interaction = {
16475
+ args: [null, ...this.arguments],
16476
+ type: INTERACTION_CALLED,
16477
+ withNew: true
16478
+ };
16479
+ if (this.annotations &&
16480
+ this.scope.context.options.treeshake.annotations) {
16481
+ this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
16482
+ }
16483
+ }
16484
+ render(code, options) {
16485
+ this.callee.render(code, options);
16486
+ renderCallArguments(code, options, this);
16487
+ }
16488
+ applyDeoptimizations() {
16489
+ this.deoptimized = true;
16490
+ this.callee.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
16491
+ this.scope.context.requestTreeshakingPass();
16285
16492
  }
16286
16493
  }
16287
- ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
16288
16494
 
16289
16495
  class PanicError extends NodeBase {
16290
16496
  initialise() {
@@ -16383,87 +16589,6 @@ class Program extends NodeBase {
16383
16589
  Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
16384
16590
  Program.prototype.applyDeoptimizations = doNotDeoptimize;
16385
16591
 
16386
- class Property extends MethodBase {
16387
- //declare method: boolean;
16388
- get method() {
16389
- return isFlagSet(this.flags, 262144 /* Flag.method */);
16390
- }
16391
- set method(value) {
16392
- this.flags = setFlag(this.flags, 262144 /* Flag.method */, value);
16393
- }
16394
- //declare shorthand: boolean;
16395
- get shorthand() {
16396
- return isFlagSet(this.flags, 524288 /* Flag.shorthand */);
16397
- }
16398
- set shorthand(value) {
16399
- this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
16400
- }
16401
- declare(kind, destructuredInitPath, init) {
16402
- return this.value.declare(kind, this.getPathInProperty(destructuredInitPath), init);
16403
- }
16404
- deoptimizeAssignment(destructuredInitPath, init) {
16405
- this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
16406
- }
16407
- hasEffects(context) {
16408
- return this.key.hasEffects(context) || this.value.hasEffects(context);
16409
- }
16410
- hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
16411
- return this.value.hasEffectsWhenDestructuring?.(context, this.getPathInProperty(destructuredInitPath), init);
16412
- }
16413
- includeDestructuredIfNecessary(context, destructuredInitPath, init) {
16414
- const path = this.getPathInProperty(destructuredInitPath);
16415
- let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
16416
- this.included;
16417
- if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
16418
- this.key.include(context, false);
16419
- if (!this.value.included) {
16420
- this.value.includeNode(context);
16421
- // Unfortunately, we need to include the value again now, so that any
16422
- // declared variables are properly included.
16423
- this.value.includeDestructuredIfNecessary(context, path, init);
16424
- }
16425
- }
16426
- if (!this.included && included) {
16427
- this.includeNode(context);
16428
- }
16429
- return this.included;
16430
- }
16431
- include(context, includeChildrenRecursively) {
16432
- this.included = true;
16433
- this.key.include(context, includeChildrenRecursively);
16434
- this.value.include(context, includeChildrenRecursively);
16435
- }
16436
- includePath(path, context) {
16437
- this.included = true;
16438
- this.value.includePath(path, context);
16439
- }
16440
- markDeclarationReached() {
16441
- this.value.markDeclarationReached();
16442
- }
16443
- render(code, options) {
16444
- if (!this.shorthand) {
16445
- this.key.render(code, options);
16446
- }
16447
- this.value.render(code, options, { isShorthandProperty: this.shorthand });
16448
- }
16449
- setAssignedValue(value) {
16450
- this.value.setAssignedValue(value);
16451
- }
16452
- getPathInProperty(destructuredInitPath) {
16453
- return destructuredInitPath.at(-1) === UnknownKey
16454
- ? destructuredInitPath
16455
- : // For now, we only consider static paths as we do not know how to
16456
- // deoptimize the path in the dynamic case.
16457
- this.computed
16458
- ? [...destructuredInitPath, UnknownKey]
16459
- : this.key instanceof Identifier
16460
- ? [...destructuredInitPath, this.key.name]
16461
- : [...destructuredInitPath, String(this.key.value)];
16462
- }
16463
- }
16464
- Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
16465
- Property.prototype.applyDeoptimizations = doNotDeoptimize;
16466
-
16467
16592
  class ReturnStatement extends NodeBase {
16468
16593
  hasEffects(context) {
16469
16594
  if (!context.ignore.returnYield || this.argument?.hasEffects(context))
@@ -16839,115 +16964,6 @@ class TemplateLiteral extends NodeBase {
16839
16964
  }
16840
16965
  }
16841
16966
 
16842
- class ModuleScope extends ChildScope {
16843
- constructor(parent, context, importDescriptions) {
16844
- super(parent, context);
16845
- this.importDescriptions = importDescriptions;
16846
- this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
16847
- }
16848
- addDeclaration(identifier, context, init, destructuredInitPath, kind) {
16849
- if (this.importDescriptions.has(identifier.name)) {
16850
- context.error(logRedeclarationError(identifier.name), identifier.start);
16851
- }
16852
- return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
16853
- }
16854
- addExportDefaultDeclaration(exportDefaultDeclaration, context) {
16855
- const variable = new ExportDefaultVariable(exportDefaultDeclaration, context);
16856
- this.variables.set('default', variable);
16857
- return variable;
16858
- }
16859
- addNamespaceMemberAccess() { }
16860
- deconflict(format, exportNamesByVariable, accessedGlobalsByScope) {
16861
- // all module level variables are already deconflicted when deconflicting the chunk
16862
- for (const scope of this.children)
16863
- scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
16864
- }
16865
- findLexicalBoundary() {
16866
- return this;
16867
- }
16868
- findVariable(name) {
16869
- const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name);
16870
- if (knownVariable) {
16871
- return knownVariable;
16872
- }
16873
- const variable = this.context.traceVariable(name) || this.parent.findVariable(name);
16874
- if (variable instanceof GlobalVariable) {
16875
- this.accessedOutsideVariables.set(name, variable);
16876
- }
16877
- return variable;
16878
- }
16879
- }
16880
-
16881
- class ThisExpression extends NodeBase {
16882
- bind() {
16883
- this.variable = this.scope.findVariable('this');
16884
- }
16885
- deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
16886
- this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
16887
- }
16888
- deoptimizePath(path) {
16889
- this.variable.deoptimizePath(path);
16890
- }
16891
- hasEffectsOnInteractionAtPath(path, interaction, context) {
16892
- if (path.length === 0) {
16893
- return interaction.type !== INTERACTION_ACCESSED;
16894
- }
16895
- return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
16896
- }
16897
- include(context) {
16898
- if (!this.included)
16899
- this.includeNode(context);
16900
- }
16901
- includeNode(context) {
16902
- this.included = true;
16903
- if (!this.deoptimized)
16904
- this.applyDeoptimizations();
16905
- this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
16906
- }
16907
- includePath(path, context) {
16908
- if (!this.included) {
16909
- this.included = true;
16910
- this.scope.context.includeVariableInModule(this.variable, path, context);
16911
- }
16912
- else if (path.length > 0) {
16913
- this.variable.includePath(path, context);
16914
- }
16915
- const functionScope = findFunctionScope(this.scope, this.variable);
16916
- if (functionScope &&
16917
- functionScope.functionNode.parent instanceof Property &&
16918
- functionScope.functionNode.parent.parent instanceof ObjectExpression) {
16919
- functionScope.functionNode.parent.parent.includePath(path, context);
16920
- }
16921
- }
16922
- initialise() {
16923
- super.initialise();
16924
- this.alias =
16925
- this.scope.findLexicalBoundary() instanceof ModuleScope
16926
- ? this.scope.context.moduleContext
16927
- : null;
16928
- if (this.alias === 'undefined') {
16929
- this.scope.context.log(LOGLEVEL_WARN, logThisIsUndefined(), this.start);
16930
- }
16931
- }
16932
- render(code) {
16933
- if (this.alias !== null) {
16934
- code.overwrite(this.start, this.end, this.alias, {
16935
- contentOnly: false,
16936
- storeName: true
16937
- });
16938
- }
16939
- }
16940
- }
16941
- function findFunctionScope(scope, thisVariable) {
16942
- while (!(scope instanceof FunctionScope && scope.thisVariable === thisVariable)) {
16943
- if (!(scope instanceof ChildScope)) {
16944
- return null;
16945
- }
16946
- scope = scope.parent;
16947
- }
16948
- return scope;
16949
- }
16950
-
16951
16967
  class ThrowStatement extends NodeBase {
16952
16968
  hasEffects() {
16953
16969
  return true;