rollup 3.7.4 → 3.7.5-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/bin/rollup CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v3.7.4
6
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
5
+ Rollup.js v3.7.5-0
6
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
7
7
 
8
8
  https://github.com/rollup/rollup
9
9
 
@@ -1388,130 +1388,10 @@ function prettyMilliseconds(milliseconds, options = {}) {
1388
1388
  return options.colonNotation ? result.join('') : result.join(' ');
1389
1389
  }
1390
1390
 
1391
- const BYTE_UNITS = [
1392
- 'B',
1393
- 'kB',
1394
- 'MB',
1395
- 'GB',
1396
- 'TB',
1397
- 'PB',
1398
- 'EB',
1399
- 'ZB',
1400
- 'YB',
1401
- ];
1402
-
1403
- const BIBYTE_UNITS = [
1404
- 'B',
1405
- 'kiB',
1406
- 'MiB',
1407
- 'GiB',
1408
- 'TiB',
1409
- 'PiB',
1410
- 'EiB',
1411
- 'ZiB',
1412
- 'YiB',
1413
- ];
1414
-
1415
- const BIT_UNITS = [
1416
- 'b',
1417
- 'kbit',
1418
- 'Mbit',
1419
- 'Gbit',
1420
- 'Tbit',
1421
- 'Pbit',
1422
- 'Ebit',
1423
- 'Zbit',
1424
- 'Ybit',
1425
- ];
1426
-
1427
- const BIBIT_UNITS = [
1428
- 'b',
1429
- 'kibit',
1430
- 'Mibit',
1431
- 'Gibit',
1432
- 'Tibit',
1433
- 'Pibit',
1434
- 'Eibit',
1435
- 'Zibit',
1436
- 'Yibit',
1437
- ];
1438
-
1439
- /*
1440
- Formats the given number using `Number#toLocaleString`.
1441
- - If locale is a string, the value is expected to be a locale-key (for example: `de`).
1442
- - If locale is true, the system default locale is used for translation.
1443
- - If no value for locale is specified, the number is returned unmodified.
1444
- */
1445
- const toLocaleString = (number, locale, options) => {
1446
- let result = number;
1447
- if (typeof locale === 'string' || Array.isArray(locale)) {
1448
- result = number.toLocaleString(locale, options);
1449
- } else if (locale === true || options !== undefined) {
1450
- result = number.toLocaleString(undefined, options);
1451
- }
1452
-
1453
- return result;
1454
- };
1455
-
1456
- function prettyBytes(number, options) {
1457
- if (!Number.isFinite(number)) {
1458
- throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
1459
- }
1460
-
1461
- options = {
1462
- bits: false,
1463
- binary: false,
1464
- ...options,
1465
- };
1466
-
1467
- const UNITS = options.bits
1468
- ? (options.binary ? BIBIT_UNITS : BIT_UNITS)
1469
- : (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
1470
-
1471
- if (options.signed && number === 0) {
1472
- return ` 0 ${UNITS[0]}`;
1473
- }
1474
-
1475
- const isNegative = number < 0;
1476
- const prefix = isNegative ? '-' : (options.signed ? '+' : '');
1477
-
1478
- if (isNegative) {
1479
- number = -number;
1480
- }
1481
-
1482
- let localeOptions;
1483
-
1484
- if (options.minimumFractionDigits !== undefined) {
1485
- localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
1486
- }
1487
-
1488
- if (options.maximumFractionDigits !== undefined) {
1489
- localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
1490
- }
1491
-
1492
- if (number < 1) {
1493
- const numberString = toLocaleString(number, options.locale, localeOptions);
1494
- return prefix + numberString + ' ' + UNITS[0];
1495
- }
1496
-
1497
- const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
1498
- number /= (options.binary ? 1024 : 1000) ** exponent;
1499
-
1500
- if (!localeOptions) {
1501
- number = number.toPrecision(3);
1502
- }
1503
-
1504
- const numberString = toLocaleString(Number(number), options.locale, localeOptions);
1505
-
1506
- const unit = UNITS[exponent];
1507
-
1508
- return prefix + numberString + ' ' + unit;
1509
- }
1510
-
1511
1391
  function printTimings(timings) {
1512
1392
  for (const [label, [time, memory, total]] of Object.entries(timings)) {
1513
1393
  const appliedColor = label[0] === '#' ? (label[1] !== '#' ? rollup.underline : rollup.bold) : (text) => text;
1514
- const row = `${label}: ${time.toFixed(0)}ms, ${prettyBytes(memory)} / ${prettyBytes(total)}`;
1394
+ const row = `${label}: ${time.toFixed(0)}ms, ${rollup.prettyBytes(memory)} / ${rollup.prettyBytes(total)}`;
1515
1395
  console.info(appliedColor(row));
1516
1396
  }
1517
1397
  }
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { promises } from 'node:fs';
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version$1 = "3.7.4";
19
+ var version$1 = "3.7.5-0";
20
20
 
21
21
  var charToInteger = {};
22
22
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -11279,7 +11279,12 @@ class PrivateIdentifier extends NodeBase {
11279
11279
  class Program extends NodeBase {
11280
11280
  constructor() {
11281
11281
  super(...arguments);
11282
- this.hasCachedEffect = false;
11282
+ this.hasCachedEffect = null;
11283
+ }
11284
+ hasCachedEffects() {
11285
+ return this.hasCachedEffect === null
11286
+ ? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
11287
+ : this.hasCachedEffect;
11283
11288
  }
11284
11289
  hasEffects(context) {
11285
11290
  // We are caching here to later more efficiently identify side-effect-free modules
@@ -13139,8 +13144,7 @@ class Module {
13139
13144
  return [null];
13140
13145
  }
13141
13146
  hasEffects() {
13142
- return (this.info.moduleSideEffects === 'no-treeshake' ||
13143
- (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
13147
+ return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
13144
13148
  }
13145
13149
  include() {
13146
13150
  const context = createInclusionContext();
@@ -15739,12 +15743,132 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
15739
15743
  const QUERY_HASH_REGEX = /[#?]/;
15740
15744
  const resolveFileName = (dependency) => dependency.getFileName();
15741
15745
 
15746
+ const BYTE_UNITS = [
15747
+ 'B',
15748
+ 'kB',
15749
+ 'MB',
15750
+ 'GB',
15751
+ 'TB',
15752
+ 'PB',
15753
+ 'EB',
15754
+ 'ZB',
15755
+ 'YB',
15756
+ ];
15757
+
15758
+ const BIBYTE_UNITS = [
15759
+ 'B',
15760
+ 'kiB',
15761
+ 'MiB',
15762
+ 'GiB',
15763
+ 'TiB',
15764
+ 'PiB',
15765
+ 'EiB',
15766
+ 'ZiB',
15767
+ 'YiB',
15768
+ ];
15769
+
15770
+ const BIT_UNITS = [
15771
+ 'b',
15772
+ 'kbit',
15773
+ 'Mbit',
15774
+ 'Gbit',
15775
+ 'Tbit',
15776
+ 'Pbit',
15777
+ 'Ebit',
15778
+ 'Zbit',
15779
+ 'Ybit',
15780
+ ];
15781
+
15782
+ const BIBIT_UNITS = [
15783
+ 'b',
15784
+ 'kibit',
15785
+ 'Mibit',
15786
+ 'Gibit',
15787
+ 'Tibit',
15788
+ 'Pibit',
15789
+ 'Eibit',
15790
+ 'Zibit',
15791
+ 'Yibit',
15792
+ ];
15793
+
15794
+ /*
15795
+ Formats the given number using `Number#toLocaleString`.
15796
+ - If locale is a string, the value is expected to be a locale-key (for example: `de`).
15797
+ - If locale is true, the system default locale is used for translation.
15798
+ - If no value for locale is specified, the number is returned unmodified.
15799
+ */
15800
+ const toLocaleString = (number, locale, options) => {
15801
+ let result = number;
15802
+ if (typeof locale === 'string' || Array.isArray(locale)) {
15803
+ result = number.toLocaleString(locale, options);
15804
+ } else if (locale === true || options !== undefined) {
15805
+ result = number.toLocaleString(undefined, options);
15806
+ }
15807
+
15808
+ return result;
15809
+ };
15810
+
15811
+ function prettyBytes(number, options) {
15812
+ if (!Number.isFinite(number)) {
15813
+ throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
15814
+ }
15815
+
15816
+ options = {
15817
+ bits: false,
15818
+ binary: false,
15819
+ ...options,
15820
+ };
15821
+
15822
+ const UNITS = options.bits
15823
+ ? (options.binary ? BIBIT_UNITS : BIT_UNITS)
15824
+ : (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
15825
+
15826
+ if (options.signed && number === 0) {
15827
+ return ` 0 ${UNITS[0]}`;
15828
+ }
15829
+
15830
+ const isNegative = number < 0;
15831
+ const prefix = isNegative ? '-' : (options.signed ? '+' : '');
15832
+
15833
+ if (isNegative) {
15834
+ number = -number;
15835
+ }
15836
+
15837
+ let localeOptions;
15838
+
15839
+ if (options.minimumFractionDigits !== undefined) {
15840
+ localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
15841
+ }
15842
+
15843
+ if (options.maximumFractionDigits !== undefined) {
15844
+ localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
15845
+ }
15846
+
15847
+ if (number < 1) {
15848
+ const numberString = toLocaleString(number, options.locale, localeOptions);
15849
+ return prefix + numberString + ' ' + UNITS[0];
15850
+ }
15851
+
15852
+ const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
15853
+ number /= (options.binary ? 1024 : 1000) ** exponent;
15854
+
15855
+ if (!localeOptions) {
15856
+ number = number.toPrecision(3);
15857
+ }
15858
+
15859
+ const numberString = toLocaleString(Number(number), options.locale, localeOptions);
15860
+
15861
+ const unit = UNITS[exponent];
15862
+
15863
+ return prefix + numberString + ' ' + unit;
15864
+ }
15865
+
15742
15866
  /**
15743
15867
  * Concatenate a number of iterables to a new iterable without fully evaluating
15744
15868
  * their iterators. Useful when e.g. working with large sets or lists and when
15745
15869
  * there is a chance that the iterators will not be fully exhausted.
15746
15870
  */
15747
- function* concatLazy(...iterables) {
15871
+ function* concatLazy(iterables) {
15748
15872
  for (const iterable of iterables) {
15749
15873
  yield* iterable;
15750
15874
  }
@@ -15885,47 +16009,11 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
15885
16009
  alias: null,
15886
16010
  modules
15887
16011
  }))
15888
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
15889
- }
15890
- function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
15891
- timeStart('optimize chunks', 3);
15892
- const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
15893
- for (const sourceChunk of chunksToBeMerged) {
15894
- chunksToBeMerged.delete(sourceChunk);
15895
- let closestChunk = null;
15896
- let closestChunkDistance = Infinity;
15897
- const { signature, size, modules } = sourceChunk;
15898
- for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
15899
- const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
15900
- if (distance === 1) {
15901
- closestChunk = targetChunk;
15902
- break;
15903
- }
15904
- else if (distance < closestChunkDistance) {
15905
- closestChunk = targetChunk;
15906
- closestChunkDistance = distance;
15907
- }
15908
- }
15909
- if (closestChunk) {
15910
- closestChunk.modules.push(...modules);
15911
- if (chunksToBeMerged.has(closestChunk)) {
15912
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
15913
- if ((closestChunk.size += size) > minChunkSize) {
15914
- chunksToBeMerged.delete(closestChunk);
15915
- unmergeableChunks.push(closestChunk);
15916
- }
15917
- }
15918
- }
15919
- else {
15920
- unmergeableChunks.push(sourceChunk);
15921
- }
15922
- }
15923
- timeEnd('optimize chunks', 3);
15924
- return unmergeableChunks;
16012
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
16013
+ alias: null,
16014
+ modules
16015
+ }));
15925
16016
  }
15926
- const CHAR_DEPENDENT = 'X';
15927
- const CHAR_INDEPENDENT = '_';
15928
- const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
15929
16017
  function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
15930
16018
  const chunkModules = Object.create(null);
15931
16019
  for (const [module, assignedEntries] of assignedEntriesByModule) {
@@ -15943,28 +16031,236 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
15943
16031
  }
15944
16032
  return chunkModules;
15945
16033
  }
15946
- function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
15947
- const chunksToBeMerged = new Set();
15948
- const unmergeableChunks = [];
15949
- const alias = null;
16034
+ /**
16035
+ * This function tries to get rid of small chunks by merging them with other
16036
+ * chunks. In order to merge chunks, one must obey the following rule:
16037
+ * - When merging several chunks, at most one of the chunks can have side
16038
+ * effects
16039
+ * - When one of the chunks has side effects, the entry points depending on that
16040
+ * chunk need to be a super set of the entry points depending on the other
16041
+ * chunks
16042
+ * - Pure chunks can always be merged
16043
+ * - We use the entry point dependence signature to calculate "chunk distance",
16044
+ * i.e. how likely it is that two chunks are loaded together
16045
+ */
16046
+ function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16047
+ timeStart('optimize chunks', 3);
16048
+ const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
16049
+ console.log(`Created ${chunkPartition.big.pure.size +
16050
+ chunkPartition.big.sideEffect.size +
16051
+ chunkPartition.small.pure.size +
16052
+ chunkPartition.small.sideEffect.size} chunks
16053
+ ----- pure side effects
16054
+ small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
16055
+ big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
16056
+ Unoptimized chunks contain ${getNumberOfCycles(chunkPartition)} cycles.
16057
+ `);
16058
+ const chunkAliases = new Map();
16059
+ if (chunkPartition.small.sideEffect.size > 0) {
16060
+ console.log(`Trying to find merge targets for ${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`);
16061
+ mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition, chunkAliases);
16062
+ console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
16063
+ }
16064
+ if (chunkPartition.small.pure.size > 0) {
16065
+ console.log(`Trying to find merge targets for ${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)}...`);
16066
+ mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition, chunkAliases);
16067
+ console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
16068
+ }
16069
+ timeEnd('optimize chunks', 3);
16070
+ const result = [
16071
+ ...chunkPartition.small.sideEffect,
16072
+ ...chunkPartition.small.pure,
16073
+ ...chunkPartition.big.sideEffect,
16074
+ ...chunkPartition.big.pure
16075
+ ];
16076
+ console.log(`${result.length} chunks remaining.`);
16077
+ return result;
16078
+ }
16079
+ const CHAR_DEPENDENT = 'X';
16080
+ const CHAR_INDEPENDENT = '_';
16081
+ const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
16082
+ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16083
+ const smallPureChunks = [];
16084
+ const bigPureChunks = [];
16085
+ const smallSideEffectChunks = [];
16086
+ const bigSideEffectChunks = [];
16087
+ const chunkByModule = new Map();
15950
16088
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16089
+ const chunkDescription = {
16090
+ dependencies: new Set(),
16091
+ modules,
16092
+ pure: true,
16093
+ signature,
16094
+ size: 0,
16095
+ transitiveDependencies: new Set(),
16096
+ transitiveDependentChunks: new Set()
16097
+ };
15951
16098
  let size = 0;
15952
- checkModules: {
16099
+ let pure = true;
16100
+ for (const module of modules) {
16101
+ chunkByModule.set(module, chunkDescription);
16102
+ pure && (pure = !module.hasEffects());
16103
+ size += module.magicString.toString().length;
16104
+ }
16105
+ chunkDescription.pure = pure;
16106
+ chunkDescription.size = size;
16107
+ (size < minChunkSize
16108
+ ? pure
16109
+ ? smallPureChunks
16110
+ : smallSideEffectChunks
16111
+ : pure
16112
+ ? bigPureChunks
16113
+ : bigSideEffectChunks).push(chunkDescription);
16114
+ }
16115
+ sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
16116
+ return {
16117
+ big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
16118
+ small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
16119
+ };
16120
+ }
16121
+ function getNumberOfCycles(partition) {
16122
+ const parents = new Set();
16123
+ const analysedChunks = new Set();
16124
+ let cycles = 0;
16125
+ const analyseChunk = (chunk) => {
16126
+ for (const dependency of chunk.dependencies) {
16127
+ if (parents.has(dependency)) {
16128
+ if (!analysedChunks.has(dependency)) {
16129
+ cycles++;
16130
+ }
16131
+ continue;
16132
+ }
16133
+ parents.add(dependency);
16134
+ analyseChunk(dependency);
16135
+ }
16136
+ analysedChunks.add(chunk);
16137
+ };
16138
+ for (const chunk of [
16139
+ ...partition.big.pure,
16140
+ ...partition.big.sideEffect,
16141
+ ...partition.small.pure,
16142
+ ...partition.small.sideEffect
16143
+ ]) {
16144
+ if (!parents.has(chunk)) {
16145
+ parents.add(chunk);
16146
+ analyseChunk(chunk);
16147
+ }
16148
+ }
16149
+ return cycles;
16150
+ }
16151
+ function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16152
+ for (const chunks of chunkLists) {
16153
+ chunks.sort(compareChunks);
16154
+ for (const chunk of chunks) {
16155
+ const { dependencies, modules, transitiveDependencies } = chunk;
16156
+ const transitiveDependencyModules = new Set();
15953
16157
  for (const module of modules) {
15954
- if (module.hasEffects()) {
15955
- break checkModules;
16158
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16159
+ const dependencyChunk = chunkByModule.get(dependency);
16160
+ if (dependencyChunk && dependencyChunk !== chunk) {
16161
+ dependencies.add(dependencyChunk);
16162
+ transitiveDependencyModules.add(dependency);
16163
+ }
15956
16164
  }
15957
- size += module.magicString.toString().length;
15958
- if (size > minChunkSize) {
15959
- break checkModules;
16165
+ }
16166
+ for (const module of transitiveDependencyModules) {
16167
+ const transitiveDependency = chunkByModule.get(module);
16168
+ if (transitiveDependency !== chunk) {
16169
+ transitiveDependencies.add(transitiveDependency);
16170
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16171
+ if (!(dependency instanceof ExternalModule)) {
16172
+ transitiveDependencyModules.add(dependency);
16173
+ }
16174
+ }
15960
16175
  }
15961
16176
  }
15962
- chunksToBeMerged.add({ alias, modules, signature, size });
15963
- continue;
15964
16177
  }
15965
- unmergeableChunks.push({ alias, modules, signature, size: null });
15966
16178
  }
