rollup 3.15.0 → 3.15.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +206 -116
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +206 -116
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/bin/rollup
CHANGED
package/dist/es/rollup.js
CHANGED
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.15.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.15.1-0
|
|
4
|
+
Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.15.0";
|
|
19
|
+
var version$1 = "3.15.1-0";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -16119,7 +16119,7 @@ function analyzeModuleGraph(entries) {
|
|
|
16119
16119
|
}
|
|
16120
16120
|
}
|
|
16121
16121
|
return {
|
|
16122
|
-
allEntries,
|
|
16122
|
+
allEntries: [...allEntries],
|
|
16123
16123
|
dependentEntriesByModule,
|
|
16124
16124
|
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
|
|
16125
16125
|
};
|
|
@@ -16193,7 +16193,7 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16193
16193
|
alias: null,
|
|
16194
16194
|
modules
|
|
16195
16195
|
}))
|
|
16196
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
|
|
16196
|
+
: getOptimizedChunks(chunkModulesBySignature, allEntries.length, minChunkSize).map(({ modules }) => ({
|
|
16197
16197
|
alias: null,
|
|
16198
16198
|
modules
|
|
16199
16199
|
}));
|
|
@@ -16217,49 +16217,109 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16217
16217
|
}
|
|
16218
16218
|
/**
|
|
16219
16219
|
* This function tries to get rid of small chunks by merging them with other
|
|
16220
|
-
* chunks.
|
|
16221
|
-
*
|
|
16222
|
-
*
|
|
16223
|
-
*
|
|
16224
|
-
*
|
|
16225
|
-
*
|
|
16226
|
-
*
|
|
16227
|
-
*
|
|
16228
|
-
*
|
|
16220
|
+
* chunks.
|
|
16221
|
+
*
|
|
16222
|
+
* We can only merge chunks safely if after the merge, loading any entry point
|
|
16223
|
+
* in any allowed order will not trigger side effects that should not have been
|
|
16224
|
+
* triggered. While side effects are usually things like global function calls,
|
|
16225
|
+
* global variable mutations or potentially thrown errors, details do not
|
|
16226
|
+
* matter here, and we just discern chunks without side effects (pure chunks)
|
|
16227
|
+
* from other chunks.
|
|
16228
|
+
*
|
|
16229
|
+
* As a first step, we assign each pre-generated chunk with side effects a
|
|
16230
|
+
* label. I.e. we have side effect "A" if the non-pure chunk "A" is loaded.
|
|
16231
|
+
*
|
|
16232
|
+
* Now to determine the side effects of loading a chunk, one also has to take
|
|
16233
|
+
* the side effects of its dependencies into account. So if A depends on B
|
|
16234
|
+
* (A -> B) and both have side effects, loading A triggers effects AB.
|
|
16235
|
+
*
|
|
16236
|
+
* Now from the previous step we know that each chunk is uniquely determine by
|
|
16237
|
+
* the entry points that depend on it and cause it to load, which we will call
|
|
16238
|
+
* its dependent entry points.
|
|
16239
|
+
*
|
|
16240
|
+
* E.g. if X -> A and Y -> A, then the dependent entry points of A are XY.
|
|
16241
|
+
* Starting from that idea, we can determine a set of chunks—and thus a set
|
|
16242
|
+
* of side effects—that must have been triggered if a certain chunk has been
|
|
16243
|
+
* loaded. Basically, it is the intersection of all chunks loaded by the
|
|
16244
|
+
* dependent entry points of a given chunk. We call the corresponding side
|
|
16245
|
+
* effects the correlated side effects of that chunk.
|
|
16246
|
+
*
|
|
16247
|
+
* Example:
|
|
16248
|
+
* X -> ABC, Y -> ADE, A-> F, B -> D
|
|
16249
|
+
* Then taking dependencies into account, X -> ABCDF, Y -> ADEF
|
|
16250
|
+
* The intersection is ADF. So we know that when A is loaded, D and F must also
|
|
16251
|
+
* be in memory even though neither D nor A is a dependency of the other.
|
|
16252
|
+
* If all have side effects, we call ADF the correlated side effects of A. The
|
|
16253
|
+
* correlated side effects need to remain constant when merging chunks.
|
|
16254
|
+
*
|
|
16255
|
+
* In contrast, we have the dependency side effects of A, which represents
|
|
16256
|
+
* the side effects we trigger if we directly load A. In this example, the
|
|
16257
|
+
* dependency side effects are AF.
|
|
16258
|
+
* For entry chunks, dependency and correlated side effects are the same.
|
|
16259
|
+
*
|
|
16260
|
+
* With these concepts, merging chunks is allowed if the correlated side effects
|
|
16261
|
+
* of each entry do not change. Thus, we are allowed to merge two chunks if
|
|
16262
|
+
* a) the dependency side effects of each chunk are a subset of the correlated
|
|
16263
|
+
* side effects of the other chunk, so no additional side effects are
|
|
16264
|
+
* triggered for any entry, or
|
|
16265
|
+
* b) The signature of chunk A is a subset of the signature of chunk B while the
|
|
16266
|
+
* dependency side effects of A are a subset of the correlated side effects
|
|
16267
|
+
* of B. Because in that scenario, whenever A is loaded, B is loaded as well.
|
|
16268
|
+
* But there are cases when B is loaded where A is not loaded. So if we merge
|
|
16269
|
+
* the chunks, all dependency side effects of A will be added to the
|
|
16270
|
+
* correlated side effects of B, and as the latter is not allowed to change,
|
|
16271
|
+
* the former need to be a subset of the latter.
|
|
16272
|
+
*
|
|
16273
|
+
* Another consideration when merging small chunks into other chunks is to avoid
|
|
16274
|
+
* that too much additional code is loaded. This is achieved when the dependent
|
|
16275
|
+
* entries of the small chunk are a subset of the dependent entries of the other
|
|
16276
|
+
* chunk. Because then when the small chunk is loaded, the other chunk was
|
|
16277
|
+
* loaded/in memory anyway, so at most when the other chunk is loaded, the
|
|
16278
|
+
* additional size of the small chunk is loaded unnecessarily.
|
|
16279
|
+
*
|
|
16280
|
+
* So the algorithm performs merges in two passes:
|
|
16281
|
+
* 1. First we try to merge small chunks A only into other chunks B if the
|
|
16282
|
+
* dependent entries of A are a subset of the dependent entries of B and the
|
|
16283
|
+
* dependency side effects of A are a subset of the correlated side effects
|
|
16284
|
+
* of B.
|
|
16285
|
+
* 2. Only then for all remaining small chunks, we look for arbitrary merges
|
|
16286
|
+
* following the above rules (a) and (b), starting with the smallest chunks
|
|
16287
|
+
* to look for possible merge targets.
|
|
16229
16288
|
*/
|
|
16230
|
-
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16289
|
+
function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
|
|
16231
16290
|
timeStart('optimize chunks', 3);
|
|
16232
|
-
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
|
|
16233
|
-
if (chunkPartition.small.
|
|
16234
|
-
mergeChunks(chunkPartition
|
|
16235
|
-
}
|
|
16236
|
-
if (chunkPartition.small.pure.size > 0) {
|
|
16237
|
-
mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16291
|
+
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize);
|
|
16292
|
+
if (chunkPartition.small.size > 0) {
|
|
16293
|
+
mergeChunks(chunkPartition, minChunkSize);
|
|
16238
16294
|
}
|
|
16239
16295
|
timeEnd('optimize chunks', 3);
|
|
16240
|
-
return [
|
|
16241
|
-
...chunkPartition.small.sideEffect,
|
|
16242
|
-
...chunkPartition.small.pure,
|
|
16243
|
-
...chunkPartition.big.sideEffect,
|
|
16244
|
-
...chunkPartition.big.pure
|
|
16245
|
-
];
|
|
16296
|
+
return [...chunkPartition.small, ...chunkPartition.big];
|
|
16246
16297
|
}
|
|
16247
16298
|
const CHAR_DEPENDENT = 'X';
|
|
16248
16299
|
const CHAR_INDEPENDENT = '_';
|
|
16249
|
-
|
|
16250
|
-
|
|
16251
|
-
const
|
|
16252
|
-
const bigPureChunks = [];
|
|
16253
|
-
const smallSideEffectChunks = [];
|
|
16254
|
-
const bigSideEffectChunks = [];
|
|
16300
|
+
function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
|
|
16301
|
+
const smallChunks = [];
|
|
16302
|
+
const bigChunks = [];
|
|
16255
16303
|
const chunkByModule = new Map();
|
|
16304
|
+
const sideEffectsByEntry = [];
|
|
16305
|
+
for (let index = 0; index < numberOfEntries; index++) {
|
|
16306
|
+
sideEffectsByEntry.push(new Set());
|
|
16307
|
+
}
|
|
16256
16308
|
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16309
|
+
const dependentEntries = new Set();
|
|
16310
|
+
for (let position = 0; position < numberOfEntries; position++) {
|
|
16311
|
+
if (signature[position] === CHAR_DEPENDENT) {
|
|
16312
|
+
dependentEntries.add(position);
|
|
16313
|
+
}
|
|
16314
|
+
}
|
|
16257
16315
|
const chunkDescription = {
|
|
16316
|
+
correlatedSideEffects: new Set(),
|
|
16258
16317
|
dependencies: new Set(),
|
|
16259
16318
|
dependentChunks: new Set(),
|
|
16319
|
+
dependentEntries,
|
|
16260
16320
|
modules,
|
|
16261
16321
|
pure: true,
|
|
16262
|
-
|
|
16322
|
+
sideEffects: new Set(),
|
|
16263
16323
|
size: 0
|
|
16264
16324
|
};
|
|
16265
16325
|
let size = 0;
|
|
@@ -16273,25 +16333,27 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
|
|
|
16273
16333
|
}
|
|
16274
16334
|
chunkDescription.pure = pure;
|
|
16275
16335
|
chunkDescription.size = size;
|
|
16276
|
-
(
|
|
16277
|
-
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
|
|
16336
|
+
if (!pure) {
|
|
16337
|
+
for (const entryIndex of dependentEntries) {
|
|
16338
|
+
sideEffectsByEntry[entryIndex].add(signature);
|
|
16339
|
+
}
|
|
16340
|
+
// In the beginning, each chunk is only its own side effect. After
|
|
16341
|
+
// merging, additional side effects can accumulate.
|
|
16342
|
+
chunkDescription.sideEffects.add(signature);
|
|
16343
|
+
}
|
|
16344
|
+
(size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
|
|
16345
|
+
}
|
|
16346
|
+
sortChunksAndAddDependenciesAndEffects([bigChunks, smallChunks], chunkByModule, sideEffectsByEntry);
|
|
16285
16347
|
return {
|
|
16286
|
-
big:
|
|
16287
|
-
small:
|
|
16348
|
+
big: new Set(bigChunks),
|
|
16349
|
+
small: new Set(smallChunks)
|
|
16288
16350
|
};
|
|
16289
16351
|
}
|
|
16290
|
-
function
|
|
16352
|
+
function sortChunksAndAddDependenciesAndEffects(chunkLists, chunkByModule, sideEffectsByEntry) {
|
|
16291
16353
|
for (const chunks of chunkLists) {
|
|
16292
|
-
chunks.sort(
|
|
16354
|
+
chunks.sort(compareChunkSize);
|
|
16293
16355
|
for (const chunk of chunks) {
|
|
16294
|
-
const { dependencies, modules } = chunk;
|
|
16356
|
+
const { dependencies, modules, correlatedSideEffects, dependentEntries } = chunk;
|
|
16295
16357
|
for (const module of modules) {
|
|
16296
16358
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16297
16359
|
const dependencyChunk = chunkByModule.get(dependency);
|
|
@@ -16301,89 +16363,129 @@ function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
|
16301
16363
|
}
|
|
16302
16364
|
}
|
|
16303
16365
|
}
|
|
16366
|
+
let firstEntry = true;
|
|
16367
|
+
// Correlated side effects is the intersection of all entry side effects
|
|
16368
|
+
for (const entryIndex of dependentEntries) {
|
|
16369
|
+
const entryEffects = sideEffectsByEntry[entryIndex];
|
|
16370
|
+
if (firstEntry) {
|
|
16371
|
+
for (const sideEffect of entryEffects) {
|
|
16372
|
+
correlatedSideEffects.add(sideEffect);
|
|
16373
|
+
}
|
|
16374
|
+
firstEntry = false;
|
|
16375
|
+
}
|
|
16376
|
+
else {
|
|
16377
|
+
for (const sideEffect of correlatedSideEffects) {
|
|
16378
|
+
if (!entryEffects.has(sideEffect)) {
|
|
16379
|
+
correlatedSideEffects.delete(sideEffect);
|
|
16380
|
+
}
|
|
16381
|
+
}
|
|
16382
|
+
}
|
|
16383
|
+
}
|
|
16304
16384
|
}
|
|
16305
16385
|
}
|
|
16306
16386
|
}
|
|
16307
|
-
function
|
|
16387
|
+
function compareChunkSize({ size: sizeA }, { size: sizeB }) {
|
|
16308
16388
|
return sizeA - sizeB;
|
|
16309
16389
|
}
|
|
16310
|
-
function mergeChunks(
|
|
16311
|
-
for (const
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
16316
|
-
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
const distance = pure
|
|
16326
|
-
? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
|
|
16327
|
-
: getSignatureDistance(targetChunk.signature, signature, true);
|
|
16328
|
-
if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
|
|
16329
|
-
if (distance === 1) {
|
|
16390
|
+
function mergeChunks(chunkPartition, minChunkSize) {
|
|
16391
|
+
for (const allowArbitraryMerges of [false, true]) {
|
|
16392
|
+
for (const mergedChunk of chunkPartition.small) {
|
|
16393
|
+
let closestChunk = null;
|
|
16394
|
+
let closestChunkDistance = Infinity;
|
|
16395
|
+
const { modules, pure, size } = mergedChunk;
|
|
16396
|
+
for (const targetChunk of concatLazy([chunkPartition.small, chunkPartition.big])) {
|
|
16397
|
+
if (mergedChunk === targetChunk)
|
|
16398
|
+
continue;
|
|
16399
|
+
// If both chunks are small, we also allow for unrelated merges during
|
|
16400
|
+
// the first pass
|
|
16401
|
+
const onlySubsetMerge = !allowArbitraryMerges && targetChunk.size >= minChunkSize;
|
|
16402
|
+
const distance = getChunkEntryDistance(mergedChunk, targetChunk, onlySubsetMerge);
|
|
16403
|
+
if (distance < closestChunkDistance &&
|
|
16404
|
+
isValidMerge(mergedChunk, targetChunk, onlySubsetMerge)) {
|
|
16330
16405
|
closestChunk = targetChunk;
|
|
16331
|
-
|
|
16406
|
+
closestChunkDistance = distance;
|
|
16332
16407
|
}
|
|
16333
|
-
closestChunk = targetChunk;
|
|
16334
|
-
closestChunkDistance = distance;
|
|
16335
|
-
}
|
|
16336
|
-
}
|
|
16337
|
-
if (closestChunk) {
|
|
16338
|
-
chunksToBeMerged.delete(mergedChunk);
|
|
16339
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16340
|
-
closestChunk.modules.push(...modules);
|
|
16341
|
-
closestChunk.size += size;
|
|
16342
|
-
closestChunk.pure && (closestChunk.pure = pure);
|
|
16343
|
-
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16344
|
-
const { dependencies, dependentChunks } = closestChunk;
|
|
16345
|
-
for (const dependency of mergedChunk.dependencies) {
|
|
16346
|
-
dependencies.add(dependency);
|
|
16347
16408
|
}
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16351
|
-
|
|
16409
|
+
if (closestChunk) {
|
|
16410
|
+
chunkPartition.small.delete(mergedChunk);
|
|
16411
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16412
|
+
closestChunk.modules.push(...modules);
|
|
16413
|
+
closestChunk.size += size;
|
|
16414
|
+
closestChunk.pure && (closestChunk.pure = pure);
|
|
16415
|
+
const { correlatedSideEffects, dependencies, dependentChunks, dependentEntries, sideEffects } = closestChunk;
|
|
16416
|
+
for (const sideEffect of correlatedSideEffects) {
|
|
16417
|
+
if (!mergedChunk.correlatedSideEffects.has(sideEffect)) {
|
|
16418
|
+
correlatedSideEffects.delete(sideEffect);
|
|
16419
|
+
}
|
|
16420
|
+
}
|
|
16421
|
+
for (const entry of mergedChunk.dependentEntries) {
|
|
16422
|
+
dependentEntries.add(entry);
|
|
16423
|
+
}
|
|
16424
|
+
for (const sideEffect of mergedChunk.sideEffects) {
|
|
16425
|
+
sideEffects.add(sideEffect);
|
|
16426
|
+
}
|
|
16427
|
+
for (const dependency of mergedChunk.dependencies) {
|
|
16428
|
+
dependencies.add(dependency);
|
|
16429
|
+
dependency.dependentChunks.delete(mergedChunk);
|
|
16430
|
+
dependency.dependentChunks.add(closestChunk);
|
|
16431
|
+
}
|
|
16432
|
+
for (const dependentChunk of mergedChunk.dependentChunks) {
|
|
16433
|
+
dependentChunks.add(dependentChunk);
|
|
16434
|
+
dependentChunk.dependencies.delete(mergedChunk);
|
|
16435
|
+
dependentChunk.dependencies.add(closestChunk);
|
|
16436
|
+
}
|
|
16437
|
+
dependencies.delete(closestChunk);
|
|
16438
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16352
16439
|
}
|
|
16353
|
-
dependencies.delete(closestChunk);
|
|
16354
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16355
16440
|
}
|
|
16356
16441
|
}
|
|
16357
16442
|
}
|
|
16358
16443
|
// Merging will not produce cycles if none of the direct non-merged dependencies
|
|
16359
16444
|
// of a chunk have the other chunk as a transitive dependency
|
|
16360
|
-
function isValidMerge(mergedChunk, targetChunk) {
|
|
16361
|
-
return !(
|
|
16362
|
-
|
|
16363
|
-
}
|
|
16364
|
-
function
|
|
16445
|
+
function isValidMerge(mergedChunk, targetChunk, onlySubsetMerge) {
|
|
16446
|
+
return !(hasTransitiveDependencyOrNonCorrelatedSideEffect(mergedChunk, targetChunk, true) ||
|
|
16447
|
+
hasTransitiveDependencyOrNonCorrelatedSideEffect(targetChunk, mergedChunk, !onlySubsetMerge));
|
|
16448
|
+
}
|
|
16449
|
+
function hasTransitiveDependencyOrNonCorrelatedSideEffect(dependentChunk, dependencyChunk, checkSideEffects) {
|
|
16450
|
+
const { correlatedSideEffects } = dependencyChunk;
|
|
16451
|
+
if (checkSideEffects) {
|
|
16452
|
+
for (const sideEffect of dependentChunk.sideEffects) {
|
|
16453
|
+
if (!correlatedSideEffects.has(sideEffect)) {
|
|
16454
|
+
return true;
|
|
16455
|
+
}
|
|
16456
|
+
}
|
|
16457
|
+
}
|
|
16365
16458
|
const chunksToCheck = new Set(dependentChunk.dependencies);
|
|
16366
|
-
for (const { dependencies } of chunksToCheck) {
|
|
16459
|
+
for (const { dependencies, sideEffects } of chunksToCheck) {
|
|
16367
16460
|
for (const dependency of dependencies) {
|
|
16368
16461
|
if (dependency === dependencyChunk) {
|
|
16369
16462
|
return true;
|
|
16370
16463
|
}
|
|
16371
16464
|
chunksToCheck.add(dependency);
|
|
16372
16465
|
}
|
|
16466
|
+
if (checkSideEffects) {
|
|
16467
|
+
for (const sideEffect of sideEffects) {
|
|
16468
|
+
if (!correlatedSideEffects.has(sideEffect)) {
|
|
16469
|
+
return true;
|
|
16470
|
+
}
|
|
16471
|
+
}
|
|
16472
|
+
}
|
|
16373
16473
|
}
|
|
16374
16474
|
return false;
|
|
16375
16475
|
}
|
|
16376
16476
|
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
16377
|
-
|
|
16378
|
-
return chunk.pure ? subPartition.pure : subPartition.sideEffect;
|
|
16477
|
+
return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
16379
16478
|
}
|
|
16380
|
-
function
|
|
16479
|
+
function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentEntries: targetEntries }, enforceSubest) {
|
|
16381
16480
|
let distance = 0;
|
|
16382
|
-
const
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
|
|
16386
|
-
|
|
16481
|
+
for (const entryIndex of targetEntries) {
|
|
16482
|
+
if (!sourceEntries.has(entryIndex)) {
|
|
16483
|
+
distance++;
|
|
16484
|
+
}
|
|
16485
|
+
}
|
|
16486
|
+
for (const entryIndex of sourceEntries) {
|
|
16487
|
+
if (!targetEntries.has(entryIndex)) {
|
|
16488
|
+
if (enforceSubest) {
|
|
16387
16489
|
return Infinity;
|
|
16388
16490
|
}
|
|
16389
16491
|
distance++;
|
|
@@ -16391,18 +16493,6 @@ function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
|
16391
16493
|
}
|
|
16392
16494
|
return distance;
|
|
16393
16495
|
}
|
|
16394
|
-
function mergeSignatures(sourceSignature, targetSignature) {
|
|
16395
|
-
let signature = '';
|
|
16396
|
-
const { length } = sourceSignature;
|
|
16397
|
-
for (let index = 0; index < length; index++) {
|
|
16398
|
-
signature +=
|
|
16399
|
-
sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
|
|
16400
|
-
targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
|
|
16401
|
-
? CHAR_DEPENDENT
|
|
16402
|
-
: CHAR_INDEPENDENT;
|
|
16403
|
-
}
|
|
16404
|
-
return signature;
|
|
16405
|
-
}
|
|
16406
16496
|
|
|
16407
16497
|
// ported from https://github.com/substack/node-commondir
|
|
16408
16498
|
function commondir(files) {
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.15.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.15.1-0
|
|
4
|
+
Mon, 13 Feb 2023 06:03:56 GMT - commit b3866fb81e367d24d78e7aaa93ec0fa794d63fe2
|
|
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.15.0";
|
|
34
|
+
var version$1 = "3.15.1-0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -16638,7 +16638,7 @@ function analyzeModuleGraph(entries) {
|
|
|
16638
16638
|
}
|
|
16639
16639
|
}
|
|
16640
16640
|
return {
|
|
16641
|
-
allEntries,
|
|
16641
|
+
allEntries: [...allEntries],
|
|
16642
16642
|
dependentEntriesByModule,
|
|
16643
16643
|
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
|
|
16644
16644
|
};
|
|
@@ -16712,7 +16712,7 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16712
16712
|
alias: null,
|
|
16713
16713
|
modules
|
|
16714
16714
|
}))
|
|
16715
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
|
|
16715
|
+
: getOptimizedChunks(chunkModulesBySignature, allEntries.length, minChunkSize).map(({ modules }) => ({
|
|
16716
16716
|
alias: null,
|
|
16717
16717
|
modules
|
|
16718
16718
|
}));
|
|
@@ -16736,49 +16736,109 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16736
16736
|
}
|
|
16737
16737
|
/**
|
|
16738
16738
|
* This function tries to get rid of small chunks by merging them with other
|
|
16739
|
-
* chunks.
|
|
16740
|
-
*
|
|
16741
|
-
*
|
|
16742
|
-
*
|
|
16743
|
-
*
|
|
16744
|
-
*
|
|
16745
|
-
*
|
|
16746
|
-
*
|
|
16747
|
-
*
|
|
16739
|
+
* chunks.
|
|
16740
|
+
*
|
|
16741
|
+
* We can only merge chunks safely if after the merge, loading any entry point
|
|
16742
|
+
* in any allowed order will not trigger side effects that should not have been
|
|
16743
|
+
* triggered. While side effects are usually things like global function calls,
|
|
16744
|
+
* global variable mutations or potentially thrown errors, details do not
|
|
16745
|
+
* matter here, and we just discern chunks without side effects (pure chunks)
|
|
16746
|
+
* from other chunks.
|
|
16747
|
+
*
|
|
16748
|
+
* As a first step, we assign each pre-generated chunk with side effects a
|
|
16749
|
+
* label. I.e. we have side effect "A" if the non-pure chunk "A" is loaded.
|
|
16750
|
+
*
|
|
16751
|
+
* Now to determine the side effects of loading a chunk, one also has to take
|
|
16752
|
+
* the side effects of its dependencies into account. So if A depends on B
|
|
16753
|
+
* (A -> B) and both have side effects, loading A triggers effects AB.
|
|
16754
|
+
*
|
|
16755
|
+
* Now from the previous step we know that each chunk is uniquely determine by
|
|
16756
|
+
* the entry points that depend on it and cause it to load, which we will call
|
|
16757
|
+
* its dependent entry points.
|
|
16758
|
+
*
|
|
16759
|
+
* E.g. if X -> A and Y -> A, then the dependent entry points of A are XY.
|
|
16760
|
+
* Starting from that idea, we can determine a set of chunks—and thus a set
|
|
16761
|
+
* of side effects—that must have been triggered if a certain chunk has been
|
|
16762
|
+
* loaded. Basically, it is the intersection of all chunks loaded by the
|
|
16763
|
+
* dependent entry points of a given chunk. We call the corresponding side
|
|
16764
|
+
* effects the correlated side effects of that chunk.
|
|
16765
|
+
*
|
|
16766
|
+
* Example:
|
|
16767
|
+
* X -> ABC, Y -> ADE, A-> F, B -> D
|
|
16768
|
+
* Then taking dependencies into account, X -> ABCDF, Y -> ADEF
|
|
16769
|
+
* The intersection is ADF. So we know that when A is loaded, D and F must also
|
|
16770
|
+
* be in memory even though neither D nor A is a dependency of the other.
|
|
16771
|
+
* If all have side effects, we call ADF the correlated side effects of A. The
|
|
16772
|
+
* correlated side effects need to remain constant when merging chunks.
|
|
16773
|
+
*
|
|
16774
|
+
* In contrast, we have the dependency side effects of A, which represents
|
|
16775
|
+
* the side effects we trigger if we directly load A. In this example, the
|
|
16776
|
+
* dependency side effects are AF.
|
|
16777
|
+
* For entry chunks, dependency and correlated side effects are the same.
|
|
16778
|
+
*
|
|
16779
|
+
* With these concepts, merging chunks is allowed if the correlated side effects
|
|
16780
|
+
* of each entry do not change. Thus, we are allowed to merge two chunks if
|
|
16781
|
+
* a) the dependency side effects of each chunk are a subset of the correlated
|
|
16782
|
+
* side effects of the other chunk, so no additional side effects are
|
|
16783
|
+
* triggered for any entry, or
|
|
16784
|
+
* b) The signature of chunk A is a subset of the signature of chunk B while the
|
|
16785
|
+
* dependency side effects of A are a subset of the correlated side effects
|
|
16786
|
+
* of B. Because in that scenario, whenever A is loaded, B is loaded as well.
|
|
16787
|
+
* But there are cases when B is loaded where A is not loaded. So if we merge
|
|
16788
|
+
* the chunks, all dependency side effects of A will be added to the
|
|
16789
|
+
* correlated side effects of B, and as the latter is not allowed to change,
|
|
16790
|
+
* the former need to be a subset of the latter.
|
|
16791
|
+
*
|
|
16792
|
+
* Another consideration when merging small chunks into other chunks is to avoid
|
|
16793
|
+
* that too much additional code is loaded. This is achieved when the dependent
|
|
16794
|
+
* entries of the small chunk are a subset of the dependent entries of the other
|
|
16795
|
+
* chunk. Because then when the small chunk is loaded, the other chunk was
|
|
16796
|
+
* loaded/in memory anyway, so at most when the other chunk is loaded, the
|
|
16797
|
+
* additional size of the small chunk is loaded unnecessarily.
|
|
16798
|
+
*
|
|
16799
|
+
* So the algorithm performs merges in two passes:
|
|
16800
|
+
* 1. First we try to merge small chunks A only into other chunks B if the
|
|
16801
|
+
* dependent entries of A are a subset of the dependent entries of B and the
|
|
16802
|
+
* dependency side effects of A are a subset of the correlated side effects
|
|
16803
|
+
* of B.
|
|
16804
|
+
* 2. Only then for all remaining small chunks, we look for arbitrary merges
|
|
16805
|
+
* following the above rules (a) and (b), starting with the smallest chunks
|
|
16806
|
+
* to look for possible merge targets.
|
|
16748
16807
|
*/
|
|
16749
|
-
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16808
|
+
function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
|
|
16750
16809
|
timeStart('optimize chunks', 3);
|
|
16751
|
-
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
|
|
16752
|
-
if (chunkPartition.small.
|
|
16753
|
-
mergeChunks(chunkPartition
|
|
16754
|
-
}
|
|
16755
|
-
if (chunkPartition.small.pure.size > 0) {
|
|
16756
|
-
mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16810
|
+
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize);
|
|
16811
|
+
if (chunkPartition.small.size > 0) {
|
|
16812
|
+
mergeChunks(chunkPartition, minChunkSize);
|
|
16757
16813
|
}
|
|
16758
16814
|
timeEnd('optimize chunks', 3);
|
|
16759
|
-
return [
|
|
16760
|
-
...chunkPartition.small.sideEffect,
|
|
16761
|
-
...chunkPartition.small.pure,
|
|
16762
|
-
...chunkPartition.big.sideEffect,
|
|
16763
|
-
...chunkPartition.big.pure
|
|
16764
|
-
];
|
|
16815
|
+
return [...chunkPartition.small, ...chunkPartition.big];
|
|
16765
16816
|
}
|
|
16766
16817
|
const CHAR_DEPENDENT = 'X';
|
|
16767
16818
|
const CHAR_INDEPENDENT = '_';
|
|
16768
|
-
|
|
16769
|
-
|
|
16770
|
-
const
|
|
16771
|
-
const bigPureChunks = [];
|
|
16772
|
-
const smallSideEffectChunks = [];
|
|
16773
|
-
const bigSideEffectChunks = [];
|
|
16819
|
+
function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
|
|
16820
|
+
const smallChunks = [];
|
|
16821
|
+
const bigChunks = [];
|
|
16774
16822
|
const chunkByModule = new Map();
|
|
16823
|
+
const sideEffectsByEntry = [];
|
|
16824
|
+
for (let index = 0; index < numberOfEntries; index++) {
|
|
16825
|
+
sideEffectsByEntry.push(new Set());
|
|
16826
|
+
}
|
|
16775
16827
|
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16828
|
+
const dependentEntries = new Set();
|
|
16829
|
+
for (let position = 0; position < numberOfEntries; position++) {
|
|
16830
|
+
if (signature[position] === CHAR_DEPENDENT) {
|
|
16831
|
+
dependentEntries.add(position);
|
|
16832
|
+
}
|
|
16833
|
+
}
|
|
16776
16834
|
const chunkDescription = {
|
|
16835
|
+
correlatedSideEffects: new Set(),
|
|
16777
16836
|
dependencies: new Set(),
|
|
16778
16837
|
dependentChunks: new Set(),
|
|
16838
|
+
dependentEntries,
|
|
16779
16839
|
modules,
|
|
16780
16840
|
pure: true,
|
|
16781
|
-
|
|
16841
|
+
sideEffects: new Set(),
|
|
16782
16842
|
size: 0
|
|
16783
16843
|
};
|
|
16784
16844
|
let size = 0;
|
|
@@ -16792,25 +16852,27 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
|
|
|
16792
16852
|
}
|
|
16793
16853
|
chunkDescription.pure = pure;
|
|
16794
16854
|
chunkDescription.size = size;
|
|
16795
|
-
(
|
|
16796
|
-
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16855
|
+
if (!pure) {
|
|
16856
|
+
for (const entryIndex of dependentEntries) {
|
|
16857
|
+
sideEffectsByEntry[entryIndex].add(signature);
|
|
16858
|
+
}
|
|
16859
|
+
// In the beginning, each chunk is only its own side effect. After
|
|
16860
|
+
// merging, additional side effects can accumulate.
|
|
16861
|
+
chunkDescription.sideEffects.add(signature);
|
|
16862
|
+
}
|
|
16863
|
+
(size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
|
|
16864
|
+
}
|
|
16865
|
+
sortChunksAndAddDependenciesAndEffects([bigChunks, smallChunks], chunkByModule, sideEffectsByEntry);
|
|
16804
16866
|
return {
|
|
16805
|
-
big:
|
|
16806
|
-
small:
|
|
16867
|
+
big: new Set(bigChunks),
|
|
16868
|
+
small: new Set(smallChunks)
|
|
16807
16869
|
};
|
|
16808
16870
|
}
|
|
16809
|
-
function
|
|
16871
|
+
function sortChunksAndAddDependenciesAndEffects(chunkLists, chunkByModule, sideEffectsByEntry) {
|
|
16810
16872
|
for (const chunks of chunkLists) {
|
|
16811
|
-
chunks.sort(
|
|
16873
|
+
chunks.sort(compareChunkSize);
|
|
16812
16874
|
for (const chunk of chunks) {
|
|
16813
|
-
const { dependencies, modules } = chunk;
|
|
16875
|
+
const { dependencies, modules, correlatedSideEffects, dependentEntries } = chunk;
|
|
16814
16876
|
for (const module of modules) {
|
|
16815
16877
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16816
16878
|
const dependencyChunk = chunkByModule.get(dependency);
|
|
@@ -16820,89 +16882,129 @@ function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
|
16820
16882
|
}
|
|
16821
16883
|
}
|
|
16822
16884
|
}
|
|
16885
|
+
let firstEntry = true;
|
|
16886
|
+
// Correlated side effects is the intersection of all entry side effects
|
|
16887
|
+
for (const entryIndex of dependentEntries) {
|
|
16888
|
+
const entryEffects = sideEffectsByEntry[entryIndex];
|
|
16889
|
+
if (firstEntry) {
|
|
16890
|
+
for (const sideEffect of entryEffects) {
|
|
16891
|
+
correlatedSideEffects.add(sideEffect);
|
|
16892
|
+
}
|
|
16893
|
+
firstEntry = false;
|
|
16894
|
+
}
|
|
16895
|
+
else {
|
|
16896
|
+
for (const sideEffect of correlatedSideEffects) {
|
|
16897
|
+
if (!entryEffects.has(sideEffect)) {
|
|
16898
|
+
correlatedSideEffects.delete(sideEffect);
|
|
16899
|
+
}
|
|
16900
|
+
}
|
|
16901
|
+
}
|
|
16902
|
+
}
|
|
16823
16903
|
}
|
|
16824
16904
|
}
|
|
16825
16905
|
}
|
|
16826
|
-
function
|
|
16906
|
+
function compareChunkSize({ size: sizeA }, { size: sizeB }) {
|
|
16827
16907
|
return sizeA - sizeB;
|
|
16828
16908
|
}
|
|
16829
|
-
function mergeChunks(
|
|
16830
|
-
for (const
|
|
16831
|
-
|
|
16832
|
-
|
|
16833
|
-
|
|
16834
|
-
|
|
16835
|
-
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
|
|
16842
|
-
|
|
16843
|
-
|
|
16844
|
-
const distance = pure
|
|
16845
|
-
? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
|
|
16846
|
-
: getSignatureDistance(targetChunk.signature, signature, true);
|
|
16847
|
-
if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
|
|
16848
|
-
if (distance === 1) {
|
|
16909
|
+
function mergeChunks(chunkPartition, minChunkSize) {
|
|
16910
|
+
for (const allowArbitraryMerges of [false, true]) {
|
|
16911
|
+
for (const mergedChunk of chunkPartition.small) {
|
|
16912
|
+
let closestChunk = null;
|
|
16913
|
+
let closestChunkDistance = Infinity;
|
|
16914
|
+
const { modules, pure, size } = mergedChunk;
|
|
16915
|
+
for (const targetChunk of concatLazy([chunkPartition.small, chunkPartition.big])) {
|
|
16916
|
+
if (mergedChunk === targetChunk)
|
|
16917
|
+
continue;
|
|
16918
|
+
// If both chunks are small, we also allow for unrelated merges during
|
|
16919
|
+
// the first pass
|
|
16920
|
+
const onlySubsetMerge = !allowArbitraryMerges && targetChunk.size >= minChunkSize;
|
|
16921
|
+
const distance = getChunkEntryDistance(mergedChunk, targetChunk, onlySubsetMerge);
|
|
16922
|
+
if (distance < closestChunkDistance &&
|
|
16923
|
+
isValidMerge(mergedChunk, targetChunk, onlySubsetMerge)) {
|
|
16849
16924
|
closestChunk = targetChunk;
|
|
16850
|
-
|
|
16925
|
+
closestChunkDistance = distance;
|
|
16851
16926
|
}
|
|
16852
|
-
closestChunk = targetChunk;
|
|
16853
|
-
closestChunkDistance = distance;
|
|
16854
|
-
}
|
|
16855
|
-
}
|
|
16856
|
-
if (closestChunk) {
|
|
16857
|
-
chunksToBeMerged.delete(mergedChunk);
|
|
16858
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16859
|
-
closestChunk.modules.push(...modules);
|
|
16860
|
-
closestChunk.size += size;
|
|
16861
|
-
closestChunk.pure && (closestChunk.pure = pure);
|
|
16862
|
-
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16863
|
-
const { dependencies, dependentChunks } = closestChunk;
|
|
16864
|
-
for (const dependency of mergedChunk.dependencies) {
|
|
16865
|
-
dependencies.add(dependency);
|
|
16866
16927
|
}
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
|
|
16928
|
+
if (closestChunk) {
|
|
16929
|
+
chunkPartition.small.delete(mergedChunk);
|
|
16930
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16931
|
+
closestChunk.modules.push(...modules);
|
|
16932
|
+
closestChunk.size += size;
|
|
16933
|
+
closestChunk.pure && (closestChunk.pure = pure);
|
|
16934
|
+
const { correlatedSideEffects, dependencies, dependentChunks, dependentEntries, sideEffects } = closestChunk;
|
|
16935
|
+
for (const sideEffect of correlatedSideEffects) {
|
|
16936
|
+
if (!mergedChunk.correlatedSideEffects.has(sideEffect)) {
|
|
16937
|
+
correlatedSideEffects.delete(sideEffect);
|
|
16938
|
+
}
|
|
16939
|
+
}
|
|
16940
|
+
for (const entry of mergedChunk.dependentEntries) {
|
|
16941
|
+
dependentEntries.add(entry);
|
|
16942
|
+
}
|
|
16943
|
+
for (const sideEffect of mergedChunk.sideEffects) {
|
|
16944
|
+
sideEffects.add(sideEffect);
|
|
16945
|
+
}
|
|
16946
|
+
for (const dependency of mergedChunk.dependencies) {
|
|
16947
|
+
dependencies.add(dependency);
|
|
16948
|
+
dependency.dependentChunks.delete(mergedChunk);
|
|
16949
|
+
dependency.dependentChunks.add(closestChunk);
|
|
16950
|
+
}
|
|
16951
|
+
for (const dependentChunk of mergedChunk.dependentChunks) {
|
|
16952
|
+
dependentChunks.add(dependentChunk);
|
|
16953
|
+
dependentChunk.dependencies.delete(mergedChunk);
|
|
16954
|
+
dependentChunk.dependencies.add(closestChunk);
|
|
16955
|
+
}
|
|
16956
|
+
dependencies.delete(closestChunk);
|
|
16957
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16871
16958
|
}
|
|
16872
|
-
dependencies.delete(closestChunk);
|
|
16873
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16874
16959
|
}
|
|
16875
16960
|
}
|
|
16876
16961
|
}
|
|
16877
16962
|
// Merging will not produce cycles if none of the direct non-merged dependencies
|
|
16878
16963
|
// of a chunk have the other chunk as a transitive dependency
|
|
16879
|
-
function isValidMerge(mergedChunk, targetChunk) {
|
|
16880
|
-
return !(
|
|
16881
|
-
|
|
16882
|
-
}
|
|
16883
|
-
function
|
|
16964
|
+
function isValidMerge(mergedChunk, targetChunk, onlySubsetMerge) {
|
|
16965
|
+
return !(hasTransitiveDependencyOrNonCorrelatedSideEffect(mergedChunk, targetChunk, true) ||
|
|
16966
|
+
hasTransitiveDependencyOrNonCorrelatedSideEffect(targetChunk, mergedChunk, !onlySubsetMerge));
|
|
16967
|
+
}
|
|
16968
|
+
function hasTransitiveDependencyOrNonCorrelatedSideEffect(dependentChunk, dependencyChunk, checkSideEffects) {
|
|
16969
|
+
const { correlatedSideEffects } = dependencyChunk;
|
|
16970
|
+
if (checkSideEffects) {
|
|
16971
|
+
for (const sideEffect of dependentChunk.sideEffects) {
|
|
16972
|
+
if (!correlatedSideEffects.has(sideEffect)) {
|
|
16973
|
+
return true;
|
|
16974
|
+
}
|
|
16975
|
+
}
|
|
16976
|
+
}
|
|
16884
16977
|
const chunksToCheck = new Set(dependentChunk.dependencies);
|
|
16885
|
-
for (const { dependencies } of chunksToCheck) {
|
|
16978
|
+
for (const { dependencies, sideEffects } of chunksToCheck) {
|
|
16886
16979
|
for (const dependency of dependencies) {
|
|
16887
16980
|
if (dependency === dependencyChunk) {
|
|
16888
16981
|
return true;
|
|
16889
16982
|
}
|
|
16890
16983
|
chunksToCheck.add(dependency);
|
|
16891
16984
|
}
|
|
16985
|
+
if (checkSideEffects) {
|
|
16986
|
+
for (const sideEffect of sideEffects) {
|
|
16987
|
+
if (!correlatedSideEffects.has(sideEffect)) {
|
|
16988
|
+
return true;
|
|
16989
|
+
}
|
|
16990
|
+
}
|
|
16991
|
+
}
|
|
16892
16992
|
}
|
|
16893
16993
|
return false;
|
|
16894
16994
|
}
|
|
16895
16995
|
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
16896
|
-
|
|
16897
|
-
return chunk.pure ? subPartition.pure : subPartition.sideEffect;
|
|
16996
|
+
return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
16898
16997
|
}
|
|
16899
|
-
function
|
|
16998
|
+
function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentEntries: targetEntries }, enforceSubest) {
|
|
16900
16999
|
let distance = 0;
|
|
16901
|
-
const
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
17000
|
+
for (const entryIndex of targetEntries) {
|
|
17001
|
+
if (!sourceEntries.has(entryIndex)) {
|
|
17002
|
+
distance++;
|
|
17003
|
+
}
|
|
17004
|
+
}
|
|
17005
|
+
for (const entryIndex of sourceEntries) {
|
|
17006
|
+
if (!targetEntries.has(entryIndex)) {
|
|
17007
|
+
if (enforceSubest) {
|
|
16906
17008
|
return Infinity;
|
|
16907
17009
|
}
|
|
16908
17010
|
distance++;
|
|
@@ -16910,18 +17012,6 @@ function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
|
16910
17012
|
}
|
|
16911
17013
|
return distance;
|
|
16912
17014
|
}
|
|
16913
|
-
function mergeSignatures(sourceSignature, targetSignature) {
|
|
16914
|
-
let signature = '';
|
|
16915
|
-
const { length } = sourceSignature;
|
|
16916
|
-
for (let index = 0; index < length; index++) {
|
|
16917
|
-
signature +=
|
|
16918
|
-
sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
|
|
16919
|
-
targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
|
|
16920
|
-
? CHAR_DEPENDENT
|
|
16921
|
-
: CHAR_INDEPENDENT;
|
|
16922
|
-
}
|
|
16923
|
-
return signature;
|
|
16924
|
-
}
|
|
16925
17015
|
|
|
16926
17016
|
// ported from https://github.com/substack/node-commondir
|
|
16927
17017
|
function commondir(files) {
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED