rollup 3.14.0 → 3.15.1-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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://rollupjs.org/"><img src="https://rollupjs.org/logo.svg" width="150" /></a>
2
+ <a href="https://rollupjs.org/"><img src="https://rollupjs.org/rollup-logo.svg" width="150" /></a>
3
3
  </p>
4
4
 
5
5
  <p align="center">
package/dist/bin/rollup CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v3.14.0
6
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
5
+ Rollup.js v3.15.1-0
6
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
7
7
 
8
8
  https://github.com/rollup/rollup
9
9
 
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version$1 = "3.14.0";
19
+ var version$1 = "3.15.1-0";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -5025,7 +5025,8 @@ function createHasEffectsContext() {
5025
5025
  breaks: false,
5026
5026
  continues: false,
5027
5027
  labels: new Set(),
5028
- returnYield: false
5028
+ returnYield: false,
5029
+ this: false
5029
5030
  },
5030
5031
  includedLabels: new Set(),
5031
5032
  instantiated: new DiscriminatedPathTracker(),
@@ -8487,7 +8488,8 @@ class ArrowFunctionExpression extends FunctionBase {
8487
8488
  breaks: false,
8488
8489
  continues: false,
8489
8490
  labels: new Set(),
8490
- returnYield: true
8491
+ returnYield: true,
8492
+ this: false
8491
8493
  };
8492
8494
  if (this.body.hasEffects(context))
8493
8495
  return true;
@@ -8757,11 +8759,14 @@ class ThisVariable extends LocalVariable {
8757
8759
  }
8758
8760
  }
8759
8761
  hasEffectsOnInteractionAtPath(path, interaction, context) {
8760
- return (this.getInit(context).hasEffectsOnInteractionAtPath(path, interaction, context) ||
8761
- super.hasEffectsOnInteractionAtPath(path, interaction, context));
8762
- }
8763
- getInit(context) {
8764
- return context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION;
8762
+ const replacedVariableInit = context.replacedVariableInits.get(this);
8763
+ if (replacedVariableInit) {
8764
+ return (replacedVariableInit.hasEffectsOnInteractionAtPath(path, interaction, context) ||
8765
+ // If the surrounding function is included, all mutations of "this" must
8766
+ // be counted as side effects, which is what this second line does.
8767
+ (!context.ignore.this && super.hasEffectsOnInteractionAtPath(path, interaction, context)));
8768
+ }
8769
+ return UNKNOWN_EXPRESSION.hasEffectsOnInteractionAtPath(path, interaction, context);
8765
8770
  }
8766
8771
  }
8767
8772
 
@@ -8793,6 +8798,10 @@ class FunctionNode extends FunctionBase {
8793
8798
  }
8794
8799
  createScope(parentScope) {
8795
8800
  this.scope = new FunctionScope(parentScope, this.context);
8801
+ this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
8802
+ // This makes sure that all deoptimizations of "this" are applied to the
8803
+ // constructed entity.
8804
+ this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
8796
8805
  }
8797
8806
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
8798
8807
  super.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
@@ -8810,15 +8819,14 @@ class FunctionNode extends FunctionBase {
8810
8819
  return true;
8811
8820
  if (interaction.type === INTERACTION_CALLED) {
8812
8821
  const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
8813
- context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew
8814
- ? new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE)
8815
- : UNKNOWN_EXPRESSION);
8822
+ context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew ? this.constructedEntity : UNKNOWN_EXPRESSION);
8816
8823
  const { brokenFlow, ignore, replacedVariableInits } = context;
8817
8824
  context.ignore = {
8818
8825
  breaks: false,
8819
8826
  continues: false,
8820
8827
  labels: new Set(),
8821
- returnYield: true
8828
+ returnYield: true,
8829
+ this: interaction.withNew
8822
8830
  };
8823
8831
  if (this.body.hasEffects(context))
8824
8832
  return true;
@@ -16111,7 +16119,7 @@ function analyzeModuleGraph(entries) {
16111
16119
  }
16112
16120
  }
16113
16121
  return {
16114
- allEntries,
16122
+ allEntries: [...allEntries],
16115
16123
  dependentEntriesByModule,
16116
16124
  dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
16117
16125
  };
@@ -16185,7 +16193,7 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
16185
16193
  alias: null,
16186
16194
  modules
16187
16195
  }))
16188
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
16196
+ : getOptimizedChunks(chunkModulesBySignature, allEntries.length, minChunkSize).map(({ modules }) => ({
16189
16197
  alias: null,
16190
16198
  modules
16191
16199
  }));
@@ -16209,49 +16217,109 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
16209
16217
  }
16210
16218
  /**
16211
16219
  * This function tries to get rid of small chunks by merging them with other
16212
- * chunks. In order to merge chunks, one must obey the following rule:
16213
- * - When merging several chunks, at most one of the chunks can have side
16214
- * effects
16215
- * - When one of the chunks has side effects, the entry points depending on that
16216
- * chunk need to be a super set of the entry points depending on the other
16217
- * chunks
16218
- * - Pure chunks can always be merged
16219
- * - We use the entry point dependence signature to calculate "chunk distance",
16220
- * i.e. how likely it is that two chunks are loaded together
16220
+ * chunks.
16221
+ *
16222
+ * We can only merge chunks safely if after the merge, loading any entry point
16223
+ * in any allowed order will not trigger side effects that should not have been
16224
+ * triggered. While side effects are usually things like global function calls,
16225
+ * global variable mutations or potentially thrown errors, details do not
16226
+ * matter here, and we just discern chunks without side effects (pure chunks)
16227
+ * from other chunks.
16228
+ *
16229
+ * As a first step, we assign each pre-generated chunk with side effects a
16230
+ * label. I.e. we have side effect "A" if the non-pure chunk "A" is loaded.
16231
+ *
16232
+ * Now to determine the side effects of loading a chunk, one also has to take
16233
+ * the side effects of its dependencies into account. So if A depends on B
16234
+ * (A -> B) and both have side effects, loading A triggers effects AB.
16235
+ *
16236
+ * Now from the previous step we know that each chunk is uniquely determine by
16237
+ * the entry points that depend on it and cause it to load, which we will call
16238
+ * its dependent entry points.
16239
+ *
16240
+ * E.g. if X -> A and Y -> A, then the dependent entry points of A are XY.
16241
+ * Starting from that idea, we can determine a set of chunks—and thus a set
16242
+ * of side effects—that must have been triggered if a certain chunk has been
16243
+ * loaded. Basically, it is the intersection of all chunks loaded by the
16244
+ * dependent entry points of a given chunk. We call the corresponding side
16245
+ * effects the correlated side effects of that chunk.
16246
+ *
16247
+ * Example:
16248
+ * X -> ABC, Y -> ADE, A-> F, B -> D
16249
+ * Then taking dependencies into account, X -> ABCDF, Y -> ADEF
16250
+ * The intersection is ADF. So we know that when A is loaded, D and F must also
16251
+ * be in memory even though neither D nor A is a dependency of the other.
16252
+ * If all have side effects, we call ADF the correlated side effects of A. The
16253
+ * correlated side effects need to remain constant when merging chunks.
16254
+ *
16255
+ * In contrast, we have the dependency side effects of A, which represents
16256
+ * the side effects we trigger if we directly load A. In this example, the
16257
+ * dependency side effects are AF.
16258
+ * For entry chunks, dependency and correlated side effects are the same.
16259
+ *
16260
+ * With these concepts, merging chunks is allowed if the correlated side effects
16261
+ * of each entry do not change. Thus, we are allowed to merge two chunks if
16262
+ * a) the dependency side effects of each chunk are a subset of the correlated
16263
+ * side effects of the other chunk, so no additional side effects are
16264
+ * triggered for any entry, or
16265
+ * b) The signature of chunk A is a subset of the signature of chunk B while the
16266
+ * dependency side effects of A are a subset of the correlated side effects
16267
+ * of B. Because in that scenario, whenever A is loaded, B is loaded as well.
16268
+ * But there are cases when B is loaded where A is not loaded. So if we merge
16269
+ * the chunks, all dependency side effects of A will be added to the
16270
+ * correlated side effects of B, and as the latter is not allowed to change,
16271
+ * the former need to be a subset of the latter.
16272
+ *
16273
+ * Another consideration when merging small chunks into other chunks is to avoid
16274
+ * that too much additional code is loaded. This is achieved when the dependent
16275
+ * entries of the small chunk are a subset of the dependent entries of the other
16276
+ * chunk. Because then when the small chunk is loaded, the other chunk was
16277
+ * loaded/in memory anyway, so at most when the other chunk is loaded, the
16278
+ * additional size of the small chunk is loaded unnecessarily.
16279
+ *
16280
+ * So the algorithm performs merges in two passes:
16281
+ * 1. First we try to merge small chunks A only into other chunks B if the
16282
+ * dependent entries of A are a subset of the dependent entries of B and the
16283
+ * dependency side effects of A are a subset of the correlated side effects
16284
+ * of B.
16285
+ * 2. Only then for all remaining small chunks, we look for arbitrary merges
16286
+ * following the above rules (a) and (b), starting with the smallest chunks
16287
+ * to look for possible merge targets.
16221
16288
  */
16222
- function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16289
+ function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
16223
16290
  timeStart('optimize chunks', 3);
16224
- const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
16225
- if (chunkPartition.small.sideEffect.size > 0) {
16226
- mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
16227
- }
16228
- if (chunkPartition.small.pure.size > 0) {
16229
- mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
16291
+ const chunkPartition = getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize);
16292
+ if (chunkPartition.small.size > 0) {
16293
+ mergeChunks(chunkPartition, minChunkSize);
16230
16294
  }
16231
16295
  timeEnd('optimize chunks', 3);
16232
- return [
16233
- ...chunkPartition.small.sideEffect,
16234
- ...chunkPartition.small.pure,
16235
- ...chunkPartition.big.sideEffect,
16236
- ...chunkPartition.big.pure
16237
- ];
16296
+ return [...chunkPartition.small, ...chunkPartition.big];
16238
16297
  }
16239
16298
  const CHAR_DEPENDENT = 'X';
16240
16299
  const CHAR_INDEPENDENT = '_';
16241
- const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
16242
- function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16243
- const smallPureChunks = [];
16244
- const bigPureChunks = [];
16245
- const smallSideEffectChunks = [];
16246
- const bigSideEffectChunks = [];
16300
+ function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
16301
+ const smallChunks = [];
16302
+ const bigChunks = [];
16247
16303
  const chunkByModule = new Map();
16304
+ const sideEffectsByEntry = [];
16305
+ for (let index = 0; index < numberOfEntries; index++) {
16306
+ sideEffectsByEntry.push(new Set());
16307
+ }
16248
16308
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16309
+ const dependentEntries = new Set();
16310
+ for (let position = 0; position < numberOfEntries; position++) {
16311
+ if (signature[position] === CHAR_DEPENDENT) {
16312
+ dependentEntries.add(position);
16313
+ }
16314
+ }
16249
16315
  const chunkDescription = {
16316
+ correlatedSideEffects: new Set(),
16250
16317
  dependencies: new Set(),
16251
16318
  dependentChunks: new Set(),
16319
+ dependentEntries,
16252
16320
  modules,
16253
16321
  pure: true,
16254
- signature,
16322
+ sideEffects: new Set(),
16255
16323
  size: 0
16256
16324
  };
16257
16325
  let size = 0;
@@ -16265,25 +16333,27 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16265
16333
  }
16266
16334
  chunkDescription.pure = pure;
16267
16335
  chunkDescription.size = size;
16268
- (size < minChunkSize
16269
- ? pure
16270
- ? smallPureChunks
16271
- : smallSideEffectChunks
16272
- : pure
16273
- ? bigPureChunks
16274
- : bigSideEffectChunks).push(chunkDescription);
16275
- }
16276
- sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
16336
+ if (!pure) {
16337
+ for (const entryIndex of dependentEntries) {
16338
+ sideEffectsByEntry[entryIndex].add(signature);
16339
+ }
16340
+ // In the beginning, each chunk is only its own side effect. After
16341
+ // merging, additional side effects can accumulate.
16342
+ chunkDescription.sideEffects.add(signature);
16343
+ }
16344
+ (size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
16345
+ }
16346
+ sortChunksAndAddDependenciesAndEffects([bigChunks, smallChunks], chunkByModule, sideEffectsByEntry);
16277
16347
  return {
16278
- big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
16279
- small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
16348
+ big: new Set(bigChunks),
16349
+ small: new Set(smallChunks)
16280
16350
  };
16281
16351
  }
16282
- function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16352
+ function sortChunksAndAddDependenciesAndEffects(chunkLists, chunkByModule, sideEffectsByEntry) {
16283
16353
  for (const chunks of chunkLists) {
16284
- chunks.sort(compareChunks);
16354
+ chunks.sort(compareChunkSize);
16285
16355
  for (const chunk of chunks) {
16286
- const { dependencies, modules } = chunk;
16356
+ const { dependencies, modules, correlatedSideEffects, dependentEntries } = chunk;
16287
16357
  for (const module of modules) {
16288
16358
  for (const dependency of module.getDependenciesToBeIncluded()) {
16289
16359
  const dependencyChunk = chunkByModule.get(dependency);
@@ -16293,89 +16363,129 @@ function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16293
16363
  }
16294
16364
  }
16295
16365
  }
16366
+ let firstEntry = true;
16367
+ // Correlated side effects is the intersection of all entry side effects
16368
+ for (const entryIndex of dependentEntries) {
16369
+ const entryEffects = sideEffectsByEntry[entryIndex];
16370
+ if (firstEntry) {
16371
+ for (const sideEffect of entryEffects) {
16372
+ correlatedSideEffects.add(sideEffect);
16373
+ }
16374
+ firstEntry = false;
16375
+ }
16376
+ else {
16377
+ for (const sideEffect of correlatedSideEffects) {
16378
+ if (!entryEffects.has(sideEffect)) {
16379
+ correlatedSideEffects.delete(sideEffect);
16380
+ }
16381
+ }
16382
+ }
16383
+ }
16296
16384
  }
16297
16385
  }
16298
16386
  }
16299
- function compareChunks({ size: sizeA }, { size: sizeB }) {
16387
+ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
16300
16388
  return sizeA - sizeB;
16301
16389
  }