15967
- return { chunksToBeMerged, unmergeableChunks };
16179
+ }
16180
+ function compareChunks({ size: sizeA }, { size: sizeB }) {
16181
+ return sizeA - sizeB;
16182
+ }
16183
+ function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition, chunkAliases) {
16184
+ for (const mergedChunk of chunksToBeMerged) {
16185
+ replaceAliasedDependencies(mergedChunk, chunkAliases);
16186
+ let closestChunk = null;
16187
+ let closestChunkDistance = Infinity;
16188
+ const { signature, modules, pure, size } = mergedChunk;
16189
+ for (const targetChunk of concatLazy(targetChunks)) {
16190
+ if (mergedChunk === targetChunk)
16191
+ continue;
16192
+ const distance = pure
16193
+ ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16194
+ : getSignatureDistance(targetChunk.signature, signature, true);
16195
+ if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk, chunkAliases)) {
16196
+ if (distance === 1) {
16197
+ closestChunk = targetChunk;
16198
+ break;
16199
+ }
16200
+ closestChunk = targetChunk;
16201
+ closestChunkDistance = distance;
16202
+ }
16203
+ }
16204
+ if (closestChunk) {
16205
+ chunkAliases.set(mergedChunk, closestChunk);
16206
+ chunksToBeMerged.delete(mergedChunk);
16207
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16208
+ closestChunk.modules.push(...modules);
16209
+ closestChunk.size += size;
16210
+ closestChunk.pure && (closestChunk.pure = pure);
16211
+ closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16212
+ const { dependencies, transitiveDependencies } = closestChunk;
16213
+ for (const dependency of mergedChunk.dependencies) {
16214
+ dependencies.add(dependency);
16215
+ }
16216
+ for (const dependency of mergedChunk.transitiveDependencies) {
16217
+ transitiveDependencies.add(dependency);
16218
+ }
16219
+ dependencies.delete(closestChunk);
16220
+ dependencies.delete(mergedChunk);
16221
+ transitiveDependencies.delete(closestChunk);
16222
+ transitiveDependencies.delete(mergedChunk);
16223
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16224
+ }
16225
+ }
16226
+ }
16227
+ function replaceAliasedDependencies(chunk, chunkAliases) {
16228
+ for (const [alias, aliased] of chunkAliases) {
16229
+ if (chunk.dependencies.has(alias)) {
16230
+ chunk.dependencies.delete(alias);
16231
+ chunk.dependencies.add(aliased);
16232
+ }
16233
+ if (chunk.transitiveDependencies.has(alias)) {
16234
+ chunk.transitiveDependencies.delete(alias);
16235
+ chunk.transitiveDependencies.add(aliased);
16236
+ }
16237
+ }
16238
+ }
16239
+ // Merging will not produce cycles if
16240
+ // - no chunk is a transitive dependency of the other, or
16241
+ // - none of the direct non-merged dependencies of a chunk have the other
16242
+ // chunk as a transitive dependency
16243
+ function isValidMerge(mergedChunk, targetChunk, chunkAliases) {
16244
+ if (hasTransitiveDependency(mergedChunk, targetChunk)) {
16245
+ return false;
16246
+ }
16247
+ replaceAliasedDependencies(targetChunk, chunkAliases);
16248
+ return !hasTransitiveDependency(targetChunk, mergedChunk);
16249
+ }
16250
+ function hasTransitiveDependency(dependentChunk, dependencyChunk) {
16251
+ if (!dependentChunk.transitiveDependencies.has(dependencyChunk)) {
16252
+ return false;
16253
+ }
16254
+ for (const dependency of dependentChunk.dependencies) {
16255
+ if (dependency.transitiveDependencies.has(dependencyChunk)) {
16256
+ return true;
16257
+ }
16258
+ }
16259
+ return false;
16260
+ }
16261
+ function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16262
+ const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16263
+ return chunk.pure ? subPartition.pure : subPartition.sideEffect;
15968
16264
  }
15969
16265
  function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
15970
16266
  let distance = 0;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
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.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
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.7.4";
34
+ var version$1 = "3.7.5-0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -11794,7 +11794,12 @@ class PrivateIdentifier extends NodeBase {
11794
11794
  class Program extends NodeBase {
11795
11795
  constructor() {
11796
11796
  super(...arguments);
11797
- this.hasCachedEffect = false;
11797
+ this.hasCachedEffect = null;
11798
+ }
11799
+ hasCachedEffects() {
11800
+ return this.hasCachedEffect === null
11801
+ ? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
11802
+ : this.hasCachedEffect;
11798
11803
  }
11799
11804
  hasEffects(context) {
11800
11805
  // We are caching here to later more efficiently identify side-effect-free modules
@@ -13654,8 +13659,7 @@ class Module {
13654
13659
  return [null];
13655
13660
  }
13656
13661
  hasEffects() {
13657
- return (this.info.moduleSideEffects === 'no-treeshake' ||
13658
- (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
13662
+ return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
13659
13663
  }
13660
13664
  include() {
13661
13665
  const context = createInclusionContext();
@@ -16254,12 +16258,132 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
16254
16258
  const QUERY_HASH_REGEX = /[#?]/;
16255
16259
  const resolveFileName = (dependency) => dependency.getFileName();
16256
16260
 
16261
+ const BYTE_UNITS = [
16262
+ 'B',
16263
+ 'kB',
16264
+ 'MB',
16265
+ 'GB',
16266
+ 'TB',
16267
+ 'PB',
16268
+ 'EB',
16269
+ 'ZB',
16270
+ 'YB',
16271
+ ];
16272
+
16273
+ const BIBYTE_UNITS = [
16274
+ 'B',
16275
+ 'kiB',
16276
+ 'MiB',
16277
+ 'GiB',
16278
+ 'TiB',
16279
+ 'PiB',
16280
+ 'EiB',
16281
+ 'ZiB',
16282
+ 'YiB',
16283
+ ];
16284
+
16285
+ const BIT_UNITS = [
16286
+ 'b',
16287
+ 'kbit',
16288
+ 'Mbit',
16289
+ 'Gbit',
16290
+ 'Tbit',
16291
+ 'Pbit',
16292
+ 'Ebit',
16293
+ 'Zbit',
16294
+ 'Ybit',
16295
+ ];
16296
+
16297
+ const BIBIT_UNITS = [
16298
+ 'b',
16299
+ 'kibit',
16300
+ 'Mibit',
16301
+ 'Gibit',
16302
+ 'Tibit',
16303
+ 'Pibit',
16304
+ 'Eibit',
16305
+ 'Zibit',
16306
+ 'Yibit',
16307
+ ];
16308
+
16309
+ /*
16310
+ Formats the given number using `Number#toLocaleString`.
16311
+ - If locale is a string, the value is expected to be a locale-key (for example: `de`).
16312
+ - If locale is true, the system default locale is used for translation.
16313
+ - If no value for locale is specified, the number is returned unmodified.
16314
+ */
16315
+ const toLocaleString = (number, locale, options) => {
16316
+ let result = number;
16317
+ if (typeof locale === 'string' || Array.isArray(locale)) {
16318
+ result = number.toLocaleString(locale, options);
16319
+ } else if (locale === true || options !== undefined) {
16320
+ result = number.toLocaleString(undefined, options);
16321
+ }
16322
+
16323
+ return result;
16324
+ };
16325
+
16326
+ function prettyBytes(number, options) {
16327
+ if (!Number.isFinite(number)) {
16328
+ throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
16329
+ }
16330
+
16331
+ options = {
16332
+ bits: false,
16333
+ binary: false,
16334
+ ...options,
16335
+ };
16336
+
16337
+ const UNITS = options.bits
16338
+ ? (options.binary ? BIBIT_UNITS : BIT_UNITS)
16339
+ : (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
16340
+
16341
+ if (options.signed && number === 0) {
16342
+ return ` 0 ${UNITS[0]}`;
16343
+ }
16344
+
16345
+ const isNegative = number < 0;
16346
+ const prefix = isNegative ? '-' : (options.signed ? '+' : '');
16347
+
16348
+ if (isNegative) {
16349
+ number = -number;
16350
+ }
16351
+
16352
+ let localeOptions;
16353
+
16354
+ if (options.minimumFractionDigits !== undefined) {
16355
+ localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
16356
+ }
16357
+
16358
+ if (options.maximumFractionDigits !== undefined) {
16359
+ localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
16360
+ }
16361
+
16362
+ if (number < 1) {
16363
+ const numberString = toLocaleString(number, options.locale, localeOptions);
16364
+ return prefix + numberString + ' ' + UNITS[0];
16365
+ }
16366
+
16367
+ const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
16368
+ number /= (options.binary ? 1024 : 1000) ** exponent;
16369
+
16370
+ if (!localeOptions) {
16371
+ number = number.toPrecision(3);
16372
+ }
16373
+
16374
+ const numberString = toLocaleString(Number(number), options.locale, localeOptions);
16375
+
16376
+ const unit = UNITS[exponent];
16377
+
16378
+ return prefix + numberString + ' ' + unit;
16379
+ }
16380
+
16257
16381
  /**
16258
16382
  * Concatenate a number of iterables to a new iterable without fully evaluating
16259
16383
  * their iterators. Useful when e.g. working with large sets or lists and when
16260
16384
  * there is a chance that the iterators will not be fully exhausted.
16261
16385
  */
16262
- function* concatLazy(...iterables) {
16386
+ function* concatLazy(iterables) {
16263
16387
  for (const iterable of iterables) {
16264
16388
  yield* iterable;
16265
16389
  }
@@ -16400,47 +16524,11 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
16400
16524
  alias: null,
16401
16525
  modules
16402
16526
  }))
16403
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
16404
- }
16405
- function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16406
- timeStart('optimize chunks', 3);
16407
- const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
16408
- for (const sourceChunk of chunksToBeMerged) {
16409
- chunksToBeMerged.delete(sourceChunk);
16410
- let closestChunk = null;
16411
- let closestChunkDistance = Infinity;
16412
- const { signature, size, modules } = sourceChunk;
16413
- for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
16414
- const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
16415
- if (distance === 1) {
16416
- closestChunk = targetChunk;
16417
- break;
16418
- }
16419
- else if (distance < closestChunkDistance) {
16420
- closestChunk = targetChunk;
16421
- closestChunkDistance = distance;
16422
- }
16423
- }
16424
- if (closestChunk) {
16425
- closestChunk.modules.push(...modules);
16426
- if (chunksToBeMerged.has(closestChunk)) {
16427
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16428
- if ((closestChunk.size += size) > minChunkSize) {
16429
- chunksToBeMerged.delete(closestChunk);
16430
- unmergeableChunks.push(closestChunk);
16431
- }
16432
- }
16433
- }
16434
- else {
16435
- unmergeableChunks.push(sourceChunk);
16436
- }
16437
- }
16438
- timeEnd('optimize chunks', 3);
16439
- return unmergeableChunks;
16527
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
16528
+ alias: null,
16529
+ modules
16530
+ }));
16440
16531
  }
16441
- const CHAR_DEPENDENT = 'X';
16442
- const CHAR_INDEPENDENT = '_';
16443
- const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
16444
16532
  function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
16445
16533
  const chunkModules = Object.create(null);
16446
16534
  for (const [module, assignedEntries] of assignedEntriesByModule) {
@@ -16458,28 +16546,236 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
16458
16546
  }
16459
16547
  return chunkModules;
16460
16548
  }
16461
- function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
16462
- const chunksToBeMerged = new Set();
16463
- const unmergeableChunks = [];
16464
- const alias = null;
16549
+ /**
16550
+ * This function tries to get rid of small chunks by merging them with other
16551
+ * chunks. In order to merge chunks, one must obey the following rule:
16552
+ * - When merging several chunks, at most one of the chunks can have side
16553
+ * effects
16554
+ * - When one of the chunks has side effects, the entry points depending on that
16555
+ * chunk need to be a super set of the entry points depending on the other
16556
+ * chunks
16557
+ * - Pure chunks can always be merged
16558
+ * - We use the entry point dependence signature to calculate "chunk distance",
16559
+ * i.e. how likely it is that two chunks are loaded together
16560
+ */
16561
+ function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16562
+ timeStart('optimize chunks', 3);
16563
+ const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
16564
+ console.log(`Created ${chunkPartition.big.pure.size +
16565
+ chunkPartition.big.sideEffect.size +
16566
+ chunkPartition.small.pure.size +
16567
+ chunkPartition.small.sideEffect.size} chunks
16568
+ ----- pure side effects
16569
+ small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
16570
+ big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
16571
+ Unoptimized chunks contain ${getNumberOfCycles(chunkPartition)} cycles.
16572
+ `);
16573
+ const chunkAliases = new Map();
16574
+ if (chunkPartition.small.sideEffect.size > 0) {
16575
+ console.log(`Trying to find merge targets for ${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`);
16576
+ mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition, chunkAliases);
16577
+ console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
16578
+ }
16579
+ if (chunkPartition.small.pure.size > 0) {
16580
+ console.log(`Trying to find merge targets for ${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)}...`);
16581
+ mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition, chunkAliases);
16582
+ console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
16583
+ }
16584
+ timeEnd('optimize chunks', 3);
16585
+ const result = [
16586
+ ...chunkPartition.small.sideEffect,
16587
+ ...chunkPartition.small.pure,
16588
+ ...chunkPartition.big.sideEffect,
16589
+ ...chunkPartition.big.pure
16590
+ ];
16591
+ console.log(`${result.length} chunks remaining.`);
16592
+ return result;
16593
+ }
16594
+ const CHAR_DEPENDENT = 'X';
16595
+ const CHAR_INDEPENDENT = '_';
16596
+ const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
16597
+ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16598
+ const smallPureChunks = [];
16599
+ const bigPureChunks = [];
16600
+ const smallSideEffectChunks = [];
16601
+ const bigSideEffectChunks = [];
16602
+ const chunkByModule = new Map();
16465
16603
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16604
+ const chunkDescription = {
16605
+ dependencies: new Set(),
16606
+ modules,
16607
+ pure: true,
16608
+ signature,
16609
+ size: 0,
16610
+ transitiveDependencies: new Set(),
16611
+ transitiveDependentChunks: new Set()
16612
+ };
16466
16613
  let size = 0;
16467
- checkModules: {
16614
+ let pure = true;
16615
+ for (const module of modules) {
16616
+ chunkByModule.set(module, chunkDescription);
16617
+ pure && (pure = !module.hasEffects());
16618
+ size += module.magicString.toString().length;
16619
+ }
16620
+ chunkDescription.pure = pure;
16621
+ chunkDescription.size = size;
16622
+ (size < minChunkSize
16623
+ ? pure
16624
+ ? smallPureChunks
16625
+ : smallSideEffectChunks
16626
+ : pure
16627
+ ? bigPureChunks
16628
+ : bigSideEffectChunks).push(chunkDescription);
16629
+ }
16630
+ sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
16631
+ return {
16632
+ big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
16633
+ small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
16634
+ };
16635
+ }
16636
+ function getNumberOfCycles(partition) {
16637
+ const parents = new Set();
16638
+ const analysedChunks = new Set();
16639
+ let cycles = 0;
16640
+ const analyseChunk = (chunk) => {
16641
+ for (const dependency of chunk.dependencies) {
16642
+ if (parents.has(dependency)) {
16643
+ if (!analysedChunks.has(dependency)) {
16644
+ cycles++;
16645
+ }
16646
+ continue;
16647
+ }
16648
+ parents.add(dependency);
16649
+ analyseChunk(dependency);
16650
+ }
16651
+ analysedChunks.add(chunk);
16652
+ };
16653
+ for (const chunk of [
16654
+ ...partition.big.pure,
16655
+ ...partition.big.sideEffect,
16656
+ ...partition.small.pure,
16657
+ ...partition.small.sideEffect
16658
+ ]) {
16659
+ if (!parents.has(chunk)) {
16660
+ parents.add(chunk);
16661
+ analyseChunk(chunk);
16662
+ }
16663
+ }
16664
+ return cycles;
16665
+ }
16666
+ function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16667
+ for (const chunks of chunkLists) {
16668
+ chunks.sort(compareChunks);
16669
+ for (const chunk of chunks) {
16670
+ const { dependencies, modules, transitiveDependencies } = chunk;
16671
+ const transitiveDependencyModules = new Set();
16468
16672
  for (const module of modules) {
16469
- if (module.hasEffects()) {
16470
- break checkModules;
16673
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16674
+ const dependencyChunk = chunkByModule.get(dependency);
16675
+ if (dependencyChunk && dependencyChunk !== chunk) {
16676
+ dependencies.add(dependencyChunk);
16677
+ transitiveDependencyModules.add(dependency);
16678
+ }
16471
16679
  }
16472
- size += module.magicString.toString().length;
16473
- if (size > minChunkSize) {
16474
- break checkModules;
16680
+ }
16681
+ for (const module of transitiveDependencyModules) {
16682
+ const transitiveDependency = chunkByModule.get(module);
16683
+ if (transitiveDependency !== chunk) {
16684
+ transitiveDependencies.add(transitiveDependency);
16685
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16686
+ if (!(dependency instanceof ExternalModule)) {
16687
+ transitiveDependencyModules.add(dependency);
16688
+ }
16689
+ }
16475
16690
  }
16476
16691
  }
16477
- chunksToBeMerged.add({ alias, modules, signature, size });
16478
- continue;
16479
16692
  }
16480
- unmergeableChunks.push({ alias, modules, signature, size: null });
16481
16693
  }
16482
- return { chunksToBeMerged, unmergeableChunks };
16694
+ }
16695
+ function compareChunks({ size: sizeA }, { size: sizeB }) {
16696
+ return sizeA - sizeB;
16697
+ }
16698
+ function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition, chunkAliases) {
16699
+ for (const mergedChunk of chunksToBeMerged) {
16700
+ replaceAliasedDependencies(mergedChunk, chunkAliases);
16701
+ let closestChunk = null;
16702
+ let closestChunkDistance = Infinity;
16703
+ const { signature, modules, pure, size } = mergedChunk;
16704
+ for (const targetChunk of concatLazy(targetChunks)) {
16705
+ if (mergedChunk === targetChunk)
16706
+ continue;
16707
+ const distance = pure
16708
+ ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16709
+ : getSignatureDistance(targetChunk.signature, signature, true);
16710
+ if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk, chunkAliases)) {
16711
+ if (distance === 1) {
16712
+ closestChunk = targetChunk;
16713
+ break;
16714
+ }
16715
+ closestChunk = targetChunk;
16716
+ closestChunkDistance = distance;
16717
+ }
16718
+ }
16719
+ if (closestChunk) {
16720
+ chunkAliases.set(mergedChunk, closestChunk);
16721
+ chunksToBeMerged.delete(mergedChunk);
16722
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16723
+ closestChunk.modules.push(...modules);
16724
+ closestChunk.size += size;
16725
+ closestChunk.pure && (closestChunk.pure = pure);
16726
+ closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16727
+ const { dependencies, transitiveDependencies } = closestChunk;
16728
+ for (const dependency of mergedChunk.dependencies) {
16729
+ dependencies.add(dependency);
16730
+ }
16731
+ for (const dependency of mergedChunk.transitiveDependencies) {
16732
+ transitiveDependencies.add(dependency);
16733
+ }
16734
+ dependencies.delete(closestChunk);
16735
+ dependencies.delete(mergedChunk);
16736
+ transitiveDependencies.delete(closestChunk);
16737
+ transitiveDependencies.delete(mergedChunk);
16738
+ getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16739
+ }
16740
+ }
16741
+ }
16742
+ function replaceAliasedDependencies(chunk, chunkAliases) {
16743
+ for (const [alias, aliased] of chunkAliases) {
16744
+ if (chunk.dependencies.has(alias)) {
16745
+ chunk.dependencies.delete(alias);
16746
+ chunk.dependencies.add(aliased);
16747
+ }
16748
+ if (chunk.transitiveDependencies.has(alias)) {
16749
+ chunk.transitiveDependencies.delete(alias);
16750
+ chunk.transitiveDependencies.add(aliased);
16751
+ }
16752
+ }
16753
+ }
16754
+ // Merging will not produce cycles if
16755
+ // - no chunk is a transitive dependency of the other, or
16756
+ // - none of the direct non-merged dependencies of a chunk have the other
16757
+ // chunk as a transitive dependency
16758
+ function isValidMerge(mergedChunk, targetChunk, chunkAliases) {
16759
+ if (hasTransitiveDependency(mergedChunk, targetChunk)) {
16760
+ return false;
16761
+ }
16762
+ replaceAliasedDependencies(targetChunk, chunkAliases);
16763
+ return !hasTransitiveDependency(targetChunk, mergedChunk);
16764
+ }
16765
+ function hasTransitiveDependency(dependentChunk, dependencyChunk) {
16766
+ if (!dependentChunk.transitiveDependencies.has(dependencyChunk)) {
16767
+ return false;
16768
+ }
16769
+ for (const dependency of dependentChunk.dependencies) {
16770
+ if (dependency.transitiveDependencies.has(dependencyChunk)) {
16771
+ return true;
16772
+ }
16773
+ }
16774
+ return false;
16775
+ }
16776
+ function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16777
+ const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16778
+ return chunk.pure ? subPartition.pure : subPartition.sideEffect;
16483
16779
  }
16484
16780
  function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16485
16781
  let distance = 0;
@@ -25313,6 +25609,7 @@ exports.loadFsEvents = loadFsEvents;
25313
25609
  exports.mergeOptions = mergeOptions;
25314
25610
  exports.normalizePluginOption = normalizePluginOption;
25315
25611
  exports.picomatch = picomatch$1;
25612
+ exports.prettyBytes = prettyBytes;
25316
25613
  exports.printQuotedStringList = printQuotedStringList;
25317
25614
  exports.relativeId = relativeId;
25318
25615
  exports.rollup = rollup;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.4
4
- Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
3
+ Rollup.js v3.7.5-0
4
+ Fri, 16 Dec 2022 10:54:15 GMT - commit 1ee5d10583f88926dc36b97e7b3870ee078327e2
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.7.4",
3
+ "version": "3.7.5-0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",