rollup 3.6.1-0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.1-0
4
- Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
3
+ Rollup.js v3.7.0
4
+ Thu, 08 Dec 2022 05:38:14 GMT - commit e83d53900e7ef2b71c12762a7fe7c91ef715a289
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.6.1-0";
19
+ var version$1 = "3.7.0";
20
20
 
21
21
  var charToInteger = {};
22
22
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -1681,7 +1681,7 @@ function formatAssertions$1(assertions, { getObject }) {
1681
1681
 
1682
1682
  function getOrCreate(map, key, init) {
1683
1683
  const existing = map.get(key);
1684
- if (existing !== undefined) {
1684
+ if (existing) {
1685
1685
  return existing;
1686
1686
  }
1687
1687
  const value = init();
@@ -5031,6 +5031,10 @@ const literalNumberMembers = assembleMemberDescriptions({
5031
5031
  toPrecision: returnsString,
5032
5032
  valueOf: returnsNumber
5033
5033
  }, objectMembers);
5034
+ const literalRegExpMembers = assembleMemberDescriptions({
5035
+ exec: returnsUnknown,
5036
+ test: returnsBoolean
5037
+ }, objectMembers);
5034
5038
  const literalStringMembers = assembleMemberDescriptions({
5035
5039
  anchor: returnsString,
5036
5040
  at: returnsUnknown,
@@ -5082,6 +5086,9 @@ const literalStringMembers = assembleMemberDescriptions({
5082
5086
  valueOf: returnsString
5083
5087
  }, objectMembers);
5084
5088
  function getLiteralMembersForValue(value) {
5089
+ if (value instanceof RegExp) {
5090
+ return literalRegExpMembers;
5091
+ }
5085
5092
  switch (typeof value) {
5086
5093
  case 'boolean': {
5087
5094
  return literalBooleanMembers;
@@ -11255,12 +11262,7 @@ class PrivateIdentifier extends NodeBase {
11255
11262
  class Program extends NodeBase {
11256
11263
  constructor() {
11257
11264
  super(...arguments);
11258
- this.hasCachedEffect = null;
11259
- }
11260
- hasCachedEffects() {
11261
- return this.hasCachedEffect === null
11262
- ? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
11263
- : this.hasCachedEffect;
11265
+ this.hasCachedEffect = false;
11264
11266
  }
11265
11267
  hasEffects(context) {
11266
11268
  // We are caching here to later more efficiently identify side-effect-free modules
@@ -13120,7 +13122,8 @@ class Module {
13120
13122
  return [null];
13121
13123
  }
13122
13124
  hasEffects() {
13123
- return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
13125
+ return (this.info.moduleSideEffects === 'no-treeshake' ||
13126
+ (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
13124
13127
  }
13125
13128
  include() {
13126
13129
  const context = createInclusionContext();
@@ -15719,138 +15722,18 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
15719
15722
  const QUERY_HASH_REGEX = /[#?]/;
15720
15723
  const resolveFileName = (dependency) => dependency.getFileName();
15721
15724
 
15722
- const BYTE_UNITS = [
15723
- 'B',
15724
- 'kB',
15725
- 'MB',
15726
- 'GB',
15727
- 'TB',
15728
- 'PB',
15729
- 'EB',
15730
- 'ZB',
15731
- 'YB',
15732
- ];
15733
-
15734
- const BIBYTE_UNITS = [
15735
- 'B',
15736
- 'kiB',
15737
- 'MiB',
15738
- 'GiB',
15739
- 'TiB',
15740
- 'PiB',
15741
- 'EiB',
15742
- 'ZiB',
15743
- 'YiB',
15744
- ];
15745
-
15746
- const BIT_UNITS = [
15747
- 'b',
15748
- 'kbit',
15749
- 'Mbit',
15750
- 'Gbit',
15751
- 'Tbit',
15752
- 'Pbit',
15753
- 'Ebit',
15754
- 'Zbit',
15755
- 'Ybit',
15756
- ];
15757
-
15758
- const BIBIT_UNITS = [
15759
- 'b',
15760
- 'kibit',
15761
- 'Mibit',
15762
- 'Gibit',
15763
- 'Tibit',
15764
- 'Pibit',
15765
- 'Eibit',
15766
- 'Zibit',
15767
- 'Yibit',
15768
- ];
15769
-
15770
- /*
15771
- Formats the given number using `Number#toLocaleString`.
15772
- - If locale is a string, the value is expected to be a locale-key (for example: `de`).
15773
- - If locale is true, the system default locale is used for translation.
15774
- - If no value for locale is specified, the number is returned unmodified.
15775
- */
15776
- const toLocaleString = (number, locale, options) => {
15777
- let result = number;
15778
- if (typeof locale === 'string' || Array.isArray(locale)) {
15779
- result = number.toLocaleString(locale, options);
15780
- } else if (locale === true || options !== undefined) {
15781
- result = number.toLocaleString(undefined, options);
15782
- }
15783
-
15784
- return result;
15785
- };
15786
-
15787
- function prettyBytes(number, options) {
15788
- if (!Number.isFinite(number)) {
15789
- throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
15790
- }
15791
-
15792
- options = {
15793
- bits: false,
15794
- binary: false,
15795
- ...options,
15796
- };
15797
-
15798
- const UNITS = options.bits
15799
- ? (options.binary ? BIBIT_UNITS : BIT_UNITS)
15800
- : (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
15801
-
15802
- if (options.signed && number === 0) {
15803
- return ` 0 ${UNITS[0]}`;
15804
- }
15805
-
15806
- const isNegative = number < 0;
15807
- const prefix = isNegative ? '-' : (options.signed ? '+' : '');
15808
-
15809
- if (isNegative) {
15810
- number = -number;
15811
- }
15812
-
15813
- let localeOptions;
15814
-
15815
- if (options.minimumFractionDigits !== undefined) {
15816
- localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
15817
- }
15818
-
15819
- if (options.maximumFractionDigits !== undefined) {
15820
- localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
15821
- }
15822
-
15823
- if (number < 1) {
15824
- const numberString = toLocaleString(number, options.locale, localeOptions);
15825
- return prefix + numberString + ' ' + UNITS[0];
15826
- }
15827
-
15828
- const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
15829
- number /= (options.binary ? 1024 : 1000) ** exponent;
15830
-
15831
- if (!localeOptions) {
15832
- number = number.toPrecision(3);
15833
- }
15834
-
15835
- const numberString = toLocaleString(Number(number), options.locale, localeOptions);
15836
-
15837
- const unit = UNITS[exponent];
15838
-
15839
- return prefix + numberString + ' ' + unit;
15840
- }
15841
-
15842
15725
  /**
15843
15726
  * Concatenate a number of iterables to a new iterable without fully evaluating
15844
15727
  * their iterators. Useful when e.g. working with large sets or lists and when
15845
15728
  * there is a chance that the iterators will not be fully exhausted.
15846
15729
  */
15847
- function* concatLazy(iterables) {
15730
+ function* concatLazy(...iterables) {
15848
15731
  for (const iterable of iterables) {
15849
15732
  yield* iterable;
15850
15733
  }
15851
15734
  }
15852
15735
 
15853
- function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
15736
+ function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
15854
15737
  const chunkDefinitions = [];
15855
15738
  const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
15856
15739
  const manualChunkModulesByAlias = Object.create(null);
@@ -15860,19 +15743,53 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
15860
15743
  for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
15861
15744
  chunkDefinitions.push({ alias, modules });
15862
15745
  }
15863
- const alreadyLoadedModulesByDynamicEntry = getAlreadyLoadedModulesByDynamicEntry(entries);
15864
15746
  const assignedEntryPointsByModule = new Map();
15865
- for (const entry of entries) {
15747
+ const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
15748
+ const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
15749
+ const staticEntries = new Set(entryModules);
15750
+ function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
15751
+ const modulesToHandle = new Set([entry]);
15752
+ for (const module of modulesToHandle) {
15753
+ const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
15754
+ if (dynamicDependentEntryPoints &&
15755
+ areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
15756
+ continue;
15757
+ }
15758
+ else {
15759
+ assignedEntryPoints.add(entry);
15760
+ }
15761
+ for (const dependency of module.getDependenciesToBeIncluded()) {
15762
+ if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
15763
+ modulesToHandle.add(dependency);
15764
+ }
15765
+ }
15766
+ }
15767
+ }
15768
+ function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
15769
+ const entriesToCheck = new Set(entryPoints);
15770
+ for (const entry of entriesToCheck) {
15771
+ if (!containedIn.has(entry)) {
15772
+ if (staticEntries.has(entry))
15773
+ return false;
15774
+ const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
15775
+ for (const dependentEntry of dynamicallyDependentEntryPoints) {
15776
+ entriesToCheck.add(dependentEntry);
15777
+ }
15778
+ }
15779
+ }
15780
+ return true;
15781
+ }
15782
+ for (const entry of entryModules) {
15866
15783
  if (!modulesInManualChunks.has(entry)) {
15867
- assignEntryToStaticDependencies(entry, undefined, assignedEntryPointsByModule, modulesInManualChunks);
15784
+ assignEntryToStaticDependencies(entry, null);
15868
15785
  }
15869
15786
  }
15870
- for (const entry of alreadyLoadedModulesByDynamicEntry.keys()) {
15787
+ for (const entry of dynamicEntryModules) {
15871
15788
  if (!modulesInManualChunks.has(entry)) {
15872
- assignEntryToStaticDependencies(entry, alreadyLoadedModulesByDynamicEntry.get(entry), assignedEntryPointsByModule, modulesInManualChunks);
15789
+ assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
15873
15790
  }
15874
15791
  }
15875
- chunkDefinitions.push(...createChunks([...entries, ...alreadyLoadedModulesByDynamicEntry.keys()], assignedEntryPointsByModule, minChunkSize));
15792
+ chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
15876
15793
  return chunkDefinitions;
15877
15794
  }
15878
15795
  function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
@@ -15887,87 +15804,47 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
15887
15804
  }
15888
15805
  }
15889
15806
  }
15890
- function getAlreadyLoadedModulesByDynamicEntry(entryModules) {
15891
- const allModules = new Set(entryModules);
15807
+ function analyzeModuleGraph(entryModules) {
15808
+ const dynamicEntryModules = new Set();
15892
15809
  const dependentEntryPointsByModule = new Map();
15893
- const dynamicImportsByEntry = new Map();
15894
- const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
15895
15810
  const entriesToHandle = new Set(entryModules);
15896
15811
  for (const currentEntry of entriesToHandle) {
15897
15812
  const modulesToHandle = new Set([currentEntry]);
15898
- const dynamicImports = new Set();
15899
- dynamicImportsByEntry.set(currentEntry, dynamicImports);
15900
15813
  for (const module of modulesToHandle) {
15901
15814
  getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry);
15902
15815
  for (const dependency of module.getDependenciesToBeIncluded()) {
15903
15816
  if (!(dependency instanceof ExternalModule)) {
15904
15817
  modulesToHandle.add(dependency);
15905
- allModules.add(dependency);
15906
15818
  }
15907
15819
  }
15908
15820
  for (const { resolution } of module.dynamicImports) {
15909
15821
  if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
15910
- dynamicImports.add(resolution);
15911
- getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, resolution, () => new Set()).add(currentEntry);
15822
+ dynamicEntryModules.add(resolution);
15912
15823
  entriesToHandle.add(resolution);
15913
- allModules.add(resolution);
15914
15824
  }
15915
15825
  }
15916
15826
  for (const dependency of module.implicitlyLoadedBefore) {
15917
- dynamicImports.add(dependency);
15918
- getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dependency, () => new Set()).add(currentEntry);
15827
+ dynamicEntryModules.add(dependency);
15919
15828
  entriesToHandle.add(dependency);
15920
- allModules.add(dependency);
15921
- }
15922
- }
15923
- }
15924
- return buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry);
15925
- }
15926
- function buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry) {
15927
- const alreadyLoadedModulesByDynamicEntry = new Map();
15928
- for (const dynamicEntry of dynamicallyDependentEntryPointsByDynamicEntry.keys()) {
15929
- alreadyLoadedModulesByDynamicEntry.set(dynamicEntry, new Set());
15930
- }
15931
- for (const module of allModules) {
15932
- const dependentEntryPoints = dependentEntryPointsByModule.get(module);
15933
- for (const entry of dependentEntryPoints) {
15934
- const dynamicEntriesToHandle = [...dynamicImportsByEntry.get(entry)];
15935
- nextDynamicEntry: for (const dynamicEntry of dynamicEntriesToHandle) {
15936
- const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
15937
- if (alreadyLoadedModules.has(module)) {
15938
- continue;
15939
- }
15940
- for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
15941
- if (!(dependentEntryPoints.has(siblingDependentEntry) ||
15942
- alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
15943
- continue nextDynamicEntry;
15944
- }
15945
- }
15946
- alreadyLoadedModules.add(module);
15947
- dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
15948
15829
  }
15949
15830
  }
15950
15831
  }
15951
- return alreadyLoadedModulesByDynamicEntry;
15832
+ return { dependentEntryPointsByModule, dynamicEntryModules };
15952
15833
  }
15953
- function assignEntryToStaticDependencies(entry, alreadyLoadedModules, assignedEntryPointsByModule, modulesInManualChunks) {
15954
- const modulesToHandle = new Set([entry]);
15955
- for (const module of modulesToHandle) {
15956
- const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
15957
- // If the module is "already loaded" for this dynamic entry, we do not need
15958
- // to mark it for this dynamic entry
15959
- if (alreadyLoadedModules?.has(module)) {
15960
- continue;
15961
- }
15962
- else {
15963
- assignedEntryPoints.add(entry);
15964
- }
15965
- for (const dependency of module.getDependenciesToBeIncluded()) {
15966
- if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
15967
- modulesToHandle.add(dependency);
15834
+ function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules) {
15835
+ const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
15836
+ for (const dynamicEntry of dynamicEntryModules) {
15837
+ const dynamicDependentEntryPoints = getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dynamicEntry, () => new Set());
15838
+ for (const importer of [
15839
+ ...dynamicEntry.includedDynamicImporters,
15840
+ ...dynamicEntry.implicitlyLoadedAfter
15841
+ ]) {
15842
+ for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
15843
+ dynamicDependentEntryPoints.add(entryPoint);
15968
15844
  }
15969
15845
  }
15970
15846
  }
15847
+ return dynamicallyDependentEntryPointsByDynamicEntry;
15971
15848
  }
15972
15849
  function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
15973
15850
  const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
@@ -15976,49 +15853,43 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize)
15976
15853
  alias: null,
15977
15854
  modules
15978
15855
  }))
15979
- : getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
15980
- alias: null,
15981
- modules
15982
- }));
15856
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
15983
15857
  }
15984
- /**
15985
- * This function tries to get rid of small chunks by merging them with other
15986
- * chunks. In order to merge chunks, one must obey the following rule:
15987
- * - When merging several chunks, at most one of the chunks can have side
15988
- * effects
15989
- * - When one of the chunks has side effects, the entry points depending on that
15990
- * chunk need to be a super set of the entry points depending on the other
15991
- * chunks
15992
- * - Pure chunks can always be merged
15993
- * - We use the entry point dependence signature to calculate "chunk distance",
15994
- * i.e. how likely it is that two chunks are loaded together
15995
- */
15996
15858
  function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
15997
15859
  timeStart('optimize chunks', 3);
15998
- const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
15999
- console.log(`Created ${chunkPartition.big.pure.size +
16000
- chunkPartition.big.sideEffect.size +
16001
- chunkPartition.small.pure.size +
16002
- chunkPartition.small.sideEffect.size} chunks
16003
- ----- pure side effects
16004
- small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
16005
- big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
16006
- `);
16007
- console.log(`Trying to find merge targets for ${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`);
16008
- mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
16009
- console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\n`);
16010
- console.log(`Trying to find merge targets for ${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)}...`);
16011
- mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
16012
- console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\n`);
15860
+ const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
15861
+ for (const sourceChunk of chunksToBeMerged) {
15862
+ chunksToBeMerged.delete(sourceChunk);
15863
+ let closestChunk = null;
15864
+ let closestChunkDistance = Infinity;
15865
+ const { signature, size, modules } = sourceChunk;
15866
+ for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
15867
+ const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
15868
+ if (distance === 1) {
15869
+ closestChunk = targetChunk;
15870
+ break;
15871
+ }
15872
+ else if (distance < closestChunkDistance) {
15873
+ closestChunk = targetChunk;
15874
+ closestChunkDistance = distance;
15875
+ }
15876
+ }
15877
+ if (closestChunk) {
15878
+ closestChunk.modules.push(...modules);
15879
+ if (chunksToBeMerged.has(closestChunk)) {
15880
+ closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
15881
+ if ((closestChunk.size += size) > minChunkSize) {
15882
+ chunksToBeMerged.delete(closestChunk);
15883
+ unmergeableChunks.push(closestChunk);
15884
+ }
15885
+ }
15886
+ }
15887
+ else {
15888
+ unmergeableChunks.push(sourceChunk);
15889
+ }
15890
+ }
16013
15891
  timeEnd('optimize chunks', 3);
