rollup 3.5.1 → 3.6.0-1

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