16302
- function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
16303
- for (const mergedChunk of chunksToBeMerged) {
16304
- let closestChunk = null;
16305
- let closestChunkDistance = Infinity;
16306
- const { signature, modules, pure, size } = mergedChunk;
16307
- for (const targetChunk of concatLazy(targetChunks)) {
16308
- if (mergedChunk === targetChunk)
16309
- continue;
16310
- // Possible improvement:
16311
- // For dynamic entries depending on a pure chunk, it is safe to merge that
16312
- // chunk into the chunk doing the dynamic import (i.e. into an "already
16313
- // loaded chunk") even if it is not pure.
16314
- // One way of handling this could be to add all "already loaded entries"
16315
- // of the dynamic importers into the signature as well. That could also
16316
- // change the way we do code-splitting for already loaded entries.
16317
- const distance = pure
16318
- ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16319
- : getSignatureDistance(targetChunk.signature, signature, true);
16320
- if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
16321
- if (distance === 1) {
16390
+ function mergeChunks(chunkPartition, minChunkSize) {
16391
+ for (const allowArbitraryMerges of [false, true]) {
16392
+ for (const mergedChunk of chunkPartition.small) {
16393
+ let closestChunk = null;
16394
+ let closestChunkDistance = Infinity;
16395
+ const { modules, pure, size } = mergedChunk;
16396
+ for (const targetChunk of concatLazy([chunkPartition.small, chunkPartition.big])) {
16397
+ if (mergedChunk === targetChunk)
16398
+ continue;
16399
+ // If both chunks are small, we also allow for unrelated merges during
16400
+ // the first pass
16401
+ const onlySubsetMerge = !allowArbitraryMerges && targetChunk.size >= minChunkSize;
16402
+ const distance = getChunkEntryDistance(mergedChunk, targetChunk, onlySubsetMerge);
16403
+ if (distance < closestChunkDistance &&
16404
+ isValidMerge(mergedChunk, targetChunk, onlySubsetMerge)) {
16322
16405
  closestChunk = targetChunk;
16323
- break;
16406
+ closestChunkDistance = distance;
16324
16407
  }
16325
- closestChunk = targetChunk;
16326
- closestChunkDistance = distance;
16327
- }
16328
- }
16329
- if (closestChunk) {
16330
- chunksToBeMerged.delete(mergedChunk);
16331
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16332
- closestChunk.modules.push(...modules);
16333
- closestChunk.size += size;
16334
- closestChunk.pure && (closestChunk.pure = pure);
16335
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16336
- const { dependencies, dependentChunks } = closestChunk;
16337
- for (const dependency of mergedChunk.dependencies) {
16338
- dependencies.add(dependency);
16339
16408
  }
16340
- for (const dependentChunk of mergedChunk.dependentChunks) {
16341
- dependentChunks.add(dependentChunk);
16342
- dependentChunk.dependencies.delete(mergedChunk);
16343
- dependentChunk.dependencies.add(closestChunk);
16409
+ if (closestChunk) {
16410
+ chunkPartition.small.delete(mergedChunk);
16411
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16412
+ closestChunk.modules.push(...modules);
16413
+ closestChunk.size += size;
16414
+ closestChunk.pure && (closestChunk.pure = pure);
16415
+ const { correlatedSideEffects, dependencies, dependentChunks, dependentEntries, sideEffects } = closestChunk;
16416
+ for (const sideEffect of correlatedSideEffects) {
16417
+ if (!mergedChunk.correlatedSideEffects.has(sideEffect)) {
16418
+ correlatedSideEffects.delete(sideEffect);
16419
+ }
16420
+ }
16421
+ for (const entry of mergedChunk.dependentEntries) {
16422
+ dependentEntries.add(entry);
16423
+ }
16424
+ for (const sideEffect of mergedChunk.sideEffects) {
16425
+ sideEffects.add(sideEffect);
16426
+ }
16427
+ for (const dependency of mergedChunk.dependencies) {
16428
+ dependencies.add(dependency);
16429
+ dependency.dependentChunks.delete(mergedChunk);
16430
+ dependency.dependentChunks.add(closestChunk);
16431
+ }
16432
+ for (const dependentChunk of mergedChunk.dependentChunks) {
16433
+ dependentChunks.add(dependentChunk);
16434
+ dependentChunk.dependencies.delete(mergedChunk);
16435
+ dependentChunk.dependencies.add(closestChunk);
16436
+ }
16437
+ dependencies.delete(closestChunk);
16438
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16344
16439
  }
16345
- dependencies.delete(closestChunk);
16346
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16347
16440
  }
16348
16441
  }
16349
16442
  }
16350
16443
  // Merging will not produce cycles if none of the direct non-merged dependencies
16351
16444
  // of a chunk have the other chunk as a transitive dependency
16352
- function isValidMerge(mergedChunk, targetChunk) {
16353
- return !(hasTransitiveDependency(mergedChunk, targetChunk) ||
16354
- hasTransitiveDependency(targetChunk, mergedChunk));
16355
- }
16356
- function hasTransitiveDependency(dependentChunk, dependencyChunk) {
16445
+ function isValidMerge(mergedChunk, targetChunk, onlySubsetMerge) {
16446
+ return !(hasTransitiveDependencyOrNonCorrelatedSideEffect(mergedChunk, targetChunk, true) ||
16447
+ hasTransitiveDependencyOrNonCorrelatedSideEffect(targetChunk, mergedChunk, !onlySubsetMerge));
16448
+ }
16449
+ function hasTransitiveDependencyOrNonCorrelatedSideEffect(dependentChunk, dependencyChunk, checkSideEffects) {
16450
+ const { correlatedSideEffects } = dependencyChunk;
16451
+ if (checkSideEffects) {
16452
+ for (const sideEffect of dependentChunk.sideEffects) {
16453
+ if (!correlatedSideEffects.has(sideEffect)) {
16454
+ return true;
16455
+ }
16456
+ }
16457
+ }
16357
16458
  const chunksToCheck = new Set(dependentChunk.dependencies);
16358
- for (const { dependencies } of chunksToCheck) {
16459
+ for (const { dependencies, sideEffects } of chunksToCheck) {
16359
16460
  for (const dependency of dependencies) {
16360
16461
  if (dependency === dependencyChunk) {
16361
16462
  return true;
16362
16463
  }
16363
16464
  chunksToCheck.add(dependency);
16364
16465
  }
16466
+ if (checkSideEffects) {
16467
+ for (const sideEffect of sideEffects) {
16468
+ if (!correlatedSideEffects.has(sideEffect)) {
16469
+ return true;
16470
+ }
16471
+ }
16472
+ }
16365
16473
  }
16366
16474
  return false;
16367
16475
  }
16368
16476
  function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16369
- const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16370
- return chunk.pure ? subPartition.pure : subPartition.sideEffect;
16477
+ return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16371
16478
  }
16372
- function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16479
+ function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentEntries: targetEntries }, enforceSubest) {
16373
16480
  let distance = 0;
16374
- const { length } = sourceSignature;
16375
- for (let index = 0; index < length; index++) {
16376
- const sourceValue = sourceSignature.charCodeAt(index);
16377
- if (sourceValue !== targetSignature.charCodeAt(index)) {
16378
- if (enforceSubset && sourceValue === CHAR_CODE_DEPENDENT) {
16481
+ for (const entryIndex of targetEntries) {
16482
+ if (!sourceEntries.has(entryIndex)) {
16483
+ distance++;
16484
+ }
16485
+ }
16486
+ for (const entryIndex of sourceEntries) {
16487
+ if (!targetEntries.has(entryIndex)) {
16488
+ if (enforceSubest) {
16379
16489
  return Infinity;
16380
16490
  }
16381
16491
  distance++;
@@ -16383,18 +16493,6 @@ function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16383
16493
  }
16384
16494
  return distance;
16385
16495
  }
16386
- function mergeSignatures(sourceSignature, targetSignature) {
16387
- let signature = '';
16388
- const { length } = sourceSignature;
16389
- for (let index = 0; index < length; index++) {
16390
- signature +=
16391
- sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
16392
- targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
16393
- ? CHAR_DEPENDENT
16394
- : CHAR_INDEPENDENT;
16395
- }
16396
- return signature;
16397
- }
16398
16496
 
16399
16497
  // ported from https://github.com/substack/node-commondir
16400
16498
  function commondir(files) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
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 v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
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$1 = "3.14.0";
34
+ var version$1 = "3.15.1-0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -5544,7 +5544,8 @@ function createHasEffectsContext() {
5544
5544
  breaks: false,
5545
5545
  continues: false,
5546
5546
  labels: new Set(),
5547
- returnYield: false
5547
+ returnYield: false,
5548
+ this: false
5548
5549
  },
5549
5550
  includedLabels: new Set(),
5550
5551
  instantiated: new DiscriminatedPathTracker(),
@@ -9006,7 +9007,8 @@ class ArrowFunctionExpression extends FunctionBase {
9006
9007
  breaks: false,
9007
9008
  continues: false,
9008
9009
  labels: new Set(),
9009
- returnYield: true
9010
+ returnYield: true,
9011
+ this: false
9010
9012
  };
9011
9013
  if (this.body.hasEffects(context))
9012
9014
  return true;
@@ -9276,11 +9278,14 @@ class ThisVariable extends LocalVariable {
9276
9278
  }
9277
9279
  }
9278
9280
  hasEffectsOnInteractionAtPath(path, interaction, context) {
9279
- return (this.getInit(context).hasEffectsOnInteractionAtPath(path, interaction, context) ||
9280
- super.hasEffectsOnInteractionAtPath(path, interaction, context));
9281
- }
9282
- getInit(context) {
9283
- return context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION;
9281
+ const replacedVariableInit = context.replacedVariableInits.get(this);
9282
+ if (replacedVariableInit) {
9283
+ return (replacedVariableInit.hasEffectsOnInteractionAtPath(path, interaction, context) ||
9284
+ // If the surrounding function is included, all mutations of "this" must
9285
+ // be counted as side effects, which is what this second line does.
9286
+ (!context.ignore.this && super.hasEffectsOnInteractionAtPath(path, interaction, context)));
9287
+ }
9288
+ return UNKNOWN_EXPRESSION.hasEffectsOnInteractionAtPath(path, interaction, context);
9284
9289
  }
9285
9290
  }
9286
9291
 
@@ -9312,6 +9317,10 @@ class FunctionNode extends FunctionBase {
9312
9317
  }
9313
9318
  createScope(parentScope) {
9314
9319
  this.scope = new FunctionScope(parentScope, this.context);
9320
+ this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
9321
+ // This makes sure that all deoptimizations of "this" are applied to the
9322
+ // constructed entity.
9323
+ this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
9315
9324
  }
9316
9325
  deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
9317
9326
  super.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
@@ -9329,15 +9338,14 @@ class FunctionNode extends FunctionBase {
9329
9338
  return true;
9330
9339
  if (interaction.type === INTERACTION_CALLED) {
9331
9340
  const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
9332
- context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew
9333
- ? new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE)
9334
- : UNKNOWN_EXPRESSION);
9341
+ context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew ? this.constructedEntity : UNKNOWN_EXPRESSION);
9335
9342
  const { brokenFlow, ignore, replacedVariableInits } = context;
9336
9343
  context.ignore = {
9337
9344
  breaks: false,
9338
9345
  continues: false,
9339
9346
  labels: new Set(),
9340
- returnYield: true
9347
+ returnYield: true,
9348
+ this: interaction.withNew
9341
9349
  };
9342
9350
  if (this.body.hasEffects(context))
9343
9351
  return true;
@@ -16630,7 +16638,7 @@ function analyzeModuleGraph(entries) {
16630
16638
  }
16631
16639
  }
16632
16640
  return {
16633
- allEntries,
16641
+ allEntries: [...allEntries],
16634
16642
  dependentEntriesByModule,
16635
16643
  dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
16636
16644
  };
@@ -16704,7 +16712,7 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
16704
16712
  alias: null,
16705
16713
  modules
16706
16714
  }))
16707
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
16715
+ : getOptimizedChunks(chunkModulesBySignature, allEntries.length, minChunkSize).map(({ modules }) => ({
16708
16716
  alias: null,
16709
16717
  modules
16710
16718
  }));
@@ -16728,49 +16736,109 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
16728
16736
  }
16729
16737
  /**
16730
16738
  * This function tries to get rid of small chunks by merging them with other
16731
- * chunks. In order to merge chunks, one must obey the following rule:
16732
- * - When merging several chunks, at most one of the chunks can have side
16733
- * effects
16734
- * - When one of the chunks has side effects, the entry points depending on that
16735
- * chunk need to be a super set of the entry points depending on the other
16736
- * chunks
16737
- * - Pure chunks can always be merged
16738
- * - We use the entry point dependence signature to calculate "chunk distance",
16739
- * i.e. how likely it is that two chunks are loaded together
16739
+ * chunks.
16740
+ *
16741
+ * We can only merge chunks safely if after the merge, loading any entry point
16742
+ * in any allowed order will not trigger side effects that should not have been
16743
+ * triggered. While side effects are usually things like global function calls,
16744
+ * global variable mutations or potentially thrown errors, details do not
16745
+ * matter here, and we just discern chunks without side effects (pure chunks)
16746
+ * from other chunks.
16747
+ *
16748
+ * As a first step, we assign each pre-generated chunk with side effects a
16749
+ * label. I.e. we have side effect "A" if the non-pure chunk "A" is loaded.
16750
+ *
16751
+ * Now to determine the side effects of loading a chunk, one also has to take
16752
+ * the side effects of its dependencies into account. So if A depends on B
16753
+ * (A -> B) and both have side effects, loading A triggers effects AB.
16754
+ *
16755
+ * Now from the previous step we know that each chunk is uniquely determine by
16756
+ * the entry points that depend on it and cause it to load, which we will call
16757
+ * its dependent entry points.
16758
+ *
16759
+ * E.g. if X -> A and Y -> A, then the dependent entry points of A are XY.
16760
+ * Starting from that idea, we can determine a set of chunks—and thus a set
16761
+ * of side effects—that must have been triggered if a certain chunk has been
16762
+ * loaded. Basically, it is the intersection of all chunks loaded by the
16763
+ * dependent entry points of a given chunk. We call the corresponding side
16764
+ * effects the correlated side effects of that chunk.
16765
+ *
16766
+ * Example:
16767
+ * X -> ABC, Y -> ADE, A-> F, B -> D
16768
+ * Then taking dependencies into account, X -> ABCDF, Y -> ADEF
16769
+ * The intersection is ADF. So we know that when A is loaded, D and F must also
16770
+ * be in memory even though neither D nor A is a dependency of the other.
16771
+ * If all have side effects, we call ADF the correlated side effects of A. The
16772
+ * correlated side effects need to remain constant when merging chunks.
16773
+ *
16774
+ * In contrast, we have the dependency side effects of A, which represents
16775
+ * the side effects we trigger if we directly load A. In this example, the
16776
+ * dependency side effects are AF.
16777
+ * For entry chunks, dependency and correlated side effects are the same.
16778
+ *
16779
+ * With these concepts, merging chunks is allowed if the correlated side effects
16780
+ * of each entry do not change. Thus, we are allowed to merge two chunks if
16781
+ * a) the dependency side effects of each chunk are a subset of the correlated
16782
+ * side effects of the other chunk, so no additional side effects are
16783
+ * triggered for any entry, or
16784
+ * b) The signature of chunk A is a subset of the signature of chunk B while the
16785
+ * dependency side effects of A are a subset of the correlated side effects
16786
+ * of B. Because in that scenario, whenever A is loaded, B is loaded as well.
16787
+ * But there are cases when B is loaded where A is not loaded. So if we merge
16788
+ * the chunks, all dependency side effects of A will be added to the
16789
+ * correlated side effects of B, and as the latter is not allowed to change,
16790
+ * the former need to be a subset of the latter.
16791
+ *
16792
+ * Another consideration when merging small chunks into other chunks is to avoid
16793
+ * that too much additional code is loaded. This is achieved when the dependent
16794
+ * entries of the small chunk are a subset of the dependent entries of the other
16795
+ * chunk. Because then when the small chunk is loaded, the other chunk was
16796
+ * loaded/in memory anyway, so at most when the other chunk is loaded, the
16797
+ * additional size of the small chunk is loaded unnecessarily.
16798
+ *
16799
+ * So the algorithm performs merges in two passes:
16800
+ * 1. First we try to merge small chunks A only into other chunks B if the
16801
+ * dependent entries of A are a subset of the dependent entries of B and the
16802
+ * dependency side effects of A are a subset of the correlated side effects
16803
+ * of B.
16804
+ * 2. Only then for all remaining small chunks, we look for arbitrary merges
16805
+ * following the above rules (a) and (b), starting with the smallest chunks
16806
+ * to look for possible merge targets.
16740
16807
  */