16014
- const result = [
16015
- ...chunkPartition.small.sideEffect,
16016
- ...chunkPartition.small.pure,
16017
- ...chunkPartition.big.sideEffect,
16018
- ...chunkPartition.big.pure
16019
- ];
16020
- console.log(`${result.length} chunks remaining.`);
16021
- return result;
15892
+ return unmergeableChunks;
16022
15893
  }
16023
15894
  const CHAR_DEPENDENT = 'X';
16024
15895
  const CHAR_INDEPENDENT = '_';
@@ -16040,141 +15911,28 @@ function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints)
16040
15911
  }
16041
15912
  return chunkModules;
16042
15913
  }
16043
- function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16044
- const smallPureChunks = [];
16045
- const bigPureChunks = [];
16046
- const smallSideEffectChunks = [];
16047
- const bigSideEffectChunks = [];
16048
- const chunkByModule = new Map();
15914
+ function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
15915
+ const chunksToBeMerged = new Set();
15916
+ const unmergeableChunks = [];
15917
+ const alias = null;
16049
15918
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16050
- const chunkDescription = {
16051
- dependencies: new Set(),
16052
- modules,
16053
- pure: true,
16054
- signature,
16055
- size: 0,
16056
- transitiveDependencies: new Set(),
16057
- transitiveDependentChunks: new Set()
16058
- };
16059
15919
  let size = 0;
16060
- let pure = true;
16061
- for (const module of modules) {
16062
- chunkByModule.set(module, chunkDescription);
16063
- pure && (pure = !module.hasEffects());
16064
- size += module.magicString.toString().length;
16065
- }
16066
- chunkDescription.pure = pure;
16067
- chunkDescription.size = size;
16068
- (size < minChunkSize
16069
- ? pure
16070
- ? smallPureChunks
16071
- : smallSideEffectChunks
16072
- : pure
16073
- ? bigPureChunks
16074
- : bigSideEffectChunks).push(chunkDescription);
16075
- }
16076
- sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
16077
- return {
16078
- big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
16079
- small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
16080
- };
16081
- }
16082
- function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
16083
- for (const chunks of chunkLists) {
16084
- chunks.sort(compareChunks);
16085
- for (const chunk of chunks) {
16086
- const { dependencies, modules, transitiveDependencies } = chunk;
16087
- const transitiveDependencyModules = new Set();
15920
+ checkModules: {
16088
15921
  for (const module of modules) {
16089
- for (const dependency of module.getDependenciesToBeIncluded()) {
16090
- const dependencyChunk = chunkByModule.get(dependency);
16091
- if (dependencyChunk && dependencyChunk !== chunk) {
16092
- dependencies.add(dependencyChunk);
16093
- transitiveDependencyModules.add(dependency);
16094
- }
16095
- }
16096
- }
16097
- for (const module of transitiveDependencyModules) {
16098
- const transitiveDependency = chunkByModule.get(module);
16099
- if (transitiveDependency !== chunk) {
16100
- transitiveDependencies.add(transitiveDependency);
16101
- transitiveDependency.transitiveDependentChunks.add(chunk);
16102
- for (const dependency of module.getDependenciesToBeIncluded()) {
16103
- if (!(dependency instanceof ExternalModule)) {
16104
- transitiveDependencyModules.add(dependency);
16105
- }
16106
- }
16107
- }
16108
- }
16109
- }
16110
- }
16111
- }
16112
- function compareChunks({ size: sizeA }, { size: sizeB }) {
16113
- return sizeA - sizeB;
16114
- }
16115
- function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
16116
- for (const mergedChunk of chunksToBeMerged) {
16117
- let closestChunk = null;
16118
- let closestChunkDistance = Infinity;
16119
- const { signature, modules, pure, size } = mergedChunk;
16120
- for (const targetChunk of concatLazy(targetChunks)) {
16121
- if (mergedChunk === targetChunk)
16122
- continue;
16123
- const distance = pure
16124
- ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16125
- : getSignatureDistance(targetChunk.signature, signature, true);
16126
- if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
16127
- if (distance === 1) {
16128
- closestChunk = targetChunk;
16129
- break;
15922
+ if (module.hasEffects()) {
15923
+ break checkModules;
16130
15924
  }
16131
- closestChunk = targetChunk;
16132
- closestChunkDistance = distance;
16133
- }
16134
- }
16135
- if (closestChunk) {
16136
- chunksToBeMerged.delete(mergedChunk);
16137
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16138
- closestChunk.modules.push(...modules);
16139
- closestChunk.size += size;
16140
- closestChunk.pure && (closestChunk.pure = pure);
16141
- closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16142
- const { dependencies, transitiveDependencies, transitiveDependentChunks } = closestChunk;
16143
- for (const dependency of mergedChunk.dependencies) {
16144
- dependencies.add(dependency);
16145
- }
16146
- for (const dependency of mergedChunk.transitiveDependencies) {
16147
- transitiveDependencies.add(dependency);
16148
- dependency.transitiveDependentChunks.delete(mergedChunk);
16149
- dependency.transitiveDependentChunks.add(closestChunk);
16150
- }
16151
- for (const dependentChunk of mergedChunk.transitiveDependentChunks) {
16152
- transitiveDependentChunks.add(dependentChunk);
16153
- if (dependentChunk.dependencies.has(mergedChunk)) {
16154
- dependentChunk.dependencies.delete(mergedChunk);
16155
- dependentChunk.dependencies.add(closestChunk);
15925
+ size += module.magicString.toString().length;
15926
+ if (size > minChunkSize) {
15927
+ break checkModules;
16156
15928
  }
16157
- dependentChunk.transitiveDependencies.delete(mergedChunk);
16158
- dependentChunk.transitiveDependencies.add(closestChunk);
16159
15929
  }
16160
- dependencies.delete(closestChunk);
16161
- transitiveDependencies.delete(closestChunk);
16162
- transitiveDependentChunks.delete(closestChunk);
16163
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
15930
+ chunksToBeMerged.add({ alias, modules, signature, size });
15931
+ continue;
16164
15932
  }
15933
+ unmergeableChunks.push({ alias, modules, signature, size: null });
16165
15934
  }
16166
- }
16167
- // If a module is a transitive but not a direct dependency of the other chunk,
16168
- // merging is prohibited as that would create a new cyclic dependency.
16169
- function isValidMerge(mergedChunk, targetChunk) {
16170
- return ((!targetChunk.transitiveDependencies.has(mergedChunk) ||
16171
- targetChunk.dependencies.has(mergedChunk)) &&
16172
- (!mergedChunk.transitiveDependencies.has(targetChunk) ||
16173
- mergedChunk.dependencies.has(targetChunk)));
16174
- }
16175
- function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16176
- const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16177
- return chunk.pure ? subPartition.pure : subPartition.sideEffect;
15935
+ return { chunksToBeMerged, unmergeableChunks };
16178
15936
  }
16179
15937
  function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16180
15938
  let distance = 0;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.1-0
4
- Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
3
+ Rollup.js v3.7.0
4
+ Thu, 08 Dec 2022 05:38:14 GMT - commit e83d53900e7ef2b71c12762a7fe7c91ef715a289
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.1-0
4
- Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
3
+ Rollup.js v3.7.0
4
+ Thu, 08 Dec 2022 05:38:14 GMT - commit e83d53900e7ef2b71c12762a7fe7c91ef715a289
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.6.1-0
4
- Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
3
+ Rollup.js v3.7.0
4
+ Thu, 08 Dec 2022 05:38:14 GMT - commit e83d53900e7ef2b71c12762a7fe7c91ef715a289
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.1-0
4
- Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
3
+ Rollup.js v3.7.0
4
+ Thu, 08 Dec 2022 05:38:14 GMT - commit e83d53900e7ef2b71c12762a7fe7c91ef715a289
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.1-0
4
- Tue, 06 Dec 2022 05:39:23 GMT - commit 1bff93da4b04d4e723793dd37607ec7775ba28dd
3
+ Rollup.js v3.7.0
4
+ Thu, 08 Dec 2022 05:38:14 GMT - commit e83d53900e7ef2b71c12762a7fe7c91ef715a289
5
5
 
6
6
  https://github.com/rollup/rollup
7
7