rollup 4.15.0 → 4.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parseAst.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -438,7 +438,7 @@ function logDeprecation(deprecation, urlSnippet, plugin) {
438
438
  code: DEPRECATED_FEATURE,
439
439
  message: deprecation,
440
440
  url: getRollupUrl(urlSnippet),
441
- ...(plugin ? { plugin } : {})
441
+ ...({})
442
442
  };
443
443
  }
444
444
  function logConstVariableReassignError() {
@@ -980,11 +980,11 @@ function logFailedValidation(message) {
980
980
  };
981
981
  }
982
982
  function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
983
- warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations, plugin);
983
+ warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations);
984
984
  }
985
985
  function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
986
- if (activeDeprecation || strictDeprecations) {
987
- const warning = logDeprecation(deprecation, urlSnippet, plugin);
986
+ {
987
+ const warning = logDeprecation(deprecation, urlSnippet);
988
988
  if (strictDeprecations) {
989
989
  return error(warning);
990
990
  }
@@ -1005,6 +1005,7 @@ const ArrowFunctionExpression = 'ArrowFunctionExpression';
1005
1005
  const BlockStatement = 'BlockStatement';
1006
1006
  const CallExpression = 'CallExpression';
1007
1007
  const CatchClause = 'CatchClause';
1008
+ const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
1008
1009
  const ExpressionStatement = 'ExpressionStatement';
1009
1010
  const Identifier = 'Identifier';
1010
1011
  const Literal = 'Literal';
@@ -1014,6 +1015,7 @@ const Program = 'Program';
1014
1015
  const Property = 'Property';
1015
1016
  const ReturnStatement = 'ReturnStatement';
1016
1017
  const TemplateLiteral = 'TemplateLiteral';
1018
+ const VariableDeclarator = 'VariableDeclarator';
1017
1019
 
1018
1020
  // This file is generated by scripts/generate-string-constants.js.
1019
1021
  // Do not edit this file directly.
@@ -2276,6 +2278,7 @@ exports.CatchClause = CatchClause;
2276
2278
  exports.EMPTY_ARRAY = EMPTY_ARRAY;
2277
2279
  exports.EMPTY_OBJECT = EMPTY_OBJECT;
2278
2280
  exports.EMPTY_SET = EMPTY_SET;
2281
+ exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
2279
2282
  exports.ExpressionStatement = ExpressionStatement;
2280
2283
  exports.FIXED_STRINGS = FIXED_STRINGS;
2281
2284
  exports.INVALID_ANNOTATION_KEY = INVALID_ANNOTATION_KEY;
@@ -2311,6 +2314,7 @@ exports.URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = URL_TREATING_MODULE_AS_EXTE
2311
2314
  exports.URL_TREESHAKE = URL_TREESHAKE;
2312
2315
  exports.URL_TREESHAKE_MODULESIDEEFFECTS = URL_TREESHAKE_MODULESIDEEFFECTS;
2313
2316
  exports.URL_WATCH = URL_WATCH;
2317
+ exports.VariableDeclarator = VariableDeclarator;
2314
2318
  exports.addTrailingSlashIfMissed = addTrailingSlashIfMissed;
2315
2319
  exports.augmentCodeLocation = augmentCodeLocation;
2316
2320
  exports.augmentLogMessage = augmentLogMessage;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
31
31
 
32
32
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
33
33
 
34
- var version = "4.15.0";
34
+ var version = "4.16.0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -3393,6 +3393,9 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
3393
3393
  };
3394
3394
 
3395
3395
  class Variable extends ExpressionEntity {
3396
+ markReassigned() {
3397
+ this.isReassigned = true;
3398
+ }
3396
3399
  constructor(name) {
3397
3400
  super();
3398
3401
  this.name = name;
@@ -3400,16 +3403,36 @@ class Variable extends ExpressionEntity {
3400
3403
  this.forbiddenNames = null;
3401
3404
  this.initReached = false;
3402
3405
  this.isId = false;
3403
- this.isReassigned = false;
3404
3406
  this.kind = null;
3405
3407
  this.renderBaseName = null;
3406
3408
  this.renderName = null;
3409
+ this.isReassigned = false;
3410
+ this.onlyFunctionCallUsed = true;
3407
3411
  }
3408
3412
  /**
3409
3413
  * Binds identifiers that reference this variable to this variable.
3410
3414
  * Necessary to be able to change variable names.
3411
3415
  */
3412
3416
  addReference(_identifier) { }
3417
+ /**
3418
+ * Check if the identifier variable is only used as function call
3419
+ * Forward the check to the export default variable if it is only used once
3420
+ * @returns true if the variable is only used as function call
3421
+ */
3422
+ getOnlyFunctionCallUsed() {
3423
+ return this.onlyFunctionCallUsed;
3424
+ }
3425
+ /**
3426
+ * Collect the places where the identifier variable is used
3427
+ * @param usedPlace Where the variable is used
3428
+ */
3429
+ addUsedPlace(usedPlace) {
3430
+ const isFunctionCall = usedPlace.parent.type === parseAst_js.CallExpression &&
3431
+ usedPlace.parent.callee === usedPlace;
3432
+ if (!isFunctionCall && usedPlace.parent.type !== parseAst_js.ExportDefaultDeclaration) {
3433
+ this.onlyFunctionCallUsed = false;
3434
+ }
3435
+ }
3413
3436
  /**
3414
3437
  * Prevent this variable from being renamed to this name to avoid name
3415
3438
  * collisions
@@ -7147,7 +7170,7 @@ class LocalVariable extends Variable {
7147
7170
  return;
7148
7171
  }
7149
7172
  if (path.length === 0) {
7150
- this.isReassigned = true;
7173
+ this.markReassigned();
7151
7174
  const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized;
7152
7175
  this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
7153
7176
  for (const expression of expressionsToBeDeoptimized) {
@@ -7241,7 +7264,7 @@ class LocalVariable extends Variable {
7241
7264
  if (this.additionalInitializers === null) {
7242
7265
  this.additionalInitializers = [this.init];
7243
7266
  this.init = UNKNOWN_EXPRESSION;
7244
- this.isReassigned = true;
7267
+ this.markReassigned();
7245
7268
  }
7246
7269
  return this.additionalInitializers;
7247
7270
  }
@@ -7259,6 +7282,8 @@ class ParameterVariable extends LocalVariable {
7259
7282
  this.deoptimizations = new PathTracker();
7260
7283
  this.deoptimizedFields = new Set();
7261
7284
  this.entitiesToBeDeoptimized = new Set();
7285
+ this.knownExpressionsToBeDeoptimized = [];
7286
+ this.knownValue = UNKNOWN_EXPRESSION;
7262
7287
  }
7263
7288
  addEntityToBeDeoptimized(entity) {
7264
7289
  if (entity === UNKNOWN_EXPRESSION) {
@@ -7288,6 +7313,47 @@ class ParameterVariable extends LocalVariable {
7288
7313
  }
7289
7314
  }
7290
7315
  }
7316
+ markReassigned() {
7317
+ if (this.isReassigned) {
7318
+ return;
7319
+ }
7320
+ super.markReassigned();
7321
+ for (const expression of this.knownExpressionsToBeDeoptimized) {
7322
+ expression.deoptimizeCache();
7323
+ }
7324
+ this.knownExpressionsToBeDeoptimized = [];
7325
+ }
7326
+ /**
7327
+ * If we are sure about the value of this parameter, we can set it here.
7328
+ * It can be a literal or the only possible value of the parameter.
7329
+ * an undefined value means that the parameter is not known.
7330
+ * @param value The known value of the parameter to be set.
7331
+ */
7332
+ setKnownValue(value) {
7333
+ if (this.isReassigned) {
7334
+ return;
7335
+ }
7336
+ if (this.knownValue !== value) {
7337
+ for (const expression of this.knownExpressionsToBeDeoptimized) {
7338
+ expression.deoptimizeCache();
7339
+ }
7340
+ this.knownExpressionsToBeDeoptimized = [];
7341
+ }
7342
+ this.knownValue = value;
7343
+ }
7344
+ getLiteralValueAtPath(path, recursionTracker, origin) {
7345
+ if (this.isReassigned) {
7346
+ return UnknownValue;
7347
+ }
7348
+ this.knownExpressionsToBeDeoptimized.push(origin);
7349
+ return recursionTracker.withTrackedEntityAtPath(path, this.knownValue, () => this.knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
7350
+ }
7351
+ hasEffectsOnInteractionAtPath(path, interaction, context) {
7352
+ // assigned is a bit different, since the value has a new name (the parameter)
7353
+ return interaction.type === INTERACTION_ASSIGNED
7354
+ ? super.hasEffectsOnInteractionAtPath(path, interaction, context)
7355
+ : this.knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
7356
+ }
7291
7357
  deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
7292
7358
  // For performance reasons, we fully deoptimize all deeper interactions
7293
7359
  if (path.length >= 2 ||
@@ -7312,7 +7378,11 @@ class ParameterVariable extends LocalVariable {
7312
7378
  }
7313
7379
  }
7314
7380
  deoptimizePath(path) {
7315
- if (path.length === 0 || this.deoptimizedFields.has(UnknownKey)) {
7381
+ if (this.deoptimizedFields.has(UnknownKey)) {
7382
+ return;
7383
+ }
7384
+ if (path.length === 0) {
7385
+ this.markReassigned();
7316
7386
  return;
7317
7387
  }
7318
7388
  const key = path[0];
@@ -8674,11 +8744,11 @@ function getGlobalAtPath(path) {
8674
8744
  }
8675
8745
 
8676
8746
  class GlobalVariable extends Variable {
8677
- constructor() {
8678
- super(...arguments);
8747
+ constructor(name) {
8748
+ super(name);
8679
8749
  // Ensure we use live-bindings for globals as we do not know if they have
8680
8750
  // been reassigned
8681
- this.isReassigned = true;
8751
+ this.markReassigned();
8682
8752
  }
8683
8753
  deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
8684
8754
  switch (interaction.type) {
@@ -8732,6 +8802,7 @@ class Identifier extends NodeBase {
8732
8802
  constructor() {
8733
8803
  super(...arguments);
8734
8804
  this.variable = null;
8805
+ this.isReferenceVariable = false;
8735
8806
  }
8736
8807
  get isTDZAccess() {
8737
8808
  if (!isFlagSet(this.flags, 4 /* Flag.tdzAccessDefined */)) {
@@ -8752,6 +8823,7 @@ class Identifier extends NodeBase {
8752
8823
  if (!this.variable && is_reference(this, this.parent)) {
8753
8824
  this.variable = this.scope.findVariable(this.name);
8754
8825
  this.variable.addReference(this);
8826
+ this.isReferenceVariable = true;
8755
8827
  }
8756
8828
  }
8757
8829
  declare(kind, init) {
@@ -8914,6 +8986,9 @@ class Identifier extends NodeBase {
8914
8986
  this.variable.consolidateInitializers();
8915
8987
  this.scope.context.requestTreeshakingPass();
8916
8988
  }
8989
+ if (this.isReferenceVariable) {
8990
+ this.variable.addUsedPlace(this);
8991
+ }
8917
8992
  }
8918
8993
  getVariableRespectingTDZ() {
8919
8994
  if (this.isPossibleTDZ()) {
@@ -9233,10 +9308,17 @@ class RestElement extends NodeBase {
9233
9308
  }
9234
9309
  }
9235
9310
 
9311
+ // This handler does nothing.
9312
+ // Since we always re-evaluate argument values in a new tree-shaking pass,
9313
+ // we don't need to get notified if it is deoptimized.
9314
+ const EMPTY_DEOPTIMIZABLE_HANDLER = { deoptimizeCache() { } };
9236
9315
  class FunctionBase extends NodeBase {
9237
9316
  constructor() {
9238
9317
  super(...arguments);
9318
+ this.knownParameterValues = [];
9319
+ this.allArguments = [];
9239
9320
  this.objectEntity = null;
9321
+ this.functionParametersOptimized = false;
9240
9322
  }
9241
9323
  get async() {
9242
9324
  return isFlagSet(this.flags, 256 /* Flag.async */);
@@ -9256,6 +9338,87 @@ class FunctionBase extends NodeBase {
9256
9338
  set generator(value) {
9257
9339
  this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
9258
9340
  }
9341
+ /**
9342
+ * update knownParameterValues when a call is made to this function
9343
+ * @param newArguments arguments of the call
9344
+ */
9345
+ updateKnownParameterValues(newArguments) {
9346
+ for (let position = 0; position < this.params.length; position++) {
9347
+ // only the "this" argument newArguments[0] can be null
9348
+ // it's possible that some arguments are empty, so the value is undefined
9349
+ const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
9350
+ const parameter = this.params[position];
9351
+ // RestElement can be, and can only be, the last parameter
9352
+ if (parameter instanceof RestElement) {
9353
+ return;
9354
+ }
9355
+ const knownParameterValue = this.knownParameterValues[position];
9356
+ if (knownParameterValue === undefined) {
9357
+ this.knownParameterValues[position] = argument;
9358
+ continue;
9359
+ }
9360
+ if (knownParameterValue === UNKNOWN_EXPRESSION ||
9361
+ knownParameterValue === argument ||
9362
+ (knownParameterValue instanceof Identifier &&
9363
+ argument instanceof Identifier &&
9364
+ knownParameterValue.variable === argument.variable)) {
9365
+ continue;
9366
+ }
9367
+ const oldValue = knownParameterValue.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
9368
+ const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
9369
+ if (oldValue !== newValue || typeof oldValue === 'symbol') {
9370
+ this.knownParameterValues[position] = UNKNOWN_EXPRESSION;
9371
+ } // else both are the same literal, no need to update
9372
+ }
9373
+ }
9374
+ forwardArgumentsForFunctionCalledOnce(newArguments) {
9375
+ for (let position = 0; position < this.params.length; position++) {
9376
+ const parameter = this.params[position];
9377
+ if (parameter instanceof Identifier) {
9378
+ const ParameterVariable = parameter.variable;
9379
+ const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
9380
+ ParameterVariable?.setKnownValue(argument);
9381
+ }
9382
+ }
9383
+ }
9384
+ /**
9385
+ * each time tree-shake starts, this method should be called to reoptimize the parameters
9386
+ * a parameter's state will change at most twice:
9387
+ * `undefined` (no call is made) -> an expression -> `UnknownArgument`
9388
+ * we are sure it will converge, and can use state from last iteration
9389
+ */
9390
+ applyFunctionParameterOptimization() {
9391
+ if (this.allArguments.length === 0) {
9392
+ return;
9393
+ }
9394
+ if (this.allArguments.length === 1) {
9395
+ // we are sure what knownParameterValues will be, so skip it and do setKnownValue
9396
+ this.forwardArgumentsForFunctionCalledOnce(this.allArguments[0]);
9397
+ return;
9398
+ }
9399
+ // reoptimize all arguments, that's why we save them
9400
+ for (const argumentsList of this.allArguments) {
9401
+ this.updateKnownParameterValues(argumentsList);
9402
+ }
9403
+ for (let position = 0; position < this.params.length; position++) {
9404
+ const parameter = this.params[position];
9405
+ // Parameters without default values
9406
+ if (parameter instanceof Identifier) {
9407
+ const parameterVariable = parameter.variable;
9408
+ // Only the RestElement may be undefined
9409
+ const knownParameterValue = this.knownParameterValues[position];
9410
+ parameterVariable?.setKnownValue(knownParameterValue);
9411
+ }
9412
+ }
9413
+ }
9414
+ deoptimizeFunctionParameters() {
9415
+ for (const parameter of this.params) {
9416
+ if (parameter instanceof Identifier) {
9417
+ const parameterVariable = parameter.variable;
9418
+ parameterVariable?.markReassigned();
9419
+ }
9420
+ }
9421
+ }
9259
9422
  deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
9260
9423
  if (interaction.type === INTERACTION_CALLED) {
9261
9424
  const { parameters } = this.scope;
@@ -9280,6 +9443,7 @@ class FunctionBase extends NodeBase {
9280
9443
  this.addArgumentToBeDeoptimized(argument);
9281
9444
  }
9282
9445
  }
9446
+ this.allArguments.push(args);
9283
9447
  }
9284
9448
  else {
9285
9449
  this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
@@ -9294,6 +9458,7 @@ class FunctionBase extends NodeBase {
9294
9458
  for (const parameterList of this.scope.parameters) {
9295
9459
  for (const parameter of parameterList) {
9296
9460
  parameter.deoptimizePath(UNKNOWN_PATH);
9461
+ parameter.markReassigned();
9297
9462
  }
9298
9463
  }
9299
9464
  }
@@ -9339,7 +9504,30 @@ class FunctionBase extends NodeBase {
9339
9504
  }
9340
9505
  return false;
9341
9506
  }
9507
+ /**
9508
+ * If the function (expression or declaration) is only used as function calls
9509
+ */
9510
+ onlyFunctionCallUsed() {
9511
+ let variable = null;
9512
+ if (this.parent.type === parseAst_js.VariableDeclarator) {
9513
+ variable = this.parent.id.variable ?? null;
9514
+ }
9515
+ if (this.parent.type === parseAst_js.ExportDefaultDeclaration) {
9516
+ variable = this.parent.variable;
9517
+ }
9518
+ return variable?.getOnlyFunctionCallUsed() ?? false;
9519
+ }
9342
9520
  include(context, includeChildrenRecursively) {
9521
+ const isIIFE = this.parent.type === parseAst_js.CallExpression &&
9522
+ this.parent.callee === this;
9523
+ const shoulOptimizeFunctionParameters = isIIFE || this.onlyFunctionCallUsed();
9524
+ if (shoulOptimizeFunctionParameters) {
9525
+ this.applyFunctionParameterOptimization();
9526
+ }
9527
+ else if (this.functionParametersOptimized) {
9528
+ this.deoptimizeFunctionParameters();
9529
+ }
9530
+ this.functionParametersOptimized = shoulOptimizeFunctionParameters;
9343
9531
  if (!this.deoptimized)
9344
9532
  this.applyDeoptimizations();
9345
9533
  this.included = true;
@@ -10089,7 +10277,7 @@ class MemberExpression extends NodeBase {
10089
10277
  }
10090
10278
  deoptimizeCache() {
10091
10279
  const { expressionsToBeDeoptimized, object } = this;
10092
- this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
10280
+ this.expressionsToBeDeoptimized = [];
10093
10281
  this.propertyKey = UnknownKey;
10094
10282
  object.deoptimizePath(UNKNOWN_PATH);
10095
10283
  for (const expression of expressionsToBeDeoptimized) {
@@ -10238,6 +10426,9 @@ class MemberExpression extends NodeBase {
10238
10426
  this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
10239
10427
  this.scope.context.requestTreeshakingPass();
10240
10428
  }
10429
+ if (this.variable) {
10430
+ this.variable.addUsedPlace(this);
10431
+ }
10241
10432
  }
10242
10433
  applyAssignmentDeoptimization() {
10243
10434
  this.assignmentDeoptimized = true;
@@ -10887,15 +11078,16 @@ class ConditionalExpression extends NodeBase {
10887
11078
  this.alternate.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
10888
11079
  }
10889
11080
  deoptimizeCache() {
11081
+ this.isBranchResolutionAnalysed = false;
11082
+ const { expressionsToBeDeoptimized } = this;
11083
+ this.expressionsToBeDeoptimized = [];
11084
+ for (const expression of expressionsToBeDeoptimized) {
11085
+ expression.deoptimizeCache();
11086
+ }
10890
11087
  if (this.usedBranch !== null) {
10891
11088
  const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
10892
11089
  this.usedBranch = null;
10893
11090
  unusedBranch.deoptimizePath(UNKNOWN_PATH);
10894
- const { expressionsToBeDeoptimized } = this;
10895
- this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
10896
- for (const expression of expressionsToBeDeoptimized) {
10897
- expression.deoptimizeCache();
10898
- }
10899
11091
  }
10900
11092
  }
10901
11093
  deoptimizePath(path) {
@@ -10909,10 +11101,10 @@ class ConditionalExpression extends NodeBase {
10909
11101
  }
10910
11102
  }
10911
11103
  getLiteralValueAtPath(path, recursionTracker, origin) {
11104
+ this.expressionsToBeDeoptimized.push(origin);
10912
11105
  const usedBranch = this.getUsedBranch();
10913
11106
  if (!usedBranch)
10914
11107
  return UnknownValue;
10915
- this.expressionsToBeDeoptimized.push(origin);
10916
11108
  return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
10917
11109
  }
10918
11110
  getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
@@ -11111,6 +11303,10 @@ class FunctionDeclaration extends FunctionNode {
11111
11303
  this.id.variable.isId = true;
11112
11304
  }
11113
11305
  }
11306
+ onlyFunctionCallUsed() {
11307
+ // call super.onlyFunctionCallUsed for export default anonymous function
11308
+ return this.id?.variable.getOnlyFunctionCallUsed() ?? super.onlyFunctionCallUsed();
11309
+ }
11114
11310
  parseNode(esTreeNode) {
11115
11311
  if (esTreeNode.id !== null) {
11116
11312
  this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
@@ -11399,7 +11595,7 @@ class IfStatement extends NodeBase {
11399
11595
  this.testValue = unset;
11400
11596
  }
11401
11597
  deoptimizeCache() {
11402
- this.testValue = UnknownValue;
11598
+ this.testValue = unset;
11403
11599
  }
11404
11600
  hasEffects(context) {
11405
11601
  if (this.test.hasEffects(context)) {
@@ -12207,12 +12403,10 @@ class LogicalExpression extends NodeBase {
12207
12403
  this.right.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
12208
12404
  }
12209
12405
  deoptimizeCache() {
12210
- if (this.usedBranch) {
12211
- const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
12212
- this.usedBranch = null;
12213
- unusedBranch.deoptimizePath(UNKNOWN_PATH);
12406
+ this.isBranchResolutionAnalysed = false;
12407
+ if (this.expressionsToBeDeoptimized.length > 0) {
12214
12408
  const { scope: { context }, expressionsToBeDeoptimized } = this;
12215
- this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
12409
+ this.expressionsToBeDeoptimized = [];
12216
12410
  for (const expression of expressionsToBeDeoptimized) {
12217
12411
  expression.deoptimizeCache();
12218
12412
  }
@@ -12220,6 +12414,11 @@ class LogicalExpression extends NodeBase {
12220
12414
  // it is rendered
12221
12415
  context.requestTreeshakingPass();
12222
12416
  }
12417
+ if (this.usedBranch) {
12418
+ const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
12419
+ this.usedBranch = null;
12420
+ unusedBranch.deoptimizePath(UNKNOWN_PATH);
12421
+ }
12223
12422
  }
12224
12423
  deoptimizePath(path) {
12225
12424
  const usedBranch = this.getUsedBranch();
@@ -12232,10 +12431,10 @@ class LogicalExpression extends NodeBase {
12232
12431
  }
12233
12432
  }
12234
12433
  getLiteralValueAtPath(path, recursionTracker, origin) {
12434
+ this.expressionsToBeDeoptimized.push(origin);
12235
12435
  const usedBranch = this.getUsedBranch();
12236
12436
  if (!usedBranch)
12237
12437
  return UnknownValue;
12238
- this.expressionsToBeDeoptimized.push(origin);
12239
12438
  return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
12240
12439
  }
12241
12440
  getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
@@ -13177,6 +13376,15 @@ class ExportDefaultVariable extends LocalVariable {
13177
13376
  this.name = identifier.name;
13178
13377
  }
13179
13378
  }
13379
+ addUsedPlace(usedPlace) {
13380
+ const original = this.getOriginalVariable();
13381
+ if (original === this) {
13382
+ super.addUsedPlace(usedPlace);
13383
+ }
13384
+ else {
13385
+ original.addUsedPlace(usedPlace);
13386
+ }
13387
+ }
13180
13388
  forbidName(name) {
13181
13389
  const original = this.getOriginalVariable();
13182
13390
  if (original === this) {
@@ -13450,7 +13658,7 @@ class UpdateExpression extends NodeBase {
13450
13658
  this.argument.deoptimizePath(EMPTY_PATH);
13451
13659
  if (this.argument instanceof Identifier) {
13452
13660
  const variable = this.scope.findVariable(this.argument.name);
13453
- variable.isReassigned = true;
13661
+ variable.markReassigned();
13454
13662
  }
13455
13663
  this.scope.context.requestTreeshakingPass();
13456
13664
  }
@@ -19435,7 +19643,7 @@ function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
19435
19643
 
19436
19644
  function flru (max) {
19437
19645
  var num, curr, prev;
19438
- var limit = max || 1;
19646
+ var limit = max ;
19439
19647
 
19440
19648
  function keep(key, value) {
19441
19649
  if (++num > limit) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.15.0
4
- Sat, 20 Apr 2024 05:36:39 GMT - commit e6e05cde31fc144228bb825c9d4ebba2f377075c
3
+ Rollup.js v4.16.0
4
+ Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "4.15.0",
3
+ "version": "4.16.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -104,22 +104,22 @@
104
104
  "homepage": "https://rollupjs.org/",
105
105
  "optionalDependencies": {
106
106
  "fsevents": "~2.3.2",
107
- "@rollup/rollup-darwin-arm64": "4.15.0",
108
- "@rollup/rollup-android-arm64": "4.15.0",
109
- "@rollup/rollup-win32-arm64-msvc": "4.15.0",
110
- "@rollup/rollup-linux-arm64-gnu": "4.15.0",
111
- "@rollup/rollup-linux-arm64-musl": "4.15.0",
112
- "@rollup/rollup-android-arm-eabi": "4.15.0",
113
- "@rollup/rollup-linux-arm-gnueabihf": "4.15.0",
114
- "@rollup/rollup-linux-arm-musleabihf": "4.15.0",
115
- "@rollup/rollup-win32-ia32-msvc": "4.15.0",
116
- "@rollup/rollup-linux-riscv64-gnu": "4.15.0",
117
- "@rollup/rollup-linux-powerpc64le-gnu": "4.15.0",
118
- "@rollup/rollup-linux-s390x-gnu": "4.15.0",
119
- "@rollup/rollup-darwin-x64": "4.15.0",
120
- "@rollup/rollup-win32-x64-msvc": "4.15.0",
121
- "@rollup/rollup-linux-x64-gnu": "4.15.0",
122
- "@rollup/rollup-linux-x64-musl": "4.15.0"
107
+ "@rollup/rollup-darwin-arm64": "4.16.0",
108
+ "@rollup/rollup-android-arm64": "4.16.0",
109
+ "@rollup/rollup-win32-arm64-msvc": "4.16.0",
110
+ "@rollup/rollup-linux-arm64-gnu": "4.16.0",
111
+ "@rollup/rollup-linux-arm64-musl": "4.16.0",
112
+ "@rollup/rollup-android-arm-eabi": "4.16.0",
113
+ "@rollup/rollup-linux-arm-gnueabihf": "4.16.0",
114
+ "@rollup/rollup-linux-arm-musleabihf": "4.16.0",
115
+ "@rollup/rollup-win32-ia32-msvc": "4.16.0",
116
+ "@rollup/rollup-linux-riscv64-gnu": "4.16.0",
117
+ "@rollup/rollup-linux-powerpc64le-gnu": "4.16.0",
118
+ "@rollup/rollup-linux-s390x-gnu": "4.16.0",
119
+ "@rollup/rollup-darwin-x64": "4.16.0",
120
+ "@rollup/rollup-win32-x64-msvc": "4.16.0",
121
+ "@rollup/rollup-linux-x64-gnu": "4.16.0",
122
+ "@rollup/rollup-linux-x64-musl": "4.16.0"
123
123
  },
124
124
  "dependencies": {
125
125
  "@types/estree": "1.0.5"