16741
- function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16808
+ function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
16742
16809
  timeStart('optimize chunks', 3);
16743
- const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
16744
- if (chunkPartition.small.sideEffect.size > 0) {
16745
- mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
16746
- }
16747
- if (chunkPartition.small.pure.size > 0) {
16748
- mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
16810
+ const chunkPartition = getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize);
16811
+ if (chunkPartition.small.size > 0) {
16812
+ mergeChunks(chunkPartition, minChunkSize);
16749
16813
  }
16750
16814
  timeEnd('optimize chunks', 3);
16751
- return [
16752
- ...chunkPartition.small.sideEffect,
16753
- ...chunkPartition.small.pure,
16754
- ...chunkPartition.big.sideEffect,
16755
- ...chunkPartition.big.pure
16756
- ];
16815
+ return [...chunkPartition.small, ...chunkPartition.big];
16757
16816
  }
16758
16817
  const CHAR_DEPENDENT = 'X';
16759
16818
  const CHAR_INDEPENDENT = '_';
16760
- const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
16761
- function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16762
- const smallPureChunks = [];
16763
- const bigPureChunks = [];
16764
- const smallSideEffectChunks = [];
16765
- const bigSideEffectChunks = [];
16819
+ function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
16820
+ const smallChunks = [];
16821
+ const bigChunks = [];
16766
16822
  const chunkByModule = new Map();
16823
+ const sideEffectsByEntry = [];
16824
+ for (let index = 0; index < numberOfEntries; index++) {
16825
+ sideEffectsByEntry.push(new Set());
16826
+ }
16767
16827
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16828
+ const dependentEntries = new Set();
16829
+ for (let position = 0; position < numberOfEntries; position++) {
16830
+ if (signature[position] === CHAR_DEPENDENT) {
16831
+ dependentEntries.add(position);
16832
+ }
16833
+ }
16768
16834
  const chunkDescription = {
16835
+ correlatedSideEffects: new Set(),
16769
16836
  dependencies: new Set(),
16770
16837
  dependentChunks: new Set(),
16838
+ dependentEntries,
16771
16839
  modules,
16772
16840
  pure: true,
16773
- signature,
16841
+ sideEffects: new Set(),
16774
16842
  size: 0
16775
16843
  };
16776
16844
  let size = 0;
@@ -16784,25 +16852,27 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16784
16852
  }
16785
16853
  chunkDescription.pure = pure;
16786
16854
  chunkDescription.size = size;
16787
- (size < minChunkSize
16788
- ? pure
16789
- ? smallPureChunks
16790
- : smallSideEffectChunks
16791
- : pure
16792
- ? bigPureChunks
16793
- : bigSideEffectChunks).push(chunkDescription);
16794
- }
16795
- sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
16855
+ if (!pure) {
16856
+ for (const entryIndex of dependentEntries) {
16857
+ sideEffectsByEntry[entryIndex].add(signature);
16858
+ }
16859
+ // In the beginning, each chunk is only its own side effect. After
16860
+ // merging, additional side effects can accumulate.
16861
+ chunkDescription.sideEffects.add(signature);
16862
+ }
16863
+ (size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
16864
+ }
16865
+ sortChunksAndAddDependenciesAndEffects([bigChunks, smallChunks], chunkByModule, sideEffectsByEntry);
16796
16866
  return {
16797
- big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
16798
- small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
16867
+ big: new Set(bigChunks),
16868
+ small: new Set(smallChunks)
16799
16869
  };
16800
16870
  }
16801
- function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16871
+ function sortChunksAndAddDependenciesAndEffects(chunkLists, chunkByModule, sideEffectsByEntry) {
16802
16872
  for (const chunks of chunkLists) {
16803
- chunks.sort(compareChunks);
16873
+ chunks.sort(compareChunkSize);
16804
16874
  for (const chunk of chunks) {
16805
- const { dependencies, modules } = chunk;
16875
+ const { dependencies, modules, correlatedSideEffects, dependentEntries } = chunk;
16806
16876
  for (const module of modules) {
16807
16877
  for (const dependency of module.getDependenciesToBeIncluded()) {
16808
16878
  const dependencyChunk = chunkByModule.get(dependency);
@@ -16812,89 +16882,129 @@ function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16812
16882
  }
16813
16883
  }
16814
16884
  }
16885
+ let firstEntry = true;
16886
+ // Correlated side effects is the intersection of all entry side effects
16887
+ for (const entryIndex of dependentEntries) {
16888
+ const entryEffects = sideEffectsByEntry[entryIndex];
16889
+ if (firstEntry) {
16890
+ for (const sideEffect of entryEffects) {
16891
+ correlatedSideEffects.add(sideEffect);
16892
+ }
16893
+ firstEntry = false;
16894
+ }
16895
+ else {
16896
+ for (const sideEffect of correlatedSideEffects) {
16897
+ if (!entryEffects.has(sideEffect)) {
16898
+ correlatedSideEffects.delete(sideEffect);
16899
+ }
16900
+ }
16901
+ }
16902
+ }
16815
16903
  }
16816
16904
  }
16817
16905
  }
16818
- function compareChunks({ size: sizeA }, { size: sizeB }) {
16906
+ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
16819
16907
  return sizeA - sizeB;
16820
16908
  }
16821
- function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
16822
- for (const mergedChunk of chunksToBeMerged) {
16823
- let closestChunk = null;
16824
- let closestChunkDistance = Infinity;
16825
- const { signature, modules, pure, size } = mergedChunk;
16826
- for (const targetChunk of concatLazy(targetChunks)) {
16827
- if (mergedChunk === targetChunk)
16828
- continue;
16829
- // Possible improvement:
16830
- // For dynamic entries depending on a pure chunk, it is safe to merge that
16831
- // chunk into the chunk doing the dynamic import (i.e. into an "already
16832
- // loaded chunk") even if it is not pure.
16833
- // One way of handling this could be to add all "already loaded entries"
16834
- // of the dynamic importers into the signature as well. That could also
16835
- // change the way we do code-splitting for already loaded entries.
16836
- const distance = pure
16837
- ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16838
- : getSignatureDistance(targetChunk.signature, signature, true);
16839
- if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
16840
- if (distance === 1) {
16909
+ function mergeChunks(chunkPartition, minChunkSize) {
16910
+ for (const allowArbitraryMerges of [false, true]) {
16911
+ for (const mergedChunk of chunkPartition.small) {
16912
+ let closestChunk = null;
16913
+ let closestChunkDistance = Infinity;
16914
+ const { modules, pure, size } = mergedChunk;
16915
+ for (const targetChunk of concatLazy([chunkPartition.small, chunkPartition.big])) {
16916
+ if (mergedChunk === targetChunk)
16917
+ continue;
16918
+ // If both chunks are small, we also allow for unrelated merges during
16919
+ // the first pass
16920
+ const onlySubsetMerge = !allowArbitraryMerges && targetChunk.size >= minChunkSize;
16921
+ const distance = getChunkEntryDistance(mergedChunk, targetChunk, onlySubsetMerge);
16922
+ if (distance < closestChunkDistance &&
16923
+ isValidMerge(mergedChunk, targetChunk, onlySubsetMerge)) {
16841
16924
  closestChunk = targetChunk;
16842
- break;
16925
+ closestChunkDistance = distance;
16843
16926
  }
16844
- closestChunk = targetChunk;
16845
- closestChunkDistance = distance;
16846
- }
16847
- }
16848
- if (closestChunk) {
16849
- chunksToBeMerged.delete(mergedChunk);
16850
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16851
- closestChunk.modules.push(...modules);
16852
- closestChunk.size += size;
16853
- closestChunk.pure && (closestChunk.pure = pure);
16854
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16855
- const { dependencies, dependentChunks } = closestChunk;
16856
- for (const dependency of mergedChunk.dependencies) {
16857
- dependencies.add(dependency);
16858
16927
  }
16859
- for (const dependentChunk of mergedChunk.dependentChunks) {
16860
- dependentChunks.add(dependentChunk);
16861
- dependentChunk.dependencies.delete(mergedChunk);
16862
- dependentChunk.dependencies.add(closestChunk);
16928
+ if (closestChunk) {
16929
+ chunkPartition.small.delete(mergedChunk);
16930
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16931
+ closestChunk.modules.push(...modules);
16932
+ closestChunk.size += size;
16933
+ closestChunk.pure && (closestChunk.pure = pure);
16934
+ const { correlatedSideEffects, dependencies, dependentChunks, dependentEntries, sideEffects } = closestChunk;
16935
+ for (const sideEffect of correlatedSideEffects) {
16936
+ if (!mergedChunk.correlatedSideEffects.has(sideEffect)) {
16937
+ correlatedSideEffects.delete(sideEffect);
16938
+ }
16939
+ }
16940
+ for (const entry of mergedChunk.dependentEntries) {
16941
+ dependentEntries.add(entry);
16942
+ }
16943
+ for (const sideEffect of mergedChunk.sideEffects) {
16944
+ sideEffects.add(sideEffect);
16945
+ }
16946
+ for (const dependency of mergedChunk.dependencies) {
16947
+ dependencies.add(dependency);
16948
+ dependency.dependentChunks.delete(mergedChunk);
16949
+ dependency.dependentChunks.add(closestChunk);
16950
+ }
16951
+ for (const dependentChunk of mergedChunk.dependentChunks) {
16952
+ dependentChunks.add(dependentChunk);
16953
+ dependentChunk.dependencies.delete(mergedChunk);
16954
+ dependentChunk.dependencies.add(closestChunk);
16955
+ }
16956
+ dependencies.delete(closestChunk);
16957
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16863
16958
  }
16864
- dependencies.delete(closestChunk);
16865
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16866
16959
  }
16867
16960
  }
16868
16961
  }
16869
16962
  // Merging will not produce cycles if none of the direct non-merged dependencies
16870
16963
  // of a chunk have the other chunk as a transitive dependency
16871
- function isValidMerge(mergedChunk, targetChunk) {
16872
- return !(hasTransitiveDependency(mergedChunk, targetChunk) ||
16873
- hasTransitiveDependency(targetChunk, mergedChunk));
16874
- }
16875
- function hasTransitiveDependency(dependentChunk, dependencyChunk) {
16964
+ function isValidMerge(mergedChunk, targetChunk, onlySubsetMerge) {
16965
+ return !(hasTransitiveDependencyOrNonCorrelatedSideEffect(mergedChunk, targetChunk, true) ||
16966
+ hasTransitiveDependencyOrNonCorrelatedSideEffect(targetChunk, mergedChunk, !onlySubsetMerge));
16967
+ }
16968
+ function hasTransitiveDependencyOrNonCorrelatedSideEffect(dependentChunk, dependencyChunk, checkSideEffects) {
16969
+ const { correlatedSideEffects } = dependencyChunk;
16970
+ if (checkSideEffects) {
16971
+ for (const sideEffect of dependentChunk.sideEffects) {
16972
+ if (!correlatedSideEffects.has(sideEffect)) {
16973
+ return true;
16974
+ }
16975
+ }
16976
+ }
16876
16977
  const chunksToCheck = new Set(dependentChunk.dependencies);
16877
- for (const { dependencies } of chunksToCheck) {
16978
+ for (const { dependencies, sideEffects } of chunksToCheck) {
16878
16979
  for (const dependency of dependencies) {
16879
16980
  if (dependency === dependencyChunk) {
16880
16981
  return true;
16881
16982
  }
16882
16983
  chunksToCheck.add(dependency);
16883
16984
  }
16985
+ if (checkSideEffects) {
16986
+ for (const sideEffect of sideEffects) {
16987
+ if (!correlatedSideEffects.has(sideEffect)) {
16988
+ return true;
16989
+ }
16990
+ }
16991
+ }
16884
16992
  }
16885
16993
  return false;
16886
16994
  }
16887
16995
  function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16888
- const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16889
- return chunk.pure ? subPartition.pure : subPartition.sideEffect;
16996
+ return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16890
16997
  }
16891
- function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16998
+ function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentEntries: targetEntries }, enforceSubest) {
16892
16999
  let distance = 0;
16893
- const { length } = sourceSignature;
16894
- for (let index = 0; index < length; index++) {
16895
- const sourceValue = sourceSignature.charCodeAt(index);
16896
- if (sourceValue !== targetSignature.charCodeAt(index)) {
16897
- if (enforceSubset && sourceValue === CHAR_CODE_DEPENDENT) {
17000
+ for (const entryIndex of targetEntries) {
17001
+ if (!sourceEntries.has(entryIndex)) {
17002
+ distance++;
17003
+ }
17004
+ }
17005
+ for (const entryIndex of sourceEntries) {
17006
+ if (!targetEntries.has(entryIndex)) {
17007
+ if (enforceSubest) {
16898
17008
  return Infinity;
16899
17009
  }
16900
17010
  distance++;
@@ -16902,18 +17012,6 @@ function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16902
17012
  }
16903
17013
  return distance;
16904
17014
  }
16905
- function mergeSignatures(sourceSignature, targetSignature) {
16906
- let signature = '';
16907
- const { length } = sourceSignature;
16908
- for (let index = 0; index < length; index++) {
16909
- signature +=
16910
- sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
16911
- targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
16912
- ? CHAR_DEPENDENT
16913
- : CHAR_INDEPENDENT;
16914
- }
16915
- return signature;
16916
- }
16917
17015
 
16918
17016
  // ported from https://github.com/substack/node-commondir
16919
17017
  function commondir(files) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.14.0
4
- Sun, 05 Feb 2023 05:33:16 GMT - commit b8526485935ef21c65a5cd5474adbddf24ec7a32
3
+ Rollup.js v3.15.1-0
4
+ Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
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": "3.14.0",
3
+ "version": "3.15.1-0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -29,6 +29,7 @@
29
29
  "prepare": "husky install && node scripts/check-release.js || npm run build",
30
30
  "prepublishOnly": "node scripts/check-release.js",
31
31
  "release": "node scripts/release.js",
32
+ "release:docs": "git fetch --update-head-ok origin master:master && git branch --force documentation-published master && git push origin documentation-published",
32
33
  "test": "npm run build && npm run test:all",
33
34
  "test:update-snapshots": "node scripts/update-snapshots.js",
34
35
  "test:cjs": "npm run build:cjs && npm run test:only",