rollup 3.6.1-0 → 3.7.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +117 -71
- 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 +117 -71
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/bin/rollup
CHANGED
package/dist/es/rollup.js
CHANGED
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.7.1-0
|
|
4
|
+
Thu, 08 Dec 2022 05:48:12 GMT - commit a3259be5f30c0b2c85c985459782207fb05f50c3
|
|
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.
|
|
19
|
+
var version$1 = "3.7.1-0";
|
|
20
20
|
|
|
21
21
|
var charToInteger = {};
|
|
22
22
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -5031,6 +5031,10 @@ const literalNumberMembers = assembleMemberDescriptions({
|
|
|
5031
5031
|
toPrecision: returnsString,
|
|
5032
5032
|
valueOf: returnsNumber
|
|
5033
5033
|
}, objectMembers);
|
|
5034
|
+
const literalRegExpMembers = assembleMemberDescriptions({
|
|
5035
|
+
exec: returnsUnknown,
|
|
5036
|
+
test: returnsBoolean
|
|
5037
|
+
}, objectMembers);
|
|
5034
5038
|
const literalStringMembers = assembleMemberDescriptions({
|
|
5035
5039
|
anchor: returnsString,
|
|
5036
5040
|
at: returnsUnknown,
|
|
@@ -5082,6 +5086,9 @@ const literalStringMembers = assembleMemberDescriptions({
|
|
|
5082
5086
|
valueOf: returnsString
|
|
5083
5087
|
}, objectMembers);
|
|
5084
5088
|
function getLiteralMembersForValue(value) {
|
|
5089
|
+
if (value instanceof RegExp) {
|
|
5090
|
+
return literalRegExpMembers;
|
|
5091
|
+
}
|
|
5085
5092
|
switch (typeof value) {
|
|
5086
5093
|
case 'boolean': {
|
|
5087
5094
|
return literalBooleanMembers;
|
|
@@ -15860,19 +15867,15 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
|
|
|
15860
15867
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
15861
15868
|
chunkDefinitions.push({ alias, modules });
|
|
15862
15869
|
}
|
|
15863
|
-
const
|
|
15864
|
-
const
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
assignEntryToStaticDependencies(entry, undefined, assignedEntryPointsByModule, modulesInManualChunks);
|
|
15868
|
-
}
|
|
15869
|
-
}
|
|
15870
|
-
for (const entry of alreadyLoadedModulesByDynamicEntry.keys()) {
|
|
15870
|
+
const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry } = analyzeModuleGraph(entries);
|
|
15871
|
+
const staticEntries = new Set(entries);
|
|
15872
|
+
const assignedEntriesByModule = new Map();
|
|
15873
|
+
for (const entry of allEntries) {
|
|
15871
15874
|
if (!modulesInManualChunks.has(entry)) {
|
|
15872
|
-
assignEntryToStaticDependencies(entry,
|
|
15875
|
+
assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry);
|
|
15873
15876
|
}
|
|
15874
15877
|
}
|
|
15875
|
-
chunkDefinitions.push(...createChunks(
|
|
15878
|
+
chunkDefinitions.push(...createChunks(allEntries, assignedEntriesByModule, minChunkSize));
|
|
15876
15879
|
return chunkDefinitions;
|
|
15877
15880
|
}
|
|
15878
15881
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -15887,80 +15890,67 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
|
|
|
15887
15890
|
}
|
|
15888
15891
|
}
|
|
15889
15892
|
}
|
|
15890
|
-
function
|
|
15891
|
-
const
|
|
15892
|
-
const
|
|
15893
|
-
const
|
|
15894
|
-
const
|
|
15895
|
-
const entriesToHandle = new Set(entryModules);
|
|
15896
|
-
for (const currentEntry of entriesToHandle) {
|
|
15893
|
+
function analyzeModuleGraph(entries) {
|
|
15894
|
+
const dynamicEntries = new Set();
|
|
15895
|
+
const dependentEntriesByModule = new Map();
|
|
15896
|
+
const allEntries = new Set(entries);
|
|
15897
|
+
for (const currentEntry of allEntries) {
|
|
15897
15898
|
const modulesToHandle = new Set([currentEntry]);
|
|
15898
|
-
const dynamicImports = new Set();
|
|
15899
|
-
dynamicImportsByEntry.set(currentEntry, dynamicImports);
|
|
15900
15899
|
for (const module of modulesToHandle) {
|
|
15901
|
-
getOrCreate(
|
|
15900
|
+
getOrCreate(dependentEntriesByModule, module, getNewSet).add(currentEntry);
|
|
15902
15901
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
15903
15902
|
if (!(dependency instanceof ExternalModule)) {
|
|
15904
15903
|
modulesToHandle.add(dependency);
|
|
15905
|
-
allModules.add(dependency);
|
|
15906
15904
|
}
|
|
15907
15905
|
}
|
|
15908
15906
|
for (const { resolution } of module.dynamicImports) {
|
|
15909
|
-
if (resolution instanceof Module &&
|
|
15910
|
-
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
|
|
15907
|
+
if (resolution instanceof Module &&
|
|
15908
|
+
resolution.includedDynamicImporters.length > 0 &&
|
|
15909
|
+
!allEntries.has(resolution)) {
|
|
15910
|
+
dynamicEntries.add(resolution);
|
|
15911
|
+
allEntries.add(resolution);
|
|
15914
15912
|
}
|
|
15915
15913
|
}
|
|
15916
15914
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15915
|
+
if (!allEntries.has(dependency)) {
|
|
15916
|
+
dynamicEntries.add(dependency);
|
|
15917
|
+
allEntries.add(dependency);
|
|
15918
|
+
}
|
|
15921
15919
|
}
|
|
15922
15920
|
}
|
|
15923
15921
|
}
|
|
15924
|
-
return
|
|
15922
|
+
return {
|
|
15923
|
+
allEntries,
|
|
15924
|
+
dependentEntriesByModule,
|
|
15925
|
+
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
|
|
15926
|
+
};
|
|
15925
15927
|
}
|
|
15926
|
-
function
|
|
15927
|
-
const
|
|
15928
|
-
for (const dynamicEntry of
|
|
15929
|
-
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
15934
|
-
const
|
|
15935
|
-
|
|
15936
|
-
const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
|
|
15937
|
-
if (alreadyLoadedModules.has(module)) {
|
|
15938
|
-
continue;
|
|
15939
|
-
}
|
|
15940
|
-
for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
|
|
15941
|
-
if (!(dependentEntryPoints.has(siblingDependentEntry) ||
|
|
15942
|
-
alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
|
|
15943
|
-
continue nextDynamicEntry;
|
|
15944
|
-
}
|
|
15945
|
-
}
|
|
15946
|
-
alreadyLoadedModules.add(module);
|
|
15947
|
-
dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
|
|
15928
|
+
function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries) {
|
|
15929
|
+
const dynamicallyDependentEntriesByDynamicEntry = new Map();
|
|
15930
|
+
for (const dynamicEntry of dynamicEntries) {
|
|
15931
|
+
const dynamicDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntry, getNewSet);
|
|
15932
|
+
for (const importer of [
|
|
15933
|
+
...dynamicEntry.includedDynamicImporters,
|
|
15934
|
+
...dynamicEntry.implicitlyLoadedAfter
|
|
15935
|
+
]) {
|
|
15936
|
+
for (const entry of dependentEntriesByModule.get(importer)) {
|
|
15937
|
+
dynamicDependentEntries.add(entry);
|
|
15948
15938
|
}
|
|
15949
15939
|
}
|
|
15950
15940
|
}
|
|
15951
|
-
return
|
|
15941
|
+
return dynamicallyDependentEntriesByDynamicEntry;
|
|
15952
15942
|
}
|
|
15953
|
-
function assignEntryToStaticDependencies(entry,
|
|
15943
|
+
function assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry) {
|
|
15944
|
+
const dynamicDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
|
|
15954
15945
|
const modulesToHandle = new Set([entry]);
|
|
15955
15946
|
for (const module of modulesToHandle) {
|
|
15956
|
-
const
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
if (alreadyLoadedModules?.has(module)) {
|
|
15947
|
+
const assignedEntries = getOrCreate(assignedEntriesByModule, module, getNewSet);
|
|
15948
|
+
if (dynamicDependentEntries &&
|
|
15949
|
+
areEntriesContainedOrDynamicallyDependent(dynamicDependentEntries, dependentEntriesByModule.get(module), staticEntries, dynamicallyDependentEntriesByDynamicEntry)) {
|
|
15960
15950
|
continue;
|
|
15961
15951
|
}
|
|
15962
15952
|
else {
|
|
15963
|
-
|
|
15953
|
+
assignedEntries.add(entry);
|
|
15964
15954
|
}
|
|
15965
15955
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
15966
15956
|
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
@@ -15969,8 +15959,30 @@ function assignEntryToStaticDependencies(entry, alreadyLoadedModules, assignedEn
|
|
|
15969
15959
|
}
|
|
15970
15960
|
}
|
|
15971
15961
|
}
|
|
15972
|
-
|
|
15973
|
-
|
|
15962
|
+
const MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES = 3;
|
|
15963
|
+
function areEntriesContainedOrDynamicallyDependent(entries, containedIn, staticEntries, dynamicallyDependentEntriesByDynamicEntry) {
|
|
15964
|
+
if (entries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
15965
|
+
return false;
|
|
15966
|
+
}
|
|
15967
|
+
const entriesToCheck = new Set(entries);
|
|
15968
|
+
for (const entry of entriesToCheck) {
|
|
15969
|
+
if (!containedIn.has(entry)) {
|
|
15970
|
+
if (staticEntries.has(entry)) {
|
|
15971
|
+
return false;
|
|
15972
|
+
}
|
|
15973
|
+
const dynamicallyDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
|
|
15974
|
+
if (dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
15975
|
+
return false;
|
|
15976
|
+
}
|
|
15977
|
+
for (const dependentEntry of dynamicallyDependentEntries) {
|
|
15978
|
+
entriesToCheck.add(dependentEntry);
|
|
15979
|
+
}
|
|
15980
|
+
}
|
|
15981
|
+
}
|
|
15982
|
+
return true;
|
|
15983
|
+
}
|
|
15984
|
+
function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
15985
|
+
const chunkModulesBySignature = getChunkModulesBySignature(assignedEntriesByModule, allEntries);
|
|
15974
15986
|
return minChunkSize === 0
|
|
15975
15987
|
? Object.values(chunkModulesBySignature).map(modules => ({
|
|
15976
15988
|
alias: null,
|
|
@@ -16003,13 +16015,14 @@ function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
|
16003
16015
|
----- pure side effects
|
|
16004
16016
|
small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
|
|
16005
16017
|
big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
|
|
16018
|
+
Unoptimized chunks contain ${getNumberOfCycles(chunkPartition)} cycles.
|
|
16006
16019
|
`);
|
|
16007
16020
|
console.log(`Trying to find merge targets for ${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`);
|
|
16008
16021
|
mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16009
|
-
console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\n`);
|
|
16022
|
+
console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
|
|
16010
16023
|
console.log(`Trying to find merge targets for ${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)}...`);
|
|
16011
16024
|
mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16012
|
-
console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\n`);
|
|
16025
|
+
console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
|
|
16013
16026
|
timeEnd('optimize chunks', 3);
|
|
16014
16027
|
const result = [
|
|
16015
16028
|
...chunkPartition.small.sideEffect,
|
|
@@ -16023,12 +16036,12 @@ small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.sma
|
|
|
16023
16036
|
const CHAR_DEPENDENT = 'X';
|
|
16024
16037
|
const CHAR_INDEPENDENT = '_';
|
|
16025
16038
|
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16026
|
-
function getChunkModulesBySignature(
|
|
16039
|
+
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16027
16040
|
const chunkModules = Object.create(null);
|
|
16028
|
-
for (const [module,
|
|
16041
|
+
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
16029
16042
|
let chunkSignature = '';
|
|
16030
|
-
for (const entry of
|
|
16031
|
-
chunkSignature +=
|
|
16043
|
+
for (const entry of allEntries) {
|
|
16044
|
+
chunkSignature += assignedEntries.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
16032
16045
|
}
|
|
16033
16046
|
const chunk = chunkModules[chunkSignature];
|
|
16034
16047
|
if (chunk) {
|
|
@@ -16079,6 +16092,36 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
|
|
|
16079
16092
|
small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
|
|
16080
16093
|
};
|
|
16081
16094
|
}
|
|
16095
|
+
function getNumberOfCycles(partition) {
|
|
16096
|
+
const parents = new Set();
|
|
16097
|
+
const analysedChunks = new Set();
|
|
16098
|
+
let cycles = 0;
|
|
16099
|
+
const analyseChunk = (chunk) => {
|
|
16100
|
+
for (const dependency of chunk.dependencies) {
|
|
16101
|
+
if (parents.has(dependency)) {
|
|
16102
|
+
if (!analysedChunks.has(dependency)) {
|
|
16103
|
+
cycles++;
|
|
16104
|
+
}
|
|
16105
|
+
continue;
|
|
16106
|
+
}
|
|
16107
|
+
parents.add(dependency);
|
|
16108
|
+
analyseChunk(dependency);
|
|
16109
|
+
}
|
|
16110
|
+
analysedChunks.add(chunk);
|
|
16111
|
+
};
|
|
16112
|
+
for (const chunk of [
|
|
16113
|
+
...partition.big.pure,
|
|
16114
|
+
...partition.big.sideEffect,
|
|
16115
|
+
...partition.small.pure,
|
|
16116
|
+
...partition.small.sideEffect
|
|
16117
|
+
]) {
|
|
16118
|
+
if (!parents.has(chunk)) {
|
|
16119
|
+
parents.add(chunk);
|
|
16120
|
+
analyseChunk(chunk);
|
|
16121
|
+
}
|
|
16122
|
+
}
|
|
16123
|
+
return cycles;
|
|
16124
|
+
}
|
|
16082
16125
|
function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
16083
16126
|
for (const chunks of chunkLists) {
|
|
16084
16127
|
chunks.sort(compareChunks);
|
|
@@ -16202,6 +16245,9 @@ function mergeSignatures(sourceSignature, targetSignature) {
|
|
|
16202
16245
|
}
|
|
16203
16246
|
return signature;
|
|
16204
16247
|
}
|
|
16248
|
+
function getNewSet() {
|
|
16249
|
+
return new Set();
|
|
16250
|
+
}
|
|
16205
16251
|
|
|
16206
16252
|
// ported from https://github.com/substack/node-commondir
|
|
16207
16253
|
function commondir(files) {
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.7.1-0
|
|
4
|
+
Thu, 08 Dec 2022 05:48:12 GMT - commit a3259be5f30c0b2c85c985459782207fb05f50c3
|
|
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.
|
|
34
|
+
var version$1 = "3.7.1-0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -5546,6 +5546,10 @@ const literalNumberMembers = assembleMemberDescriptions({
|
|
|
5546
5546
|
toPrecision: returnsString,
|
|
5547
5547
|
valueOf: returnsNumber
|
|
5548
5548
|
}, objectMembers);
|
|
5549
|
+
const literalRegExpMembers = assembleMemberDescriptions({
|
|
5550
|
+
exec: returnsUnknown,
|
|
5551
|
+
test: returnsBoolean
|
|
5552
|
+
}, objectMembers);
|
|
5549
5553
|
const literalStringMembers = assembleMemberDescriptions({
|
|
5550
5554
|
anchor: returnsString,
|
|
5551
5555
|
at: returnsUnknown,
|
|
@@ -5597,6 +5601,9 @@ const literalStringMembers = assembleMemberDescriptions({
|
|
|
5597
5601
|
valueOf: returnsString
|
|
5598
5602
|
}, objectMembers);
|
|
5599
5603
|
function getLiteralMembersForValue(value) {
|
|
5604
|
+
if (value instanceof RegExp) {
|
|
5605
|
+
return literalRegExpMembers;
|
|
5606
|
+
}
|
|
5600
5607
|
switch (typeof value) {
|
|
5601
5608
|
case 'boolean': {
|
|
5602
5609
|
return literalBooleanMembers;
|
|
@@ -16375,19 +16382,15 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
|
|
|
16375
16382
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
16376
16383
|
chunkDefinitions.push({ alias, modules });
|
|
16377
16384
|
}
|
|
16378
|
-
const
|
|
16379
|
-
const
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
assignEntryToStaticDependencies(entry, undefined, assignedEntryPointsByModule, modulesInManualChunks);
|
|
16383
|
-
}
|
|
16384
|
-
}
|
|
16385
|
-
for (const entry of alreadyLoadedModulesByDynamicEntry.keys()) {
|
|
16385
|
+
const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry } = analyzeModuleGraph(entries);
|
|
16386
|
+
const staticEntries = new Set(entries);
|
|
16387
|
+
const assignedEntriesByModule = new Map();
|
|
16388
|
+
for (const entry of allEntries) {
|
|
16386
16389
|
if (!modulesInManualChunks.has(entry)) {
|
|
16387
|
-
assignEntryToStaticDependencies(entry,
|
|
16390
|
+
assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry);
|
|
16388
16391
|
}
|
|
16389
16392
|
}
|
|
16390
|
-
chunkDefinitions.push(...createChunks(
|
|
16393
|
+
chunkDefinitions.push(...createChunks(allEntries, assignedEntriesByModule, minChunkSize));
|
|
16391
16394
|
return chunkDefinitions;
|
|
16392
16395
|
}
|
|
16393
16396
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -16402,80 +16405,67 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
|
|
|
16402
16405
|
}
|
|
16403
16406
|
}
|
|
16404
16407
|
}
|
|
16405
|
-
function
|
|
16406
|
-
const
|
|
16407
|
-
const
|
|
16408
|
-
const
|
|
16409
|
-
const
|
|
16410
|
-
const entriesToHandle = new Set(entryModules);
|
|
16411
|
-
for (const currentEntry of entriesToHandle) {
|
|
16408
|
+
function analyzeModuleGraph(entries) {
|
|
16409
|
+
const dynamicEntries = new Set();
|
|
16410
|
+
const dependentEntriesByModule = new Map();
|
|
16411
|
+
const allEntries = new Set(entries);
|
|
16412
|
+
for (const currentEntry of allEntries) {
|
|
16412
16413
|
const modulesToHandle = new Set([currentEntry]);
|
|
16413
|
-
const dynamicImports = new Set();
|
|
16414
|
-
dynamicImportsByEntry.set(currentEntry, dynamicImports);
|
|
16415
16414
|
for (const module of modulesToHandle) {
|
|
16416
|
-
getOrCreate(
|
|
16415
|
+
getOrCreate(dependentEntriesByModule, module, getNewSet).add(currentEntry);
|
|
16417
16416
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16418
16417
|
if (!(dependency instanceof ExternalModule)) {
|
|
16419
16418
|
modulesToHandle.add(dependency);
|
|
16420
|
-
allModules.add(dependency);
|
|
16421
16419
|
}
|
|
16422
16420
|
}
|
|
16423
16421
|
for (const { resolution } of module.dynamicImports) {
|
|
16424
|
-
if (resolution instanceof Module &&
|
|
16425
|
-
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
|
|
16422
|
+
if (resolution instanceof Module &&
|
|
16423
|
+
resolution.includedDynamicImporters.length > 0 &&
|
|
16424
|
+
!allEntries.has(resolution)) {
|
|
16425
|
+
dynamicEntries.add(resolution);
|
|
16426
|
+
allEntries.add(resolution);
|
|
16429
16427
|
}
|
|
16430
16428
|
}
|
|
16431
16429
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
16432
|
-
|
|
16433
|
-
|
|
16434
|
-
|
|
16435
|
-
|
|
16430
|
+
if (!allEntries.has(dependency)) {
|
|
16431
|
+
dynamicEntries.add(dependency);
|
|
16432
|
+
allEntries.add(dependency);
|
|
16433
|
+
}
|
|
16436
16434
|
}
|
|
16437
16435
|
}
|
|
16438
16436
|
}
|
|
16439
|
-
return
|
|
16437
|
+
return {
|
|
16438
|
+
allEntries,
|
|
16439
|
+
dependentEntriesByModule,
|
|
16440
|
+
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
|
|
16441
|
+
};
|
|
16440
16442
|
}
|
|
16441
|
-
function
|
|
16442
|
-
const
|
|
16443
|
-
for (const dynamicEntry of
|
|
16444
|
-
|
|
16445
|
-
|
|
16446
|
-
|
|
16447
|
-
|
|
16448
|
-
|
|
16449
|
-
const
|
|
16450
|
-
|
|
16451
|
-
const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
|
|
16452
|
-
if (alreadyLoadedModules.has(module)) {
|
|
16453
|
-
continue;
|
|
16454
|
-
}
|
|
16455
|
-
for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
|
|
16456
|
-
if (!(dependentEntryPoints.has(siblingDependentEntry) ||
|
|
16457
|
-
alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
|
|
16458
|
-
continue nextDynamicEntry;
|
|
16459
|
-
}
|
|
16460
|
-
}
|
|
16461
|
-
alreadyLoadedModules.add(module);
|
|
16462
|
-
dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
|
|
16443
|
+
function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries) {
|
|
16444
|
+
const dynamicallyDependentEntriesByDynamicEntry = new Map();
|
|
16445
|
+
for (const dynamicEntry of dynamicEntries) {
|
|
16446
|
+
const dynamicDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntry, getNewSet);
|
|
16447
|
+
for (const importer of [
|
|
16448
|
+
...dynamicEntry.includedDynamicImporters,
|
|
16449
|
+
...dynamicEntry.implicitlyLoadedAfter
|
|
16450
|
+
]) {
|
|
16451
|
+
for (const entry of dependentEntriesByModule.get(importer)) {
|
|
16452
|
+
dynamicDependentEntries.add(entry);
|
|
16463
16453
|
}
|
|
16464
16454
|
}
|
|
16465
16455
|
}
|
|
16466
|
-
return
|
|
16456
|
+
return dynamicallyDependentEntriesByDynamicEntry;
|
|
16467
16457
|
}
|
|
16468
|
-
function assignEntryToStaticDependencies(entry,
|
|
16458
|
+
function assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry) {
|
|
16459
|
+
const dynamicDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
|
|
16469
16460
|
const modulesToHandle = new Set([entry]);
|
|
16470
16461
|
for (const module of modulesToHandle) {
|
|
16471
|
-
const
|
|
16472
|
-
|
|
16473
|
-
|
|
16474
|
-
if (alreadyLoadedModules?.has(module)) {
|
|
16462
|
+
const assignedEntries = getOrCreate(assignedEntriesByModule, module, getNewSet);
|
|
16463
|
+
if (dynamicDependentEntries &&
|
|
16464
|
+
areEntriesContainedOrDynamicallyDependent(dynamicDependentEntries, dependentEntriesByModule.get(module), staticEntries, dynamicallyDependentEntriesByDynamicEntry)) {
|
|
16475
16465
|
continue;
|
|
16476
16466
|
}
|
|
16477
16467
|
else {
|
|
16478
|
-
|
|
16468
|
+
assignedEntries.add(entry);
|
|
16479
16469
|
}
|
|
16480
16470
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16481
16471
|
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
@@ -16484,8 +16474,30 @@ function assignEntryToStaticDependencies(entry, alreadyLoadedModules, assignedEn
|
|
|
16484
16474
|
}
|
|
16485
16475
|
}
|
|
16486
16476
|
}
|
|
16487
|
-
|
|
16488
|
-
|
|
16477
|
+
const MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES = 3;
|
|
16478
|
+
function areEntriesContainedOrDynamicallyDependent(entries, containedIn, staticEntries, dynamicallyDependentEntriesByDynamicEntry) {
|
|
16479
|
+
if (entries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
16480
|
+
return false;
|
|
16481
|
+
}
|
|
16482
|
+
const entriesToCheck = new Set(entries);
|
|
16483
|
+
for (const entry of entriesToCheck) {
|
|
16484
|
+
if (!containedIn.has(entry)) {
|
|
16485
|
+
if (staticEntries.has(entry)) {
|
|
16486
|
+
return false;
|
|
16487
|
+
}
|
|
16488
|
+
const dynamicallyDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
|
|
16489
|
+
if (dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
16490
|
+
return false;
|
|
16491
|
+
}
|
|
16492
|
+
for (const dependentEntry of dynamicallyDependentEntries) {
|
|
16493
|
+
entriesToCheck.add(dependentEntry);
|
|
16494
|
+
}
|
|
16495
|
+
}
|
|
16496
|
+
}
|
|
16497
|
+
return true;
|
|
16498
|
+
}
|
|
16499
|
+
function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
16500
|
+
const chunkModulesBySignature = getChunkModulesBySignature(assignedEntriesByModule, allEntries);
|
|
16489
16501
|
return minChunkSize === 0
|
|
16490
16502
|
? Object.values(chunkModulesBySignature).map(modules => ({
|
|
16491
16503
|
alias: null,
|
|
@@ -16518,13 +16530,14 @@ function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
|
16518
16530
|
----- pure side effects
|
|
16519
16531
|
small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
|
|
16520
16532
|
big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
|
|
16533
|
+
Unoptimized chunks contain ${getNumberOfCycles(chunkPartition)} cycles.
|
|
16521
16534
|
`);
|
|
16522
16535
|
console.log(`Trying to find merge targets for ${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`);
|
|
16523
16536
|
mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16524
|
-
console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\n`);
|
|
16537
|
+
console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
|
|
16525
16538
|
console.log(`Trying to find merge targets for ${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)}...`);
|
|
16526
16539
|
mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16527
|
-
console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\n`);
|
|
16540
|
+
console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
|
|
16528
16541
|
timeEnd('optimize chunks', 3);
|
|
16529
16542
|
const result = [
|
|
16530
16543
|
...chunkPartition.small.sideEffect,
|
|
@@ -16538,12 +16551,12 @@ small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.sma
|
|
|
16538
16551
|
const CHAR_DEPENDENT = 'X';
|
|
16539
16552
|
const CHAR_INDEPENDENT = '_';
|
|
16540
16553
|
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16541
|
-
function getChunkModulesBySignature(
|
|
16554
|
+
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16542
16555
|
const chunkModules = Object.create(null);
|
|
16543
|
-
for (const [module,
|
|
16556
|
+
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
16544
16557
|
let chunkSignature = '';
|
|
16545
|
-
for (const entry of
|
|
16546
|
-
chunkSignature +=
|
|
16558
|
+
for (const entry of allEntries) {
|
|
16559
|
+
chunkSignature += assignedEntries.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
16547
16560
|
}
|
|
16548
16561
|
const chunk = chunkModules[chunkSignature];
|
|
16549
16562
|
if (chunk) {
|
|
@@ -16594,6 +16607,36 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
|
|
|
16594
16607
|
small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
|
|
16595
16608
|
};
|
|
16596
16609
|
}
|
|
16610
|
+
function getNumberOfCycles(partition) {
|
|
16611
|
+
const parents = new Set();
|
|
16612
|
+
const analysedChunks = new Set();
|
|
16613
|
+
let cycles = 0;
|
|
16614
|
+
const analyseChunk = (chunk) => {
|
|
16615
|
+
for (const dependency of chunk.dependencies) {
|
|
16616
|
+
if (parents.has(dependency)) {
|
|
16617
|
+
if (!analysedChunks.has(dependency)) {
|
|
16618
|
+
cycles++;
|
|
16619
|
+
}
|
|
16620
|
+
continue;
|
|
16621
|
+
}
|
|
16622
|
+
parents.add(dependency);
|
|
16623
|
+
analyseChunk(dependency);
|
|
16624
|
+
}
|
|
16625
|
+
analysedChunks.add(chunk);
|
|
16626
|
+
};
|
|
16627
|
+
for (const chunk of [
|
|
16628
|
+
...partition.big.pure,
|
|
16629
|
+
...partition.big.sideEffect,
|
|
16630
|
+
...partition.small.pure,
|
|
16631
|
+
...partition.small.sideEffect
|
|
16632
|
+
]) {
|
|
16633
|
+
if (!parents.has(chunk)) {
|
|
16634
|
+
parents.add(chunk);
|
|
16635
|
+
analyseChunk(chunk);
|
|
16636
|
+
}
|
|
16637
|
+
}
|
|
16638
|
+
return cycles;
|
|
16639
|
+
}
|
|
16597
16640
|
function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
16598
16641
|
for (const chunks of chunkLists) {
|
|
16599
16642
|
chunks.sort(compareChunks);
|
|
@@ -16717,6 +16760,9 @@ function mergeSignatures(sourceSignature, targetSignature) {
|
|
|
16717
16760
|
}
|
|
16718
16761
|
return signature;
|
|
16719
16762
|
}
|
|
16763
|
+
function getNewSet() {
|
|
16764
|
+
return new Set();
|
|
16765
|
+
}
|
|
16720
16766
|
|
|
16721
16767
|
// ported from https://github.com/substack/node-commondir
|
|
16722
16768
|
function commondir(files) {
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED