rollup 3.6.0 → 3.6.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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0
4
- Mon, 05 Dec 2022 11:26:13 GMT - commit de6675b4404a53f664769ba56bfdfdc56bf68531
3
+ Rollup.js v3.6.1-0
4
+ Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
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.6.0";
34
+ var version$1 = "3.6.1-0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -2828,7 +2828,7 @@ function formatAssertions(assertions, { getObject }) {
2828
2828
 
2829
2829
  function getOrCreate(map, key, init) {
2830
2830
  const existing = map.get(key);
2831
- if (existing) {
2831
+ if (existing !== undefined) {
2832
2832
  return existing;
2833
2833
  }
2834
2834
  const value = init();
@@ -11770,7 +11770,12 @@ class PrivateIdentifier extends NodeBase {
11770
11770
  class Program extends NodeBase {
11771
11771
  constructor() {
11772
11772
  super(...arguments);
11773
- this.hasCachedEffect = false;
11773
+ this.hasCachedEffect = null;
11774
+ }
11775
+ hasCachedEffects() {
11776
+ return this.hasCachedEffect === null
11777
+ ? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
11778
+ : this.hasCachedEffect;
11774
11779
  }
11775
11780
  hasEffects(context) {
11776
11781
  // We are caching here to later more efficiently identify side-effect-free modules
@@ -13630,8 +13635,7 @@ class Module {
13630
13635
  return [null];
13631
13636
  }
13632
13637
  hasEffects() {
13633
- return (this.info.moduleSideEffects === 'no-treeshake' ||
13634
- (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
13638
+ return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
13635
13639
  }
13636
13640
  include() {
13637
13641
  const context = createInclusionContext();
@@ -16230,18 +16234,138 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
16230
16234
  const QUERY_HASH_REGEX = /[#?]/;
16231
16235
  const resolveFileName = (dependency) => dependency.getFileName();
16232
16236
 
16237
+ const BYTE_UNITS = [
16238
+ 'B',
16239
+ 'kB',
16240
+ 'MB',
16241
+ 'GB',
16242
+ 'TB',
16243
+ 'PB',
16244
+ 'EB',
16245
+ 'ZB',
16246
+ 'YB',
16247
+ ];
16248
+
16249
+ const BIBYTE_UNITS = [
16250
+ 'B',
16251
+ 'kiB',
16252
+ 'MiB',
16253
+ 'GiB',
16254
+ 'TiB',
16255
+ 'PiB',
16256
+ 'EiB',
16257
+ 'ZiB',
16258
+ 'YiB',
16259
+ ];
16260
+
16261
+ const BIT_UNITS = [
16262
+ 'b',
16263
+ 'kbit',
16264
+ 'Mbit',
16265
+ 'Gbit',
16266
+ 'Tbit',
16267
+ 'Pbit',
16268
+ 'Ebit',
16269
+ 'Zbit',
16270
+ 'Ybit',
16271
+ ];
16272
+
16273
+ const BIBIT_UNITS = [
16274
+ 'b',
16275
+ 'kibit',
16276
+ 'Mibit',
16277
+ 'Gibit',
16278
+ 'Tibit',
16279
+ 'Pibit',
16280
+ 'Eibit',
16281
+ 'Zibit',
16282
+ 'Yibit',
16283
+ ];
16284
+
16285
+ /*
16286
+ Formats the given number using `Number#toLocaleString`.
16287
+ - If locale is a string, the value is expected to be a locale-key (for example: `de`).
16288
+ - If locale is true, the system default locale is used for translation.
16289
+ - If no value for locale is specified, the number is returned unmodified.
16290
+ */
16291
+ const toLocaleString = (number, locale, options) => {
16292
+ let result = number;
16293
+ if (typeof locale === 'string' || Array.isArray(locale)) {
16294
+ result = number.toLocaleString(locale, options);
16295
+ } else if (locale === true || options !== undefined) {
16296
+ result = number.toLocaleString(undefined, options);
16297
+ }
16298
+
16299
+ return result;
16300
+ };
16301
+
16302
+ function prettyBytes(number, options) {
16303
+ if (!Number.isFinite(number)) {
16304
+ throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
16305
+ }
16306
+
16307
+ options = {
16308
+ bits: false,
16309
+ binary: false,
16310
+ ...options,
16311
+ };
16312
+
16313
+ const UNITS = options.bits
16314
+ ? (options.binary ? BIBIT_UNITS : BIT_UNITS)
16315
+ : (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
16316
+
16317
+ if (options.signed && number === 0) {
16318
+ return ` 0 ${UNITS[0]}`;
16319
+ }
16320
+
16321
+ const isNegative = number < 0;
16322
+ const prefix = isNegative ? '-' : (options.signed ? '+' : '');
16323
+
16324
+ if (isNegative) {
16325
+ number = -number;
16326
+ }
16327
+
16328
+ let localeOptions;
16329
+
16330
+ if (options.minimumFractionDigits !== undefined) {
16331
+ localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
16332
+ }
16333
+
16334
+ if (options.maximumFractionDigits !== undefined) {
16335
+ localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
16336
+ }
16337
+
16338
+ if (number < 1) {
16339
+ const numberString = toLocaleString(number, options.locale, localeOptions);
16340
+ return prefix + numberString + ' ' + UNITS[0];
16341
+ }
16342
+
16343
+ const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
16344
+ number /= (options.binary ? 1024 : 1000) ** exponent;
16345
+
16346
+ if (!localeOptions) {
16347
+ number = number.toPrecision(3);
16348
+ }
16349
+
16350
+ const numberString = toLocaleString(Number(number), options.locale, localeOptions);
16351
+
16352
+ const unit = UNITS[exponent];
16353
+
16354
+ return prefix + numberString + ' ' + unit;
16355
+ }
16356
+
16233
16357
  /**
16234
16358
  * Concatenate a number of iterables to a new iterable without fully evaluating
16235
16359
  * their iterators. Useful when e.g. working with large sets or lists and when
16236
16360
  * there is a chance that the iterators will not be fully exhausted.
16237
16361
  */
16238
- function* concatLazy(...iterables) {
16362
+ function* concatLazy(iterables) {
16239
16363
  for (const iterable of iterables) {
16240
16364
  yield* iterable;
16241
16365
  }
16242
16366
  }
16243
16367
 
16244
- function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
16368
+ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16245
16369
  const chunkDefinitions = [];
16246
16370
  const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
16247
16371
  const manualChunkModulesByAlias = Object.create(null);
@@ -16251,53 +16375,19 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize
16251
16375
  for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
16252
16376
  chunkDefinitions.push({ alias, modules });
16253
16377
  }
16378
+ const alreadyLoadedModulesByDynamicEntry = getAlreadyLoadedModulesByDynamicEntry(entries);
16254
16379
  const assignedEntryPointsByModule = new Map();
16255
- const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
16256
- const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
16257
- const staticEntries = new Set(entryModules);
16258
- function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
16259
- const modulesToHandle = new Set([entry]);
16260
- for (const module of modulesToHandle) {
16261
- const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
16262
- if (dynamicDependentEntryPoints &&
16263
- areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
16264
- continue;
16265
- }
16266
- else {
16267
- assignedEntryPoints.add(entry);
16268
- }
16269
- for (const dependency of module.getDependenciesToBeIncluded()) {
16270
- if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
16271
- modulesToHandle.add(dependency);
16272
- }
16273
- }
16274
- }
16275
- }
16276
- function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
16277
- const entriesToCheck = new Set(entryPoints);
16278
- for (const entry of entriesToCheck) {
16279
- if (!containedIn.has(entry)) {
16280
- if (staticEntries.has(entry))
16281
- return false;
16282
- const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
16283
- for (const dependentEntry of dynamicallyDependentEntryPoints) {
16284
- entriesToCheck.add(dependentEntry);
16285
- }
16286
- }
16287
- }
16288
- return true;
16289
- }
16290
- for (const entry of entryModules) {
16380
+ for (const entry of entries) {
16291
16381
  if (!modulesInManualChunks.has(entry)) {
16292
- assignEntryToStaticDependencies(entry, null);
16382
+ assignEntryToStaticDependencies(entry, undefined, assignedEntryPointsByModule, modulesInManualChunks);
16293
16383
  }
16294
16384
  }
16295
- for (const entry of dynamicEntryModules) {
16385
+ for (const entry of alreadyLoadedModulesByDynamicEntry.keys()) {
16296
16386
  if (!modulesInManualChunks.has(entry)) {
16297
- assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
16387
+ assignEntryToStaticDependencies(entry, alreadyLoadedModulesByDynamicEntry.get(entry), assignedEntryPointsByModule, modulesInManualChunks);
16298
16388
  }
16299
16389
  }
16300
- chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
16390
+ chunkDefinitions.push(...createChunks([...entries, ...alreadyLoadedModulesByDynamicEntry.keys()], assignedEntryPointsByModule, minChunkSize));
16301
16391
  return chunkDefinitions;
16302
16392
  }
16303
16393
  function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
@@ -16312,47 +16402,87 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
16312
16402
  }
16313
16403
  }
16314
16404
  }
16315
- function analyzeModuleGraph(entryModules) {
16316
- const dynamicEntryModules = new Set();
16405
+ function getAlreadyLoadedModulesByDynamicEntry(entryModules) {
16406
+ const allModules = new Set(entryModules);
16317
16407
  const dependentEntryPointsByModule = new Map();
16408
+ const dynamicImportsByEntry = new Map();
16409
+ const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
16318
16410
  const entriesToHandle = new Set(entryModules);
16319
16411
  for (const currentEntry of entriesToHandle) {
16320
16412
  const modulesToHandle = new Set([currentEntry]);
16413
+ const dynamicImports = new Set();
16414
+ dynamicImportsByEntry.set(currentEntry, dynamicImports);
16321
16415
  for (const module of modulesToHandle) {
16322
16416
  getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry);
16323
16417
  for (const dependency of module.getDependenciesToBeIncluded()) {
16324
16418
  if (!(dependency instanceof ExternalModule)) {
16325
16419
  modulesToHandle.add(dependency);
16420
+ allModules.add(dependency);
16326
16421
  }
16327
16422
  }
16328
16423
  for (const { resolution } of module.dynamicImports) {
16329
16424
  if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
16330
- dynamicEntryModules.add(resolution);
16425
+ dynamicImports.add(resolution);
16426
+ getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, resolution, () => new Set()).add(currentEntry);
16331
16427
  entriesToHandle.add(resolution);
16428
+ allModules.add(resolution);
16332
16429
  }
16333
16430
  }
16334
16431
  for (const dependency of module.implicitlyLoadedBefore) {
16335
- dynamicEntryModules.add(dependency);
16432
+ dynamicImports.add(dependency);
16433
+ getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dependency, () => new Set()).add(currentEntry);
16336
16434
  entriesToHandle.add(dependency);
16435
+ allModules.add(dependency);
16337
16436
  }
16338
16437
  }
16339
16438
  }
16340
- return { dependentEntryPointsByModule, dynamicEntryModules };
16439
+ return buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry);
16341
16440
  }
16342
- function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules) {
16343
- const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
16344
- for (const dynamicEntry of dynamicEntryModules) {
16345
- const dynamicDependentEntryPoints = getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dynamicEntry, () => new Set());
16346
- for (const importer of [
16347
- ...dynamicEntry.includedDynamicImporters,
16348
- ...dynamicEntry.implicitlyLoadedAfter
16349
- ]) {
16350
- for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
16351
- dynamicDependentEntryPoints.add(entryPoint);
16441
+ function buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry) {
16442
+ const alreadyLoadedModulesByDynamicEntry = new Map();
16443
+ for (const dynamicEntry of dynamicallyDependentEntryPointsByDynamicEntry.keys()) {
16444
+ alreadyLoadedModulesByDynamicEntry.set(dynamicEntry, new Set());
16445
+ }
16446
+ for (const module of allModules) {
16447
+ const dependentEntryPoints = dependentEntryPointsByModule.get(module);
16448
+ for (const entry of dependentEntryPoints) {
16449
+ const dynamicEntriesToHandle = [...dynamicImportsByEntry.get(entry)];
16450
+ nextDynamicEntry: for (const dynamicEntry of dynamicEntriesToHandle) {
16451
+ const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
16452
+ if (alreadyLoadedModules.has(module)) {
16453
+ continue;
16454
+ }
16455
+ for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
16456
+ if (!(dependentEntryPoints.has(siblingDependentEntry) ||
16457
+ alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
16458
+ continue nextDynamicEntry;
16459
+ }
16460
+ }
16461
+ alreadyLoadedModules.add(module);
16462
+ dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
16463
+ }
16464
+ }
16465
+ }
16466
+ return alreadyLoadedModulesByDynamicEntry;
16467
+ }
16468
+ function assignEntryToStaticDependencies(entry, alreadyLoadedModules, assignedEntryPointsByModule, modulesInManualChunks) {
16469
+ const modulesToHandle = new Set([entry]);
16470
+ for (const module of modulesToHandle) {
16471
+ const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
16472
+ // If the module is "already loaded" for this dynamic entry, we do not need
16473
+ // to mark it for this dynamic entry
16474
+ if (alreadyLoadedModules?.has(module)) {
16475
+ continue;
16476
+ }
16477
+ else {
16478
+ assignedEntryPoints.add(entry);
16479
+ }
16480
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16481
+ if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
16482
+ modulesToHandle.add(dependency);
16352
16483
  }
16353
16484
  }
16354
16485
  }
16355
- return dynamicallyDependentEntryPointsByDynamicEntry;
16356
16486
  }
16357
16487
  function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
16358
16488
  const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
@@ -16361,43 +16491,49 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize)
16361
16491
  alias: null,
16362
16492
  modules
16363
16493
  }))
16364
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
16494
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
16495
+ alias: null,
16496
+ modules
16497
+ }));
16365
16498
  }
16499
+ /**
16500
+ * This function tries to get rid of small chunks by merging them with other
16501
+ * chunks. In order to merge chunks, one must obey the following rule:
16502
+ * - When merging several chunks, at most one of the chunks can have side
16503
+ * effects
16504
+ * - When one of the chunks has side effects, the entry points depending on that
16505
+ * chunk need to be a super set of the entry points depending on the other
16506
+ * chunks
16507
+ * - Pure chunks can always be merged
16508
+ * - We use the entry point dependence signature to calculate "chunk distance",
16509
+ * i.e. how likely it is that two chunks are loaded together
16510
+ */
16366
16511
  function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16367
16512
  timeStart('optimize chunks', 3);
16368
- const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
16369
- for (const sourceChunk of chunksToBeMerged) {
16370
- chunksToBeMerged.delete(sourceChunk);
16371
- let closestChunk = null;
16372
- let closestChunkDistance = Infinity;
16373
- const { signature, size, modules } = sourceChunk;
16374
- for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
16375
- const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
16376
- if (distance === 1) {
16377
- closestChunk = targetChunk;
16378
- break;
16379
- }
16380
- else if (distance < closestChunkDistance) {
16381
- closestChunk = targetChunk;
16382
- closestChunkDistance = distance;
16383
- }
16384
- }
16385
- if (closestChunk) {
16386
- closestChunk.modules.push(...modules);
16387
- if (chunksToBeMerged.has(closestChunk)) {
16388
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16389
- if ((closestChunk.size += size) > minChunkSize) {
16390
- chunksToBeMerged.delete(closestChunk);
16391
- unmergeableChunks.push(closestChunk);
16392
- }
16393
- }
16394
- }
16395
- else {
16396
- unmergeableChunks.push(sourceChunk);
16397
- }
16398
- }
16513
+ const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
16514
+ console.log(`Created ${chunkPartition.big.pure.size +
16515
+ chunkPartition.big.sideEffect.size +
16516
+ chunkPartition.small.pure.size +
16517
+ chunkPartition.small.sideEffect.size} chunks
16518
+ ----- pure side effects
16519
+ small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
16520
+ big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
16521
+ `);
16522
+ console.log(`Trying to find merge targets for ${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`);
16523
+ mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
16524
+ console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\n`);
16525
+ console.log(`Trying to find merge targets for ${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)}...`);
16526
+ mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
16527
+ console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\n`);
16399
16528
  timeEnd('optimize chunks', 3);
16400
- return unmergeableChunks;
16529
+ const result = [
16530
+ ...chunkPartition.small.sideEffect,
16531
+ ...chunkPartition.small.pure,
16532
+ ...chunkPartition.big.sideEffect,
16533
+ ...chunkPartition.big.pure
16534
+ ];
16535
+ console.log(`${result.length} chunks remaining.`);
16536
+ return result;
16401
16537
  }
16402
16538
  const CHAR_DEPENDENT = 'X';
16403
16539
  const CHAR_INDEPENDENT = '_';
@@ -16419,28 +16555,141 @@ function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints)
16419
16555
  }
16420
16556
  return chunkModules;
16421
16557
  }
16422
- function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
16423
- const chunksToBeMerged = new Set();
16424
- const unmergeableChunks = [];
16425
- const alias = null;
16558
+ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16559
+ const smallPureChunks = [];
16560
+ const bigPureChunks = [];
16561
+ const smallSideEffectChunks = [];
16562
+ const bigSideEffectChunks = [];
16563
+ const chunkByModule = new Map();
16426
16564
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16565
+ const chunkDescription = {
16566
+ dependencies: new Set(),
16567
+ modules,
16568
+ pure: true,
16569
+ signature,
16570
+ size: 0,
16571
+ transitiveDependencies: new Set(),
16572
+ transitiveDependentChunks: new Set()
16573
+ };
16427
16574
  let size = 0;
16428
- checkModules: {
16575
+ let pure = true;
16576
+ for (const module of modules) {
16577
+ chunkByModule.set(module, chunkDescription);
16578
+ pure && (pure = !module.hasEffects());
16579
+ size += module.magicString.toString().length;
16580
+ }
16581
+ chunkDescription.pure = pure;
16582
+ chunkDescription.size = size;
16583
+ (size < minChunkSize
16584
+ ? pure
16585
+ ? smallPureChunks
16586
+ : smallSideEffectChunks
16587
+ : pure
16588
+ ? bigPureChunks
16589
+ : bigSideEffectChunks).push(chunkDescription);
16590
+ }
16591
+ sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
16592
+ return {
16593
+ big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
16594
+ small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
16595
+ };
16596
+ }
16597
+ function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16598
+ for (const chunks of chunkLists) {
16599
+ chunks.sort(compareChunks);
16600
+ for (const chunk of chunks) {
16601
+ const { dependencies, modules, transitiveDependencies } = chunk;
16602
+ const transitiveDependencyModules = new Set();
16429
16603
  for (const module of modules) {
16430
- if (module.hasEffects()) {
16431
- break checkModules;
16604
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16605
+ const dependencyChunk = chunkByModule.get(dependency);
16606
+ if (dependencyChunk && dependencyChunk !== chunk) {
16607
+ dependencies.add(dependencyChunk);
16608
+ transitiveDependencyModules.add(dependency);
16609
+ }
16432
16610
  }
16433
- size += module.magicString.toString().length;
16434
- if (size > minChunkSize) {
16435
- break checkModules;
16611
+ }
16612
+ for (const module of transitiveDependencyModules) {
16613
+ const transitiveDependency = chunkByModule.get(module);
16614
+ if (transitiveDependency !== chunk) {
16615
+ transitiveDependencies.add(transitiveDependency);
16616
+ transitiveDependency.transitiveDependentChunks.add(chunk);
16617
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16618
+ if (!(dependency instanceof ExternalModule)) {
16619
+ transitiveDependencyModules.add(dependency);
16620
+ }
16621
+ }
16436
16622
  }
16437
16623
  }
16438
- chunksToBeMerged.add({ alias, modules, signature, size });
16439
- continue;
16440
16624
  }
16441
- unmergeableChunks.push({ alias, modules, signature, size: null });
16442
16625
  }
