rollup 3.7.3 → 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.3
6
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3";
19
+ var version$1 = "3.7.5-0";
20
20
 
21
21
  var charToInteger = {};
22
22
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -5038,6 +5038,11 @@ const literalNumberMembers = assembleMemberDescriptions({
5038
5038
  toPrecision: returnsString,
5039
5039
  valueOf: returnsNumber
5040
5040
  }, objectMembers);
5041
+ /**
5042
+ * RegExp are stateful when they have the global or sticky flags set.
5043
+ * But if we actually don't use them, the side effect does not matter.
5044
+ * the check logic in `hasEffectsOnInteractionAtPath`.
5045
+ */
5041
5046
  const literalRegExpMembers = assembleMemberDescriptions({
5042
5047
  exec: returnsUnknown,
5043
5048
  test: returnsBoolean
@@ -8911,6 +8916,11 @@ class Literal extends NodeBase {
8911
8916
  return true;
8912
8917
  }
8913
8918
  case INTERACTION_CALLED: {
8919
+ if (this.included &&
8920
+ this.value instanceof RegExp &&
8921
+ (this.value.global || this.value.sticky)) {
8922
+ return true;
8923
+ }
8914
8924
  return (path.length !== 1 ||
8915
8925
  hasMemberEffectWhenCalled(this.members, path[0], interaction, context));
8916
8926
  }
@@ -11269,7 +11279,12 @@ class PrivateIdentifier extends NodeBase {
11269
11279
  class Program extends NodeBase {
11270
11280
  constructor() {
11271
11281
  super(...arguments);
11272
- this.hasCachedEffect = false;
11282
+ this.hasCachedEffect = null;
11283
+ }
11284
+ hasCachedEffects() {
11285
+ return this.hasCachedEffect === null
11286
+ ? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
11287
+ : this.hasCachedEffect;
11273
11288
  }
11274
11289
  hasEffects(context) {
11275
11290
  // We are caching here to later more efficiently identify side-effect-free modules
@@ -13129,8 +13144,7 @@ class Module {
13129
13144
  return [null];
13130
13145
  }
13131
13146
  hasEffects() {
13132
- return (this.info.moduleSideEffects === 'no-treeshake' ||
13133
- (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
13147
+ return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
13134
13148
  }
13135
13149
  include() {
13136
13150
  const context = createInclusionContext();
@@ -15729,12 +15743,132 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
15729
15743
  const QUERY_HASH_REGEX = /[#?]/;
15730
15744
  const resolveFileName = (dependency) => dependency.getFileName();
15731
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
+
15732
15866
  /**
15733
15867
  * Concatenate a number of iterables to a new iterable without fully evaluating
15734
15868
  * their iterators. Useful when e.g. working with large sets or lists and when
15735
15869
  * there is a chance that the iterators will not be fully exhausted.
15736
15870
  */
15737
- function* concatLazy(...iterables) {
15871
+ function* concatLazy(iterables) {
15738
15872
  for (const iterable of iterables) {
15739
15873
  yield* iterable;
15740
15874
  }
@@ -15875,47 +16009,11 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
15875
16009
  alias: null,
15876
16010
  modules
15877
16011
  }))
15878
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
15879
- }
15880
- function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
15881
- timeStart('optimize chunks', 3);
15882
- const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
15883
- for (const sourceChunk of chunksToBeMerged) {
15884
- chunksToBeMerged.delete(sourceChunk);
15885
- let closestChunk = null;
15886
- let closestChunkDistance = Infinity;
15887
- const { signature, size, modules } = sourceChunk;
15888
- for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
15889
- const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
15890
- if (distance === 1) {
15891
- closestChunk = targetChunk;
15892
- break;
15893
- }
15894
- else if (distance < closestChunkDistance) {
15895
- closestChunk = targetChunk;
15896
- closestChunkDistance = distance;
15897
- }
15898
- }
15899
- if (closestChunk) {
15900
- closestChunk.modules.push(...modules);
15901
- if (chunksToBeMerged.has(closestChunk)) {
15902
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
15903
- if ((closestChunk.size += size) > minChunkSize) {
15904
- chunksToBeMerged.delete(closestChunk);
15905
- unmergeableChunks.push(closestChunk);
15906
- }
15907
- }
15908
- }
15909
- else {
15910
- unmergeableChunks.push(sourceChunk);
15911
- }
15912
- }
15913
- timeEnd('optimize chunks', 3);
15914
- return unmergeableChunks;
16012
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
16013
+ alias: null,
16014
+ modules
16015
+ }));
15915
16016
  }
15916
- const CHAR_DEPENDENT = 'X';
15917
- const CHAR_INDEPENDENT = '_';
15918
- const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
15919
16017
  function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
15920
16018
  const chunkModules = Object.create(null);
15921
16019
  for (const [module, assignedEntries] of assignedEntriesByModule) {
@@ -15933,28 +16031,236 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
15933
16031
  }
15934
16032
  return chunkModules;
15935
16033
  }
15936
- function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
15937
- const chunksToBeMerged = new Set();
15938
- const unmergeableChunks = [];
15939
- 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();
15940
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
+ };
15941
16098
  let size = 0;
15942
- 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();
15943
16157
  for (const module of modules) {
15944
- if (module.hasEffects()) {
15945
- 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
+ }
15946
16164
  }
15947
- size += module.magicString.toString().length;
15948
- if (size > minChunkSize) {
15949
- 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
+ }
15950
16175
  }
15951
16176
  }
15952
- chunksToBeMerged.add({ alias, modules, signature, size });
15953
- continue;
15954
16177
  }
15955
- unmergeableChunks.push({ alias, modules, signature, size: null });
15956
16178
  }
15957
- 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;
15958
16264
  }
15959
16265
  function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
15960
16266
  let distance = 0;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3";
34
+ var version$1 = "3.7.5-0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -5553,6 +5553,11 @@ const literalNumberMembers = assembleMemberDescriptions({
5553
5553
  toPrecision: returnsString,
5554
5554
  valueOf: returnsNumber
5555
5555
  }, objectMembers);
5556
+ /**
5557
+ * RegExp are stateful when they have the global or sticky flags set.
5558
+ * But if we actually don't use them, the side effect does not matter.
5559
+ * the check logic in `hasEffectsOnInteractionAtPath`.
5560
+ */
5556
5561
  const literalRegExpMembers = assembleMemberDescriptions({
5557
5562
  exec: returnsUnknown,
5558
5563
  test: returnsBoolean
@@ -9426,6 +9431,11 @@ class Literal extends NodeBase {
9426
9431
  return true;
9427
9432
  }
9428
9433
  case INTERACTION_CALLED: {
9434
+ if (this.included &&
9435
+ this.value instanceof RegExp &&
9436
+ (this.value.global || this.value.sticky)) {
9437
+ return true;
9438
+ }
9429
9439
  return (path.length !== 1 ||
9430
9440
  hasMemberEffectWhenCalled(this.members, path[0], interaction, context));
9431
9441
  }
@@ -11784,7 +11794,12 @@ class PrivateIdentifier extends NodeBase {
11784
11794
  class Program extends NodeBase {
11785
11795
  constructor() {
11786
11796
  super(...arguments);
11787
- this.hasCachedEffect = false;
11797
+ this.hasCachedEffect = null;
11798
+ }
11799
+ hasCachedEffects() {
11800
+ return this.hasCachedEffect === null
11801
+ ? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
11802
+ : this.hasCachedEffect;
11788
11803
  }
11789
11804
  hasEffects(context) {
11790
11805
  // We are caching here to later more efficiently identify side-effect-free modules
@@ -13644,8 +13659,7 @@ class Module {
13644
13659
  return [null];
13645
13660
  }
13646
13661
  hasEffects() {
13647
- return (this.info.moduleSideEffects === 'no-treeshake' ||
13648
- (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
13662
+ return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
13649
13663
  }
13650
13664
  include() {
13651
13665
  const context = createInclusionContext();
@@ -16244,12 +16258,132 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
16244
16258
  const QUERY_HASH_REGEX = /[#?]/;
16245
16259
  const resolveFileName = (dependency) => dependency.getFileName();
16246
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
+
16247
16381
  /**
16248
16382
  * Concatenate a number of iterables to a new iterable without fully evaluating
16249
16383
  * their iterators. Useful when e.g. working with large sets or lists and when
16250
16384
  * there is a chance that the iterators will not be fully exhausted.
16251
16385
  */
16252
- function* concatLazy(...iterables) {
16386
+ function* concatLazy(iterables) {
16253
16387
  for (const iterable of iterables) {
16254
16388
  yield* iterable;
16255
16389
  }
@@ -16390,47 +16524,11 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
16390
16524
  alias: null,
16391
16525
  modules
16392
16526
  }))
16393
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
16394
- }
16395
- function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16396
- timeStart('optimize chunks', 3);
16397
- const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
16398
- for (const sourceChunk of chunksToBeMerged) {
16399
- chunksToBeMerged.delete(sourceChunk);
16400
- let closestChunk = null;
16401
- let closestChunkDistance = Infinity;
16402
- const { signature, size, modules } = sourceChunk;
16403
- for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
16404
- const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
16405
- if (distance === 1) {
16406
- closestChunk = targetChunk;
16407
- break;
16408
- }
16409
- else if (distance < closestChunkDistance) {
16410
- closestChunk = targetChunk;
16411
- closestChunkDistance = distance;
16412
- }
16413
- }
16414
- if (closestChunk) {
16415
- closestChunk.modules.push(...modules);
16416
- if (chunksToBeMerged.has(closestChunk)) {
16417
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16418
- if ((closestChunk.size += size) > minChunkSize) {
16419
- chunksToBeMerged.delete(closestChunk);
16420
- unmergeableChunks.push(closestChunk);
16421
- }
16422
- }
16423
- }
16424
- else {
16425
- unmergeableChunks.push(sourceChunk);
16426
- }
16427
- }
16428
- timeEnd('optimize chunks', 3);
16429
- return unmergeableChunks;
16527
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
16528
+ alias: null,
16529
+ modules
16530
+ }));
16430
16531
  }
16431
- const CHAR_DEPENDENT = 'X';
16432
- const CHAR_INDEPENDENT = '_';
16433
- const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
16434
16532
  function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
16435
16533
  const chunkModules = Object.create(null);
16436
16534
  for (const [module, assignedEntries] of assignedEntriesByModule) {
@@ -16448,28 +16546,236 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
16448
16546
  }
16449
16547
  return chunkModules;
16450
16548
  }
16451
- function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
16452
- const chunksToBeMerged = new Set();
16453
- const unmergeableChunks = [];
16454
- 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();
16455
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
+ };
16456
16613
  let size = 0;
16457
- 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();
16458
16672
  for (const module of modules) {
16459
- if (module.hasEffects()) {
16460
- 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
+ }
16461
16679
  }
16462
- size += module.magicString.toString().length;
16463
- if (size > minChunkSize) {
16464
- 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
+ }
16465
16690
  }
16466
16691
  }
16467
- chunksToBeMerged.add({ alias, modules, signature, size });
16468
- continue;
16469
16692
  }
16470
- unmergeableChunks.push({ alias, modules, signature, size: null });
16471
16693
  }
16472
- 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;
16473
16779
  }
16474
16780
  function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16475
16781
  let distance = 0;
@@ -25303,6 +25609,7 @@ exports.loadFsEvents = loadFsEvents;
25303
25609
  exports.mergeOptions = mergeOptions;
25304
25610
  exports.normalizePluginOption = normalizePluginOption;
25305
25611
  exports.picomatch = picomatch$1;
25612
+ exports.prettyBytes = prettyBytes;
25306
25613
  exports.printQuotedStringList = printQuotedStringList;
25307
25614
  exports.relativeId = relativeId;
25308
25615
  exports.rollup = rollup;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.7.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3
4
- Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
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.3",
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",