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