16443
- return { chunksToBeMerged, unmergeableChunks };
16626
+ }
16627
+ function compareChunks({ size: sizeA }, { size: sizeB }) {
16628
+ return sizeA - sizeB;
16629
+ }
16630
+ function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
16631
+ for (const mergedChunk of chunksToBeMerged) {
16632
+ let closestChunk = null;
16633
+ let closestChunkDistance = Infinity;
16634
+ const { signature, modules, pure, size } = mergedChunk;
16635
+ for (const targetChunk of concatLazy(targetChunks)) {
16636
+ if (mergedChunk === targetChunk)
16637
+ continue;
16638
+ const distance = pure
16639
+ ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16640
+ : getSignatureDistance(targetChunk.signature, signature, true);
16641
+ if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
16642
+ if (distance === 1) {
16643
+ closestChunk = targetChunk;
16644
+ break;
16645
+ }
16646
+ closestChunk = targetChunk;
16647
+ closestChunkDistance = distance;
16648
+ }
16649
+ }
16650
+ if (closestChunk) {
16651
+ chunksToBeMerged.delete(mergedChunk);
16652
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16653
+ closestChunk.modules.push(...modules);
16654
+ closestChunk.size += size;
16655
+ closestChunk.pure && (closestChunk.pure = pure);
16656
+ closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16657
+ const { dependencies, transitiveDependencies, transitiveDependentChunks } = closestChunk;
16658
+ for (const dependency of mergedChunk.dependencies) {
16659
+ dependencies.add(dependency);
16660
+ }
16661
+ for (const dependency of mergedChunk.transitiveDependencies) {
16662
+ transitiveDependencies.add(dependency);
16663
+ dependency.transitiveDependentChunks.delete(mergedChunk);
16664
+ dependency.transitiveDependentChunks.add(closestChunk);
16665
+ }
16666
+ for (const dependentChunk of mergedChunk.transitiveDependentChunks) {
16667
+ transitiveDependentChunks.add(dependentChunk);
16668
+ if (dependentChunk.dependencies.has(mergedChunk)) {
16669
+ dependentChunk.dependencies.delete(mergedChunk);
16670
+ dependentChunk.dependencies.add(closestChunk);
16671
+ }
16672
+ dependentChunk.transitiveDependencies.delete(mergedChunk);
16673
+ dependentChunk.transitiveDependencies.add(closestChunk);
16674
+ }
16675
+ dependencies.delete(closestChunk);
16676
+ transitiveDependencies.delete(closestChunk);
16677
+ transitiveDependentChunks.delete(closestChunk);
16678
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16679
+ }
16680
+ }
16681
+ }
16682
+ // If a module is a transitive but not a direct dependency of the other chunk,
16683
+ // merging is prohibited as that would create a new cyclic dependency.
16684
+ function isValidMerge(mergedChunk, targetChunk) {
16685
+ return ((!targetChunk.transitiveDependencies.has(mergedChunk) ||
16686
+ targetChunk.dependencies.has(mergedChunk)) &&
16687
+ (!mergedChunk.transitiveDependencies.has(targetChunk) ||
16688
+ mergedChunk.dependencies.has(targetChunk)));
16689
+ }
16690
+ function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16691
+ const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16692
+ return chunk.pure ? subPartition.pure : subPartition.sideEffect;
16444
16693
  }
16445
16694
  function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16446
16695
  let distance = 0;
@@ -25274,6 +25523,7 @@ exports.loadFsEvents = loadFsEvents;
25274
25523
  exports.mergeOptions = mergeOptions;
25275
25524
  exports.normalizePluginOption = normalizePluginOption;
25276
25525
  exports.picomatch = picomatch$1;
25526
+ exports.prettyBytes = prettyBytes;
25277
25527
  exports.printQuotedStringList = printQuotedStringList;
25278
25528
  exports.relativeId = relativeId;
25279
25529
  exports.rollup = rollup;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0
4
- Mon, 05 Dec 2022 11:26:13 GMT - commit de6675b4404a53f664769ba56bfdfdc56bf68531
3
+ Rollup.js v3.6.1-0
4
+ Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0
4
- Mon, 05 Dec 2022 11:26:13 GMT - commit de6675b4404a53f664769ba56bfdfdc56bf68531
3
+ Rollup.js v3.6.1-0
4
+ Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
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.6.0",
3
+ "version": "3.6.1-0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",