@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,7 +1,7 @@
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
 
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
42
42
 
43
43
  const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
44
44
 
45
- var version = "4.68.4";
45
+ var version = "4.68.6";
46
46
  const package_ = {
47
47
  version: version};
48
48
 
@@ -16918,16 +16918,331 @@ class ImportSpecifier extends NodeBase {
16918
16918
  ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
16919
16919
  ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
16920
16920
 
16921
+ class ModuleScope extends ChildScope {
16922
+ constructor(parent, context, importDescriptions) {
16923
+ super(parent, context);
16924
+ this.importDescriptions = importDescriptions;
16925
+ this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
16926
+ }
16927
+ addDeclaration(identifier, context, init, destructuredInitPath, kind) {
16928
+ if (this.importDescriptions.has(identifier.name)) {
16929
+ context.error(parseAst_js.logRedeclarationError(identifier.name), identifier.start);
16930
+ }
16931
+ return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
16932
+ }
16933
+ addExportDefaultDeclaration(exportDefaultDeclaration, context) {
16934
+ const variable = new ExportDefaultVariable(exportDefaultDeclaration, context);
16935
+ this.variables.set('default', variable);
16936
+ return variable;
16937
+ }
16938
+ addNamespaceMemberAccess() { }
16939
+ deconflict(format, exportNamesByVariable, accessedGlobalsByScope) {
16940
+ // all module level variables are already deconflicted when deconflicting the chunk
16941
+ for (const scope of this.children)
16942
+ scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
16943
+ }
16944
+ findLexicalBoundary() {
16945
+ return this;
16946
+ }
16947
+ findVariable(name) {
16948
+ const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name);
16949
+ if (knownVariable) {
16950
+ return knownVariable;
16951
+ }
16952
+ const variable = this.context.traceVariable(name) || this.parent.findVariable(name);
16953
+ if (variable instanceof GlobalVariable) {
16954
+ this.accessedOutsideVariables.set(name, variable);
16955
+ }
16956
+ return variable;
16957
+ }
16958
+ }
16959
+
16960
+ class ObjectExpression extends NodeBase {
16961
+ constructor() {
16962
+ super(...arguments);
16963
+ this.objectEntity = null;
16964
+ this.protoProp = null;
16965
+ }
16966
+ deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
16967
+ this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
16968
+ }
16969
+ deoptimizeCache() {
16970
+ this.getObjectEntity().deoptimizeAllProperties();
16971
+ }
16972
+ deoptimizePath(path) {
16973
+ this.getObjectEntity().deoptimizePath(path);
16974
+ }
16975
+ getKnownFunctionAtPath(path, recursionTracker, origin) {
16976
+ return this.getObjectEntity().getKnownFunctionAtPath(path, recursionTracker, origin);
16977
+ }
16978
+ getLiteralValueAtPath(path, recursionTracker, origin) {
16979
+ return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
16980
+ }
16981
+ getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
16982
+ return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
16983
+ }
16984
+ hasEffectsOnInteractionAtPath(path, interaction, context) {
16985
+ return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
16986
+ }
16987
+ include(context, includeChildrenRecursively) {
16988
+ if (!this.included)
16989
+ this.includeNode(context);
16990
+ this.getObjectEntity().include(context, includeChildrenRecursively);
16991
+ this.protoProp?.include(context, includeChildrenRecursively);
16992
+ }
16993
+ includeNode(context) {
16994
+ this.included = true;
16995
+ this.protoProp?.includePath(UNKNOWN_PATH, context);
16996
+ }
16997
+ includePath(path, context) {
16998
+ if (!this.included)
16999
+ this.includeNode(context);
17000
+ this.getObjectEntity().includePath(path, context);
17001
+ }
17002
+ includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
17003
+ this.getObjectEntity().includeCallArgumentsWhenCalledAtPath(path, interaction, context);
17004
+ }
17005
+ render(code, options, { renderedSurroundingElement } = parseAst_js.BLANK) {
17006
+ if (renderedSurroundingElement === parseAst_js.ExpressionStatement ||
17007
+ renderedSurroundingElement === parseAst_js.ArrowFunctionExpression) {
17008
+ code.appendRight(this.start, '(');
17009
+ code.prependLeft(this.end, ')');
17010
+ }
17011
+ if (this.properties.length > 0) {
17012
+ const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
17013
+ let lastSeparatorPos = null;
17014
+ for (const { node, separator, start, end } of separatedNodes) {
17015
+ if (!node.included) {
17016
+ treeshakeNode(node, code, start, end);
17017
+ continue;
17018
+ }
17019
+ lastSeparatorPos = separator;
17020
+ node.render(code, options);
17021
+ }
17022
+ if (lastSeparatorPos) {
17023
+ code.remove(lastSeparatorPos, this.end - 1);
17024
+ }
17025
+ }
17026
+ }
17027
+ getObjectEntity() {
17028
+ if (this.objectEntity !== null) {
17029
+ return this.objectEntity;
17030
+ }
17031
+ let prototype = OBJECT_PROTOTYPE;
17032
+ const properties = [];
17033
+ for (const property of this.properties) {
17034
+ if (property instanceof SpreadElement) {
17035
+ properties.push({ key: UnknownKey, kind: 'init', property });
17036
+ continue;
17037
+ }
17038
+ let key;
17039
+ if (property.computed) {
17040
+ const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
17041
+ if (typeof keyValue === 'symbol') {
17042
+ properties.push({
17043
+ key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey,
17044
+ kind: property.kind,
17045
+ property
17046
+ });
17047
+ continue;
17048
+ }
17049
+ else {
17050
+ key = String(keyValue);
17051
+ }
17052
+ }
17053
+ else {
17054
+ key =
17055
+ property.key instanceof Identifier
17056
+ ? property.key.name
17057
+ : String(property.key.value);
17058
+ if (key === '__proto__' && property.kind === 'init') {
17059
+ this.protoProp = property;
17060
+ prototype =
17061
+ property.value instanceof Literal && property.value.value === null
17062
+ ? null
17063
+ : property.value;
17064
+ continue;
17065
+ }
17066
+ }
17067
+ properties.push({ key, kind: property.kind, property });
17068
+ }
17069
+ return (this.objectEntity = new ObjectEntity(properties, prototype));
17070
+ }
17071
+ }
17072
+ ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
17073
+
17074
+ class Property extends MethodBase {
17075
+ //declare method: boolean;
17076
+ get method() {
17077
+ return isFlagSet(this.flags, 262144 /* Flag.method */);
17078
+ }
17079
+ set method(value) {
17080
+ this.flags = setFlag(this.flags, 262144 /* Flag.method */, value);
17081
+ }
17082
+ //declare shorthand: boolean;
17083
+ get shorthand() {
17084
+ return isFlagSet(this.flags, 524288 /* Flag.shorthand */);
17085
+ }
17086
+ set shorthand(value) {
17087
+ this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
17088
+ }
17089
+ declare(kind, destructuredInitPath, init) {
17090
+ return this.value.declare(kind, this.getPathInProperty(destructuredInitPath), init);
17091
+ }
17092
+ deoptimizeAssignment(destructuredInitPath, init) {
17093
+ this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
17094
+ }
17095
+ hasEffects(context) {
17096
+ return this.key.hasEffects(context) || this.value.hasEffects(context);
17097
+ }
17098
+ hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
17099
+ return this.value.hasEffectsWhenDestructuring?.(context, this.getPathInProperty(destructuredInitPath), init);
17100
+ }
17101
+ includeDestructuredIfNecessary(context, destructuredInitPath, init) {
17102
+ const path = this.getPathInProperty(destructuredInitPath);
17103
+ let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
17104
+ this.included;
17105
+ if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
17106
+ this.key.include(context, false);
17107
+ if (!this.value.included) {
17108
+ this.value.includeNode(context);
17109
+ // Unfortunately, we need to include the value again now, so that any
17110
+ // declared variables are properly included.
17111
+ this.value.includeDestructuredIfNecessary(context, path, init);
17112
+ }
17113
+ }
17114
+ if (!this.included && included) {
17115
+ this.includeNode(context);
17116
+ }
17117
+ return this.included;
17118
+ }
17119
+ include(context, includeChildrenRecursively) {
17120
+ this.included = true;
17121
+ this.key.include(context, includeChildrenRecursively);
17122
+ this.value.include(context, includeChildrenRecursively);
17123
+ }
17124
+ includePath(path, context) {
17125
+ this.included = true;
17126
+ this.value.includePath(path, context);
17127
+ }
17128
+ markDeclarationReached() {
17129
+ this.value.markDeclarationReached();
17130
+ }
17131
+ render(code, options) {
17132
+ if (!this.shorthand) {
17133
+ this.key.render(code, options);
17134
+ }
17135
+ this.value.render(code, options, { isShorthandProperty: this.shorthand });
17136
+ }
17137
+ setAssignedValue(value) {
17138
+ this.value.setAssignedValue(value);
17139
+ }
17140
+ getPathInProperty(destructuredInitPath) {
17141
+ return destructuredInitPath.at(-1) === UnknownKey
17142
+ ? destructuredInitPath
17143
+ : // For now, we only consider static paths as we do not know how to
17144
+ // deoptimize the path in the dynamic case.
17145
+ this.computed
17146
+ ? [...destructuredInitPath, UnknownKey]
17147
+ : this.key instanceof Identifier
17148
+ ? [...destructuredInitPath, this.key.name]
17149
+ : [...destructuredInitPath, String(this.key.value)];
17150
+ }
17151
+ }
17152
+ Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
17153
+ Property.prototype.applyDeoptimizations = doNotDeoptimize;
17154
+
17155
+ class ThisExpression extends NodeBase {
17156
+ bind() {
17157
+ this.variable = this.scope.findVariable('this');
17158
+ }
17159
+ deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
17160
+ this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
17161
+ }
17162
+ deoptimizePath(path) {
17163
+ this.variable.deoptimizePath(path);
17164
+ }
17165
+ hasEffectsOnInteractionAtPath(path, interaction, context) {
17166
+ if (path.length === 0) {
17167
+ return interaction.type !== INTERACTION_ACCESSED;
17168
+ }
17169
+ return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
17170
+ }
17171
+ include(context) {
17172
+ if (!this.included)
17173
+ this.includeNode(context);
17174
+ }
17175
+ includeNode(context) {
17176
+ this.included = true;
17177
+ if (!this.deoptimized)
17178
+ this.applyDeoptimizations();
17179
+ this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
17180
+ }
17181
+ includePath(path, context) {
17182
+ if (!this.included) {
17183
+ this.included = true;
17184
+ this.scope.context.includeVariableInModule(this.variable, path, context);
17185
+ }
17186
+ else if (path.length > 0) {
17187
+ this.variable.includePath(path, context);
17188
+ }
17189
+ includeThisPathInObjectLiteral(this.scope, this.variable, path, context);
17190
+ }
17191
+ initialise() {
17192
+ super.initialise();
17193
+ this.alias = getTopLevelThisAlias(this.scope, this.start);
17194
+ }
17195
+ render(code) {
17196
+ if (this.alias !== null) {
17197
+ code.overwrite(this.start, this.end, this.alias, {
17198
+ contentOnly: false,
17199
+ storeName: true
17200
+ });
17201
+ }
17202
+ }
17203
+ }
17204
+ function getTopLevelThisAlias(scope, position) {
17205
+ if (!(scope.findLexicalBoundary() instanceof ModuleScope)) {
17206
+ return null;
17207
+ }
17208
+ const { moduleContext } = scope.context;
17209
+ if (moduleContext === 'undefined') {
17210
+ scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logThisIsUndefined(), position);
17211
+ }
17212
+ return moduleContext;
17213
+ }
17214
+ function includeThisPathInObjectLiteral(scope, thisVariable, path, context) {
17215
+ const functionScope = findFunctionScope(scope, thisVariable);
17216
+ if (functionScope &&
17217
+ functionScope.functionNode.parent instanceof Property &&
17218
+ functionScope.functionNode.parent.parent instanceof ObjectExpression) {
17219
+ functionScope.functionNode.parent.parent.includePath(path, context);
17220
+ }
17221
+ }
17222
+ function findFunctionScope(scope, thisVariable) {
17223
+ while (!(scope instanceof FunctionScope && scope.thisVariable === thisVariable)) {
17224
+ if (!(scope instanceof ChildScope)) {
17225
+ return null;
17226
+ }
17227
+ scope = scope.parent;
17228
+ }
17229
+ return scope;
17230
+ }
17231
+
16921
17232
  class JSXIdentifier extends IdentifierBase {
16922
17233
  constructor() {
16923
17234
  super(...arguments);
16924
17235
  this.isNativeElement = false;
17236
+ this.thisAlias = null;
16925
17237
  }
16926
17238
  bind() {
16927
17239
  const type = this.getType();
16928
17240
  if (type === 0 /* IdentifierType.Reference */) {
16929
17241
  this.variable = this.scope.findVariable(this.name);
16930
17242
  this.variable.addReference(this);
17243
+ if (this.name === 'this') {
17244
+ this.thisAlias = getTopLevelThisAlias(this.scope, this.start);
17245
+ }
16931
17246
  }
16932
17247
  else if (type === 1 /* IdentifierType.NativeElementName */) {
16933
17248
  this.isNativeElement = true;
@@ -16955,10 +17270,15 @@ class JSXIdentifier extends IdentifierBase {
16955
17270
  else if (path.length > 0) {
16956
17271
  this.variable?.includePath(path, context);
16957
17272
  }
17273
+ if (this.name === 'this' && this.variable) {
17274
+ includeThisPathInObjectLiteral(this.scope, this.variable, path, context);
17275
+ }
16958
17276
  }
16959
17277
  render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
16960
17278
  if (this.variable) {
16961
- const name = this.variable.getName(getPropertyAccess, useOriginalName);
17279
+ const name = this.name === 'this'
17280
+ ? (this.thisAlias ?? this.name)
17281
+ : this.variable.getName(getPropertyAccess, useOriginalName);
16962
17282
  if (name !== this.name) {
16963
17283
  code.overwrite(this.start, this.end, name, {
16964
17284
  contentOnly: true,
@@ -17749,159 +18069,45 @@ class NewExpression extends NodeBase {
17749
18069
  hasEffectsOnInteractionAtPath(path, { type }) {
17750
18070
  return path.length > 0 || type !== INTERACTION_ACCESSED;
17751
18071
  }
17752
- include(context, includeChildrenRecursively) {
17753
- if (!this.included)
17754
- this.includeNode(context);
17755
- if (includeChildrenRecursively) {
17756
- super.include(context, true);
17757
- }
17758
- else {
17759
- this.callee.include(context, false);
17760
- this.callee.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, this.interaction, context);
17761
- }
17762
- }
17763
- includeNode(context) {
17764
- this.included = true;
17765
- if (!this.deoptimized)
17766
- this.applyDeoptimizations();
17767
- this.callee.includePath(UNKNOWN_PATH, context);
17768
- }
17769
- initialise() {
17770
- super.initialise();
17771
- this.interaction = {
17772
- args: [null, ...this.arguments],
17773
- type: INTERACTION_CALLED,
17774
- withNew: true
17775
- };
17776
- if (this.annotations &&
17777
- this.scope.context.options.treeshake.annotations) {
17778
- this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
17779
- }
17780
- }
17781
- render(code, options) {
17782
- this.callee.render(code, options);
17783
- renderCallArguments(code, options, this);
17784
- }
17785
- applyDeoptimizations() {
17786
- this.deoptimized = true;
17787
- this.callee.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
17788
- this.scope.context.requestTreeshakingPass();
17789
- }
17790
- }
17791
-
17792
- class ObjectExpression extends NodeBase {
17793
- constructor() {
17794
- super(...arguments);
17795
- this.objectEntity = null;
17796
- this.protoProp = null;
17797
- }
17798
- deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
17799
- this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
17800
- }
17801
- deoptimizeCache() {
17802
- this.getObjectEntity().deoptimizeAllProperties();
17803
- }
17804
- deoptimizePath(path) {
17805
- this.getObjectEntity().deoptimizePath(path);
17806
- }
17807
- getKnownFunctionAtPath(path, recursionTracker, origin) {
17808
- return this.getObjectEntity().getKnownFunctionAtPath(path, recursionTracker, origin);
17809
- }
17810
- getLiteralValueAtPath(path, recursionTracker, origin) {
17811
- return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
17812
- }
17813
- getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
17814
- return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
17815
- }
17816
- hasEffectsOnInteractionAtPath(path, interaction, context) {
17817
- return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
17818
- }
17819
- include(context, includeChildrenRecursively) {
17820
- if (!this.included)
17821
- this.includeNode(context);
17822
- this.getObjectEntity().include(context, includeChildrenRecursively);
17823
- this.protoProp?.include(context, includeChildrenRecursively);
17824
- }
17825
- includeNode(context) {
17826
- this.included = true;
17827
- this.protoProp?.includePath(UNKNOWN_PATH, context);
17828
- }
17829
- includePath(path, context) {
17830
- if (!this.included)
17831
- this.includeNode(context);
17832
- this.getObjectEntity().includePath(path, context);
17833
- }
17834
- includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
17835
- this.getObjectEntity().includeCallArgumentsWhenCalledAtPath(path, interaction, context);
17836
- }
17837
- render(code, options, { renderedSurroundingElement } = parseAst_js.BLANK) {
17838
- if (renderedSurroundingElement === parseAst_js.ExpressionStatement ||
17839
- renderedSurroundingElement === parseAst_js.ArrowFunctionExpression) {
17840
- code.appendRight(this.start, '(');
17841
- code.prependLeft(this.end, ')');
17842
- }
17843
- if (this.properties.length > 0) {
17844
- const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
17845
- let lastSeparatorPos = null;
17846
- for (const { node, separator, start, end } of separatedNodes) {
17847
- if (!node.included) {
17848
- treeshakeNode(node, code, start, end);
17849
- continue;
17850
- }
17851
- lastSeparatorPos = separator;
17852
- node.render(code, options);
17853
- }
17854
- if (lastSeparatorPos) {
17855
- code.remove(lastSeparatorPos, this.end - 1);
17856
- }
17857
- }
17858
- }
17859
- getObjectEntity() {
17860
- if (this.objectEntity !== null) {
17861
- return this.objectEntity;
18072
+ include(context, includeChildrenRecursively) {
18073
+ if (!this.included)
18074
+ this.includeNode(context);
18075
+ if (includeChildrenRecursively) {
18076
+ super.include(context, true);
17862
18077
  }
17863
- let prototype = OBJECT_PROTOTYPE;
17864
- const properties = [];
17865
- for (const property of this.properties) {
17866
- if (property instanceof SpreadElement) {
17867
- properties.push({ key: UnknownKey, kind: 'init', property });
17868
- continue;
17869
- }
17870
- let key;
17871
- if (property.computed) {
17872
- const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
17873
- if (typeof keyValue === 'symbol') {
17874
- properties.push({
17875
- key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey,
17876
- kind: property.kind,
17877
- property
17878
- });
17879
- continue;
17880
- }
17881
- else {
17882
- key = String(keyValue);
17883
- }
17884
- }
17885
- else {
17886
- key =
17887
- property.key instanceof Identifier
17888
- ? property.key.name
17889
- : String(property.key.value);
17890
- if (key === '__proto__' && property.kind === 'init') {
17891
- this.protoProp = property;
17892
- prototype =
17893
- property.value instanceof Literal && property.value.value === null
17894
- ? null
17895
- : property.value;
17896
- continue;
17897
- }
17898
- }
17899
- properties.push({ key, kind: property.kind, property });
18078
+ else {
18079
+ this.callee.include(context, false);
18080
+ this.callee.includeCallArgumentsWhenCalledAtPath(EMPTY_PATH, this.interaction, context);
17900
18081
  }
17901
- return (this.objectEntity = new ObjectEntity(properties, prototype));
18082
+ }
18083
+ includeNode(context) {
18084
+ this.included = true;
18085
+ if (!this.deoptimized)
18086
+ this.applyDeoptimizations();
18087
+ this.callee.includePath(UNKNOWN_PATH, context);
18088
+ }
18089
+ initialise() {
18090
+ super.initialise();
18091
+ this.interaction = {
18092
+ args: [null, ...this.arguments],
18093
+ type: INTERACTION_CALLED,
18094
+ withNew: true
18095
+ };
18096
+ if (this.annotations &&
18097
+ this.scope.context.options.treeshake.annotations) {
18098
+ this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
18099
+ }
18100
+ }
18101
+ render(code, options) {
18102
+ this.callee.render(code, options);
18103
+ renderCallArguments(code, options, this);
18104
+ }
18105
+ applyDeoptimizations() {
18106
+ this.deoptimized = true;
18107
+ this.callee.deoptimizeArgumentsOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
18108
+ this.scope.context.requestTreeshakingPass();
17902
18109
  }
17903
18110
  }
17904
- ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
17905
18111
 
17906
18112
  class PanicError extends NodeBase {
17907
18113
  initialise() {
@@ -18000,87 +18206,6 @@ class Program extends NodeBase {
18000
18206
  Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
18001
18207
  Program.prototype.applyDeoptimizations = doNotDeoptimize;
18002
18208
 
18003
- class Property extends MethodBase {
18004
- //declare method: boolean;
18005
- get method() {
18006
- return isFlagSet(this.flags, 262144 /* Flag.method */);
18007
- }
18008
- set method(value) {
18009
- this.flags = setFlag(this.flags, 262144 /* Flag.method */, value);
18010
- }
18011
- //declare shorthand: boolean;
18012
- get shorthand() {
18013
- return isFlagSet(this.flags, 524288 /* Flag.shorthand */);
18014
- }
18015
- set shorthand(value) {
18016
- this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
18017
- }
18018
- declare(kind, destructuredInitPath, init) {
18019
- return this.value.declare(kind, this.getPathInProperty(destructuredInitPath), init);
18020
- }
18021
- deoptimizeAssignment(destructuredInitPath, init) {
18022
- this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
18023
- }
18024
- hasEffects(context) {
18025
- return this.key.hasEffects(context) || this.value.hasEffects(context);
18026
- }
18027
- hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
18028
- return this.value.hasEffectsWhenDestructuring?.(context, this.getPathInProperty(destructuredInitPath), init);
18029
- }
18030
- includeDestructuredIfNecessary(context, destructuredInitPath, init) {
18031
- const path = this.getPathInProperty(destructuredInitPath);
18032
- let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
18033
- this.included;
18034
- if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
18035
- this.key.include(context, false);
18036
- if (!this.value.included) {
18037
- this.value.includeNode(context);
18038
- // Unfortunately, we need to include the value again now, so that any
18039
- // declared variables are properly included.
18040
- this.value.includeDestructuredIfNecessary(context, path, init);
18041
- }
18042
- }
18043
- if (!this.included && included) {
18044
- this.includeNode(context);
18045
- }
18046
- return this.included;
18047
- }
18048
- include(context, includeChildrenRecursively) {
18049
- this.included = true;
18050
- this.key.include(context, includeChildrenRecursively);
18051
- this.value.include(context, includeChildrenRecursively);
18052
- }
18053
- includePath(path, context) {
18054
- this.included = true;
18055
- this.value.includePath(path, context);
18056
- }
18057
- markDeclarationReached() {
18058
- this.value.markDeclarationReached();
18059
- }
18060
- render(code, options) {
18061
- if (!this.shorthand) {
18062
- this.key.render(code, options);
18063
- }
18064
- this.value.render(code, options, { isShorthandProperty: this.shorthand });
18065
- }
18066
- setAssignedValue(value) {
18067
- this.value.setAssignedValue(value);
18068
- }
18069
- getPathInProperty(destructuredInitPath) {
18070
- return destructuredInitPath.at(-1) === UnknownKey
18071
- ? destructuredInitPath
18072
- : // For now, we only consider static paths as we do not know how to
18073
- // deoptimize the path in the dynamic case.
18074
- this.computed
18075
- ? [...destructuredInitPath, UnknownKey]
18076
- : this.key instanceof Identifier
18077
- ? [...destructuredInitPath, this.key.name]
18078
- : [...destructuredInitPath, String(this.key.value)];
18079
- }
18080
- }
18081
- Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
18082
- Property.prototype.applyDeoptimizations = doNotDeoptimize;
18083
-
18084
18209
  class ReturnStatement extends NodeBase {
18085
18210
  hasEffects(context) {
18086
18211
  if (!context.ignore.returnYield || this.argument?.hasEffects(context))
@@ -18456,115 +18581,6 @@ class TemplateLiteral extends NodeBase {
18456
18581
  }
18457
18582
  }
18458
18583
 
18459
- class ModuleScope extends ChildScope {
18460
- constructor(parent, context, importDescriptions) {
18461
- super(parent, context);
18462
- this.importDescriptions = importDescriptions;
18463
- this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
18464
- }
18465
- addDeclaration(identifier, context, init, destructuredInitPath, kind) {
18466
- if (this.importDescriptions.has(identifier.name)) {
18467
- context.error(parseAst_js.logRedeclarationError(identifier.name), identifier.start);
18468
- }
18469
- return super.addDeclaration(identifier, context, init, destructuredInitPath, kind);
18470
- }
18471
- addExportDefaultDeclaration(exportDefaultDeclaration, context) {
18472
- const variable = new ExportDefaultVariable(exportDefaultDeclaration, context);
18473
- this.variables.set('default', variable);
18474
- return variable;
18475
- }
18476
- addNamespaceMemberAccess() { }
18477
- deconflict(format, exportNamesByVariable, accessedGlobalsByScope) {
18478
- // all module level variables are already deconflicted when deconflicting the chunk
18479
- for (const scope of this.children)
18480
- scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope);
18481
- }
18482
- findLexicalBoundary() {
18483
- return this;
18484
- }
18485
- findVariable(name) {
18486
- const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name);
18487
- if (knownVariable) {
18488
- return knownVariable;
18489
- }
18490
- const variable = this.context.traceVariable(name) || this.parent.findVariable(name);
18491
- if (variable instanceof GlobalVariable) {
18492
- this.accessedOutsideVariables.set(name, variable);
18493
- }
18494
- return variable;
18495
- }
18496
- }
18497
-
18498
- class ThisExpression extends NodeBase {
18499
- bind() {
18500
- this.variable = this.scope.findVariable('this');
18501
- }
18502
- deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
18503
- this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
18504
- }
18505
- deoptimizePath(path) {
18506
- this.variable.deoptimizePath(path);
18507
- }
18508
- hasEffectsOnInteractionAtPath(path, interaction, context) {
18509
- if (path.length === 0) {
18510
- return interaction.type !== INTERACTION_ACCESSED;
18511
- }
18512
- return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
18513
- }
18514
- include(context) {
18515
- if (!this.included)
18516
- this.includeNode(context);
18517
- }
18518
- includeNode(context) {
18519
- this.included = true;
18520
- if (!this.deoptimized)
18521
- this.applyDeoptimizations();
18522
- this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
18523
- }
18524
- includePath(path, context) {
18525
- if (!this.included) {
18526
- this.included = true;
18527
- this.scope.context.includeVariableInModule(this.variable, path, context);
18528
- }
18529
- else if (path.length > 0) {
18530
- this.variable.includePath(path, context);
18531
- }
18532
- const functionScope = findFunctionScope(this.scope, this.variable);
18533
- if (functionScope &&
18534
- functionScope.functionNode.parent instanceof Property &&
18535
- functionScope.functionNode.parent.parent instanceof ObjectExpression) {
18536
- functionScope.functionNode.parent.parent.includePath(path, context);
18537
- }
18538
- }
18539
- initialise() {
18540
- super.initialise();
18541
- this.alias =
18542
- this.scope.findLexicalBoundary() instanceof ModuleScope
18543
- ? this.scope.context.moduleContext
18544
- : null;
18545
- if (this.alias === 'undefined') {
18546
- this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logThisIsUndefined(), this.start);
18547
- }
18548
- }
18549
- render(code) {
18550
- if (this.alias !== null) {
18551
- code.overwrite(this.start, this.end, this.alias, {
18552
- contentOnly: false,
18553
- storeName: true
18554
- });
18555
- }
18556
- }
18557
- }
18558
- function findFunctionScope(scope, thisVariable) {
18559
- while (!(scope instanceof FunctionScope && scope.thisVariable === thisVariable)) {
18560
- if (!(scope instanceof ChildScope)) {
18561
- return null;
18562
- }
18563
- scope = scope.parent;
18564
- }
18565
- return scope;
18566
- }
18567
-
18568
18584
  class ThrowStatement extends NodeBase {
18569
18585
  hasEffects() {
18570
18586
  return true;