rollup 3.7.3-0 → 3.7.4
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 +94 -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 +94 -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.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.7.4
|
|
4
|
+
Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
|
|
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.4";
|
|
20
20
|
|
|
21
21
|
var charToInteger = {};
|
|
22
22
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -5038,6 +5038,11 @@ const literalNumberMembers = assembleMemberDescriptions({
|
|
|
5038
5038
|
toPrecision: returnsString,
|
|
5039
5039
|
valueOf: returnsNumber
|
|
5040
5040
|
}, objectMembers);
|
|
5041
|
+
/**
|
|
5042
|
+
* RegExp are stateful when they have the global or sticky flags set.
|
|
5043
|
+
* But if we actually don't use them, the side effect does not matter.
|
|
5044
|
+
* the check logic in `hasEffectsOnInteractionAtPath`.
|
|
5045
|
+
*/
|
|
5041
5046
|
const literalRegExpMembers = assembleMemberDescriptions({
|
|
5042
5047
|
exec: returnsUnknown,
|
|
5043
5048
|
test: returnsBoolean
|
|
@@ -8911,6 +8916,11 @@ class Literal extends NodeBase {
|
|
|
8911
8916
|
return true;
|
|
8912
8917
|
}
|
|
8913
8918
|
case INTERACTION_CALLED: {
|
|
8919
|
+
if (this.included &&
|
|
8920
|
+
this.value instanceof RegExp &&
|
|
8921
|
+
(this.value.global || this.value.sticky)) {
|
|
8922
|
+
return true;
|
|
8923
|
+
}
|
|
8914
8924
|
return (path.length !== 1 ||
|
|
8915
8925
|
hasMemberEffectWhenCalled(this.members, path[0], interaction, context));
|
|
8916
8926
|
}
|
|
@@ -11269,12 +11279,7 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11269
11279
|
class Program extends NodeBase {
|
|
11270
11280
|
constructor() {
|
|
11271
11281
|
super(...arguments);
|
|
11272
|
-
this.hasCachedEffect =
|
|
11273
|
-
}
|
|
11274
|
-
hasCachedEffects() {
|
|
11275
|
-
return this.hasCachedEffect === null
|
|
11276
|
-
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11277
|
-
: this.hasCachedEffect;
|
|
11282
|
+
this.hasCachedEffect = false;
|
|
11278
11283
|
}
|
|
11279
11284
|
hasEffects(context) {
|
|
11280
11285
|
// We are caching here to later more efficiently identify side-effect-free modules
|
|
@@ -13134,7 +13139,8 @@ class Module {
|
|
|
13134
13139
|
return [null];
|
|
13135
13140
|
}
|
|
13136
13141
|
hasEffects() {
|
|
13137
|
-
return this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13142
|
+
return (this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13143
|
+
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13138
13144
|
}
|
|
13139
13145
|
include() {
|
|
13140
13146
|
const context = createInclusionContext();
|
|
@@ -14779,7 +14785,6 @@ class Chunk {
|
|
|
14779
14785
|
this.entryModules = [];
|
|
14780
14786
|
this.exportMode = 'named';
|
|
14781
14787
|
this.facadeModule = null;
|
|
14782
|
-
this.id = null;
|
|
14783
14788
|
this.namespaceVariableName = '';
|
|
14784
14789
|
this.variableName = '';
|
|
14785
14790
|
this.accessedGlobalsByScope = new Map();
|
|
@@ -14870,6 +14875,25 @@ class Chunk {
|
|
|
14870
14875
|
}
|
|
14871
14876
|
return true;
|
|
14872
14877
|
}
|
|
14878
|
+
finalizeChunk(code, map, hashesByPlaceholder) {
|
|
14879
|
+
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
14880
|
+
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
14881
|
+
const fileName = (this.fileName = finalize(renderedChunkInfo.fileName));
|
|
14882
|
+
return {
|
|
14883
|
+
...renderedChunkInfo,
|
|
14884
|
+
code,
|
|
14885
|
+
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
14886
|
+
fileName,
|
|
14887
|
+
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
14888
|
+
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
14889
|
+
finalize(fileName),
|
|
14890
|
+
bindings
|
|
14891
|
+
])),
|
|
14892
|
+
imports: renderedChunkInfo.imports.map(finalize),
|
|
14893
|
+
map,
|
|
14894
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
14895
|
+
};
|
|
14896
|
+
}
|
|
14873
14897
|
generateExports() {
|
|
14874
14898
|
this.sortedExportNames = null;
|
|
14875
14899
|
const remainingExports = new Set(this.exports);
|
|
@@ -14962,24 +14986,6 @@ class Chunk {
|
|
|
14962
14986
|
}
|
|
14963
14987
|
return facades;
|
|
14964
14988
|
}
|
|
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
14989
|
getChunkName() {
|
|
14984
14990
|
return (this.name ?? (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
14985
14991
|
}
|
|
@@ -14987,7 +14993,7 @@ class Chunk {
|
|
|
14987
14993
|
return (this.sortedExportNames ?? (this.sortedExportNames = [...this.exportsByName.keys()].sort()));
|
|
14988
14994
|
}
|
|
14989
14995
|
getFileName() {
|
|
14990
|
-
return this.
|
|
14996
|
+
return this.fileName || this.getPreliminaryFileName().fileName;
|
|
14991
14997
|
}
|
|
14992
14998
|
getImportPath(importer) {
|
|
14993
14999
|
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
@@ -15733,132 +15739,12 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
15733
15739
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
15734
15740
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
15735
15741
|
|
|
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
15742
|
/**
|
|
15857
15743
|
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
15858
15744
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
15859
15745
|
* there is a chance that the iterators will not be fully exhausted.
|
|
15860
15746
|
*/
|
|
15861
|
-
function* concatLazy(iterables) {
|
|
15747
|
+
function* concatLazy(...iterables) {
|
|
15862
15748
|
for (const iterable of iterables) {
|
|
15863
15749
|
yield* iterable;
|
|
15864
15750
|
}
|
|
@@ -15999,11 +15885,47 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
15999
15885
|
alias: null,
|
|
16000
15886
|
modules
|
|
16001
15887
|
}))
|
|
16002
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16003
|
-
alias: null,
|
|
16004
|
-
modules
|
|
16005
|
-
}));
|
|
15888
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
16006
15889
|
}
|
|
15890
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
15891
|
+
timeStart('optimize chunks', 3);
|
|
15892
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
15893
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
15894
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
15895
|
+
let closestChunk = null;
|
|
15896
|
+
let closestChunkDistance = Infinity;
|
|
15897
|
+
const { signature, size, modules } = sourceChunk;
|
|
15898
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
15899
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
15900
|
+
if (distance === 1) {
|
|
15901
|
+
closestChunk = targetChunk;
|
|
15902
|
+
break;
|
|
15903
|
+
}
|
|
15904
|
+
else if (distance < closestChunkDistance) {
|
|
15905
|
+
closestChunk = targetChunk;
|
|
15906
|
+
closestChunkDistance = distance;
|
|
15907
|
+
}
|
|
15908
|
+
}
|
|
15909
|
+
if (closestChunk) {
|
|
15910
|
+
closestChunk.modules.push(...modules);
|
|
15911
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
15912
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
15913
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
15914
|
+
chunksToBeMerged.delete(closestChunk);
|
|
15915
|
+
unmergeableChunks.push(closestChunk);
|
|
15916
|
+
}
|
|
15917
|
+
}
|
|
15918
|
+
}
|
|
15919
|
+
else {
|
|
15920
|
+
unmergeableChunks.push(sourceChunk);
|
|
15921
|
+
}
|
|
15922
|
+
}
|
|
15923
|
+
timeEnd('optimize chunks', 3);
|
|
15924
|
+
return unmergeableChunks;
|
|
15925
|
+
}
|
|
15926
|
+
const CHAR_DEPENDENT = 'X';
|
|
15927
|
+
const CHAR_INDEPENDENT = '_';
|
|
15928
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16007
15929
|
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16008
15930
|
const chunkModules = Object.create(null);
|
|
16009
15931
|
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
@@ -16021,225 +15943,28 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16021
15943
|
}
|
|
16022
15944
|
return chunkModules;
|
|
16023
15945
|
}
|
|
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();
|
|
15946
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
15947
|
+
const chunksToBeMerged = new Set();
|
|
15948
|
+
const unmergeableChunks = [];
|
|
15949
|
+
const alias = null;
|
|
16073
15950
|
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
15951
|
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();
|
|
15952
|
+
checkModules: {
|
|
16142
15953
|
for (const module of modules) {
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
16146
|
-
dependencies.add(dependencyChunk);
|
|
16147
|
-
transitiveDependencyModules.add(dependency);
|
|
16148
|
-
}
|
|
15954
|
+
if (module.hasEffects()) {
|
|
15955
|
+
break checkModules;
|
|
16149
15956
|
}
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
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
|
-
}
|
|
15957
|
+
size += module.magicString.toString().length;
|
|
15958
|
+
if (size > minChunkSize) {
|
|
15959
|
+
break checkModules;
|
|
16161
15960
|
}
|
|
16162
15961
|
}
|
|
15962
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
15963
|
+
continue;
|
|
16163
15964
|
}
|
|
15965
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
16164
15966
|
}
|
|
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;
|
|
16184
|
-
}
|
|
16185
|
-
closestChunk = targetChunk;
|
|
16186
|
-
closestChunkDistance = distance;
|
|
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);
|
|
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
|
-
}
|
|
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;
|
|
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;
|
|
15967
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
16243
15968
|
}
|
|
16244
15969
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16245
15970
|
let distance = 0;
|
|
@@ -16743,14 +16468,14 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
16743
16468
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
16744
16469
|
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
16745
16470
|
}
|
|
16746
|
-
bundle[finalFileName] = chunk.
|
|
16471
|
+
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
16747
16472
|
}
|
|
16748
16473
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
16749
16474
|
let updatedCode = hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code;
|
|
16750
16475
|
if (map) {
|
|
16751
16476
|
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
16752
16477
|
}
|
|
16753
|
-
bundle[fileName] = chunk.
|
|
16478
|
+
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
16754
16479
|
}
|
|
16755
16480
|
}
|
|
16756
16481
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -23293,8 +23018,7 @@ function getChunkFileName(file, facadeChunkByModule) {
|
|
|
23293
23018
|
return file.fileName;
|
|
23294
23019
|
}
|
|
23295
23020
|
if (facadeChunkByModule) {
|
|
23296
|
-
|
|
23297
|
-
return chunk.id || chunk.getFileName();
|
|
23021
|
+
return facadeChunkByModule.get(file.module).getFileName();
|
|
23298
23022
|
}
|
|
23299
23023
|
return error(errorChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
23300
23024
|
}
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED