rollup 3.7.3-0 → 3.7.3
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 +123 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +84 -370
- 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 +84 -371
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.7.3
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.7.3
|
|
4
|
+
Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { promises } from 'node:fs';
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.7.3
|
|
19
|
+
var version$1 = "3.7.3";
|
|
20
20
|
|
|
21
21
|
var charToInteger = {};
|
|
22
22
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -11269,12 +11269,7 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11269
11269
|
class Program extends NodeBase {
|
|
11270
11270
|
constructor() {
|
|
11271
11271
|
super(...arguments);
|
|
11272
|
-
this.hasCachedEffect =
|
|
11273
|
-
}
|
|
11274
|
-
hasCachedEffects() {
|
|
11275
|
-
return this.hasCachedEffect === null
|
|
11276
|
-
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11277
|
-
: this.hasCachedEffect;
|
|
11272
|
+
this.hasCachedEffect = false;
|
|
11278
11273
|
}
|
|
11279
11274
|
hasEffects(context) {
|
|
11280
11275
|
// We are caching here to later more efficiently identify side-effect-free modules
|
|
@@ -13134,7 +13129,8 @@ class Module {
|
|
|
13134
13129
|
return [null];
|
|
13135
13130
|
}
|
|
13136
13131
|
hasEffects() {
|
|
13137
|
-
return this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13132
|
+
return (this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13133
|
+
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13138
13134
|
}
|
|
13139
13135
|
include() {
|
|
13140
13136
|
const context = createInclusionContext();
|
|
@@ -14779,7 +14775,6 @@ class Chunk {
|
|
|
14779
14775
|
this.entryModules = [];
|
|
14780
14776
|
this.exportMode = 'named';
|
|
14781
14777
|
this.facadeModule = null;
|
|
14782
|
-
this.id = null;
|
|
14783
14778
|
this.namespaceVariableName = '';
|
|
14784
14779
|
this.variableName = '';
|
|
14785
14780
|
this.accessedGlobalsByScope = new Map();
|
|
@@ -14870,6 +14865,25 @@ class Chunk {
|
|
|
14870
14865
|
}
|
|
14871
14866
|
return true;
|
|
14872
14867
|
}
|
|
14868
|
+
finalizeChunk(code, map, hashesByPlaceholder) {
|
|
14869
|
+
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
14870
|
+
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
14871
|
+
const fileName = (this.fileName = finalize(renderedChunkInfo.fileName));
|
|
14872
|
+
return {
|
|
14873
|
+
...renderedChunkInfo,
|
|
14874
|
+
code,
|
|
14875
|
+
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
14876
|
+
fileName,
|
|
14877
|
+
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
14878
|
+
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
14879
|
+
finalize(fileName),
|
|
14880
|
+
bindings
|
|
14881
|
+
])),
|
|
14882
|
+
imports: renderedChunkInfo.imports.map(finalize),
|
|
14883
|
+
map,
|
|
14884
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
14885
|
+
};
|
|
14886
|
+
}
|
|
14873
14887
|
generateExports() {
|
|
14874
14888
|
this.sortedExportNames = null;
|
|
14875
14889
|
const remainingExports = new Set(this.exports);
|
|
@@ -14962,24 +14976,6 @@ class Chunk {
|
|
|
14962
14976
|
}
|
|
14963
14977
|
return facades;
|
|
14964
14978
|
}
|
|
14965
|
-
generateOutputChunk(code, map, hashesByPlaceholder) {
|
|
14966
|
-
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
14967
|
-
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
14968
|
-
return {
|
|
14969
|
-
...renderedChunkInfo,
|
|
14970
|
-
code,
|
|
14971
|
-
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
14972
|
-
fileName: finalize(renderedChunkInfo.fileName),
|
|
14973
|
-
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
14974
|
-
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
14975
|
-
finalize(fileName),
|
|
14976
|
-
bindings
|
|
14977
|
-
])),
|
|
14978
|
-
imports: renderedChunkInfo.imports.map(finalize),
|
|
14979
|
-
map,
|
|
14980
|
-
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
14981
|
-
};
|
|
14982
|
-
}
|
|
14983
14979
|
getChunkName() {
|
|
14984
14980
|
return (this.name ?? (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
14985
14981
|
}
|
|
@@ -14987,7 +14983,7 @@ class Chunk {
|
|
|
14987
14983
|
return (this.sortedExportNames ?? (this.sortedExportNames = [...this.exportsByName.keys()].sort()));
|
|
14988
14984
|
}
|
|
14989
14985
|
getFileName() {
|
|
14990
|
-
return this.
|
|
14986
|
+
return this.fileName || this.getPreliminaryFileName().fileName;
|
|
14991
14987
|
}
|
|
14992
14988
|
getImportPath(importer) {
|
|
14993
14989
|
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
@@ -15733,132 +15729,12 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
15733
15729
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
15734
15730
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
15735
15731
|
|
|
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
|
-
|
|
15856
15732
|
/**
|
|
15857
15733
|
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
15858
15734
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
15859
15735
|
* there is a chance that the iterators will not be fully exhausted.
|
|
15860
15736
|
*/
|
|
15861
|
-
function* concatLazy(iterables) {
|
|
15737
|
+
function* concatLazy(...iterables) {
|
|
15862
15738
|
for (const iterable of iterables) {
|
|
15863
15739
|
yield* iterable;
|
|
15864
15740
|
}
|
|
@@ -15999,11 +15875,47 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
15999
15875
|
alias: null,
|
|
16000
15876
|
modules
|
|
16001
15877
|
}))
|
|
16002
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16003
|
-
alias: null,
|
|
16004
|
-
modules
|
|
16005
|
-
}));
|
|
15878
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
16006
15879
|
}
|
|
15880
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
15881
|
+
timeStart('optimize chunks', 3);
|
|
15882
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
15883
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
15884
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
15885
|
+
let closestChunk = null;
|
|
15886
|
+
let closestChunkDistance = Infinity;
|
|
15887
|
+
const { signature, size, modules } = sourceChunk;
|
|
15888
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
15889
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
15890
|
+
if (distance === 1) {
|
|
15891
|
+
closestChunk = targetChunk;
|
|
15892
|
+
break;
|
|
15893
|
+
}
|
|
15894
|
+
else if (distance < closestChunkDistance) {
|
|
15895
|
+
closestChunk = targetChunk;
|
|
15896
|
+
closestChunkDistance = distance;
|
|
15897
|
+
}
|
|
15898
|
+
}
|
|
15899
|
+
if (closestChunk) {
|
|
15900
|
+
closestChunk.modules.push(...modules);
|
|
15901
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
15902
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
15903
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
15904
|
+
chunksToBeMerged.delete(closestChunk);
|
|
15905
|
+
unmergeableChunks.push(closestChunk);
|
|
15906
|
+
}
|
|
15907
|
+
}
|
|
15908
|
+
}
|
|
15909
|
+
else {
|
|
15910
|
+
unmergeableChunks.push(sourceChunk);
|
|
15911
|
+
}
|
|
15912
|
+
}
|
|
15913
|
+
timeEnd('optimize chunks', 3);
|
|
15914
|
+
return unmergeableChunks;
|
|
15915
|
+
}
|
|
15916
|
+
const CHAR_DEPENDENT = 'X';
|
|
15917
|
+
const CHAR_INDEPENDENT = '_';
|
|
15918
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16007
15919
|
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16008
15920
|
const chunkModules = Object.create(null);
|
|
16009
15921
|
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
@@ -16021,225 +15933,28 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16021
15933
|
}
|
|
16022
15934
|
return chunkModules;
|
|
16023
15935
|
}
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
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();
|
|
15936
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
15937
|
+
const chunksToBeMerged = new Set();
|
|
15938
|
+
const unmergeableChunks = [];
|
|
15939
|
+
const alias = null;
|
|
16073
15940
|
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
|
-
};
|
|
16083
15941
|
let size = 0;
|
|
16084
|
-
|
|
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();
|
|
15942
|
+
checkModules: {
|
|
16142
15943
|
for (const module of modules) {
|
|
16143
|
-
|
|
16144
|
-
|
|
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
|
-
}
|
|
16161
|
-
}
|
|
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;
|
|
15944
|
+
if (module.hasEffects()) {
|
|
15945
|
+
break checkModules;
|
|
16184
15946
|
}
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
}
|
|
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);
|
|
15947
|
+
size += module.magicString.toString().length;
|
|
15948
|
+
if (size > minChunkSize) {
|
|
15949
|
+
break checkModules;
|
|
16210
15950
|
}
|
|
16211
|
-
dependentChunk.transitiveDependencies.delete(mergedChunk);
|
|
16212
|
-
dependentChunk.transitiveDependencies.add(closestChunk);
|
|
16213
15951
|
}
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
transitiveDependentChunks.delete(closestChunk);
|
|
16217
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16218
|
-
}
|
|
16219
|
-
}
|
|
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;
|
|
15952
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
15953
|
+
continue;
|
|
16236
15954
|
}
|
|
15955
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
16237
15956
|
}
|
|
16238
|
-
return
|
|
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;
|
|
15957
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
16243
15958
|
}
|
|
16244
15959
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16245
15960
|
let distance = 0;
|
|
@@ -16743,14 +16458,14 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
16743
16458
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
16744
16459
|
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
16745
16460
|
}
|
|
16746
|
-
bundle[finalFileName] = chunk.
|
|
16461
|
+
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
16747
16462
|
}
|
|
16748
16463
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16749
16464
|
let updatedCode = hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code;
|
|
16750
16465
|
if (map) {
|
|
16751
16466
|
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
16752
16467
|
}
|
|
16753
|
-
bundle[fileName] = chunk.
|
|
16468
|
+
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
16754
16469
|
}
|
|
16755
16470
|
}
|
|
16756
16471
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -23293,8 +23008,7 @@ function getChunkFileName(file, facadeChunkByModule) {
|
|
|
23293
23008
|
return file.fileName;
|
|
23294
23009
|
}
|
|
23295
23010
|
if (facadeChunkByModule) {
|
|
23296
|
-
|
|
23297
|
-
return chunk.id || chunk.getFileName();
|
|
23011
|
+
return facadeChunkByModule.get(file.module).getFileName();
|
|
23298
23012
|
}
|
|
23299
23013
|
return error(errorChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
23300
23014
|
}
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED