rollup 3.16.0 → 3.17.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 +5 -4
- package/dist/es/rollup.js +3 -3
- package/dist/es/shared/{rollup.js → node-entry.js} +265 -109
- package/dist/es/shared/watch.js +3 -3
- package/dist/loadConfigFile.js +3 -3
- package/dist/rollup.d.ts +2 -0
- package/dist/rollup.js +7 -5
- package/dist/shared/fsevents-importer.js +37 -0
- package/dist/shared/index.js +4 -3
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +270 -208
- package/dist/shared/watch-cli.js +6 -4
- package/dist/shared/watch-proxy.js +87 -0
- package/dist/shared/watch.js +4 -3
- package/package.json +2 -2
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.17.0
|
|
4
|
+
Sat, 18 Feb 2023 05:06:04 GMT - commit 0c33497a7de91e150a7d242125e8da9dd4e4a3ac
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
+
const process$1 = require('node:process');
|
|
13
|
+
const tty = require('tty');
|
|
12
14
|
const node_path = require('node:path');
|
|
13
15
|
const require$$0$1 = require('path');
|
|
14
|
-
const process$1 = require('node:process');
|
|
15
16
|
const node_perf_hooks = require('node:perf_hooks');
|
|
16
17
|
const node_crypto = require('node:crypto');
|
|
17
18
|
const promises = require('node:fs/promises');
|
|
18
19
|
const node_events = require('node:events');
|
|
19
|
-
const tty = require('tty');
|
|
20
20
|
|
|
21
21
|
function _interopNamespaceDefault(e) {
|
|
22
22
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -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.17.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -59,6 +59,7 @@ const URL_OUTPUT_EXPORTS = 'configuration-options/#output-exports';
|
|
|
59
59
|
const URL_OUTPUT_EXTEND = 'configuration-options/#output-extend';
|
|
60
60
|
const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
|
|
61
61
|
const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
|
|
62
|
+
const URL_OUTPUT_EXPERIMENTALDEEPCHUNKOPTIMIZATION = 'configuration-options/#output-experimentaldeepdynamicchunkoptimization';
|
|
62
63
|
const URL_OUTPUT_GENERATEDCODE_CONSTBINDINGS = 'configuration-options/#output-generatedcode-constbindings';
|
|
63
64
|
const URL_OUTPUT_GENERATEDCODE_SYMBOLS = 'configuration-options/#output-generatedcode-symbols';
|
|
64
65
|
const URL_OUTPUT_GLOBALS = 'configuration-options/#output-globals';
|
|
@@ -1124,29 +1125,6 @@ async function mergeOutputOptions(config, overrides, warn) {
|
|
|
1124
1125
|
return outputOptions;
|
|
1125
1126
|
}
|
|
1126
1127
|
|
|
1127
|
-
let fsEvents;
|
|
1128
|
-
let fsEventsImportError;
|
|
1129
|
-
async function loadFsEvents() {
|
|
1130
|
-
try {
|
|
1131
|
-
({ default: fsEvents } = await import('fsevents'));
|
|
1132
|
-
}
|
|
1133
|
-
catch (error) {
|
|
1134
|
-
fsEventsImportError = error;
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
// A call to this function will be injected into the chokidar code
|
|
1138
|
-
function getFsEvents() {
|
|
1139
|
-
if (fsEventsImportError)
|
|
1140
|
-
throw fsEventsImportError;
|
|
1141
|
-
return fsEvents;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
const fseventsImporter = /*#__PURE__*/Object.defineProperty({
|
|
1145
|
-
__proto__: null,
|
|
1146
|
-
getFsEvents,
|
|
1147
|
-
loadFsEvents
|
|
1148
|
-
}, Symbol.toStringTag, { value: 'Module' });
|
|
1149
|
-
|
|
1150
1128
|
const {
|
|
1151
1129
|
env = {},
|
|
1152
1130
|
argv = [],
|
|
@@ -3006,7 +2984,7 @@ class DiscriminatedPathTracker {
|
|
|
3006
2984
|
currentPaths[pathSegment] ||
|
|
3007
2985
|
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
3008
2986
|
}
|
|
3009
|
-
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, getNewSet);
|
|
2987
|
+
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
3010
2988
|
if (trackedEntities.has(entity))
|
|
3011
2989
|
return true;
|
|
3012
2990
|
trackedEntities.add(entity);
|
|
@@ -13486,7 +13464,7 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
|
|
|
13486
13464
|
});
|
|
13487
13465
|
}
|
|
13488
13466
|
function getAndExtendSideEffectModules(variable, module) {
|
|
13489
|
-
const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, getNewSet);
|
|
13467
|
+
const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, (getNewSet));
|
|
13490
13468
|
let currentVariable = variable;
|
|
13491
13469
|
const referencedVariables = new Set([currentVariable]);
|
|
13492
13470
|
while (true) {
|
|
@@ -13825,7 +13803,7 @@ class Module {
|
|
|
13825
13803
|
searchedNamesAndModules
|
|
13826
13804
|
});
|
|
13827
13805
|
if (importerForSideEffects) {
|
|
13828
|
-
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, getNewSet).add(this);
|
|
13806
|
+
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, (getNewSet)).add(this);
|
|
13829
13807
|
setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
|
|
13830
13808
|
}
|
|
13831
13809
|
return [variable];
|
|
@@ -16579,7 +16557,137 @@ function* concatLazy(iterables) {
|
|
|
16579
16557
|
}
|
|
16580
16558
|
}
|
|
16581
16559
|
|
|
16582
|
-
|
|
16560
|
+
/**
|
|
16561
|
+
* At its core, the algorithm first starts from each static or dynamic entry
|
|
16562
|
+
* point and then assigns that entry point to all modules than can be reached
|
|
16563
|
+
* via static imports. We call this the *dependent entry points* of that
|
|
16564
|
+
* module.
|
|
16565
|
+
*
|
|
16566
|
+
* Then we group all modules with the same dependent entry points into chunks
|
|
16567
|
+
* as those modules will always be loaded together.
|
|
16568
|
+
*
|
|
16569
|
+
* One non-trivial optimization we can apply is that dynamic entries are
|
|
16570
|
+
* different from static entries in so far as when a dynamic import occurs,
|
|
16571
|
+
* some
|
|
16572
|
+
* modules are already in memory. If some of these modules are also
|
|
16573
|
+
* dependencies
|
|
16574
|
+
* of the dynamic entry, then it does not make sense to create a separate chunk
|
|
16575
|
+
* for them. Instead, the dynamic import target can load them from the
|
|
16576
|
+
* importing
|
|
16577
|
+
* chunk.
|
|
16578
|
+
*
|
|
16579
|
+
* With regard to chunking, if B is implicitly loaded after A, then this can be
|
|
16580
|
+
* handled the same way as if there was a dynamic import A => B.
|
|
16581
|
+
*
|
|
16582
|
+
* Example:
|
|
16583
|
+
* Assume A -> B (A imports B), A => C (A dynamically imports C) and C -> B.
|
|
16584
|
+
* Then the initial algorithm would assign A into the A chunk, C into the C
|
|
16585
|
+
* chunk and B into the AC chunk, i.e. the chunk with the dependent entry
|
|
16586
|
+
* points
|
|
16587
|
+
* A and C.
|
|
16588
|
+
* However we know that C can only be loaded from A, so A and its dependency B
|
|
16589
|
+
* must already be in memory when C is loaded. So it is enough to create only
|
|
16590
|
+
* two chunks A containing [AB] and C containing [C].
|
|
16591
|
+
*
|
|
16592
|
+
* So we do not assign the dynamic entry C as dependent entry point to modules
|
|
16593
|
+
* that are already loaded.
|
|
16594
|
+
*
|
|
16595
|
+
* In a more complex example, let us assume that we have entry points X and Y.
|
|
16596
|
+
* Further, let us assume
|
|
16597
|
+
* X -> A, X -> B, X -> C,
|
|
16598
|
+
* Y -> A, Y -> B,
|
|
16599
|
+
* A => D,
|
|
16600
|
+
* D -> B, D -> C
|
|
16601
|
+
* So without dynamic import optimization, the dependent entry points are
|
|
16602
|
+
* A: XY, B: DXY, C: DX, D: D, X: X, Y: Y,
|
|
16603
|
+
* so we would for now create six chunks.
|
|
16604
|
+
*
|
|
16605
|
+
* Now D is loaded only after A is loaded. But A is loaded if either X is
|
|
16606
|
+
* loaded
|
|
16607
|
+
* or Y is loaded. So the modules that are already in memory when D is loaded
|
|
16608
|
+
* are the intersection of all modules that X depends on with all modules that
|
|
16609
|
+
* Y
|
|
16610
|
+
* depends on, which in this case are the modules A and B.
|
|
16611
|
+
* We could also say they are all modules that have both X and Y as dependent
|
|
16612
|
+
* entry points.
|
|
16613
|
+
*
|
|
16614
|
+
* So we can remove D as dependent entry point from A and B, which means they
|
|
16615
|
+
* both now have only XY as dependent entry points and can be merged into the
|
|
16616
|
+
* same chunk.
|
|
16617
|
+
*
|
|
16618
|
+
* Now let us extend this to the most general case where we have several
|
|
16619
|
+
* dynamic
|
|
16620
|
+
* importers for one dynamic entry point.
|
|
16621
|
+
*
|
|
16622
|
+
* In the most general form, it works like this:
|
|
16623
|
+
* For each dynamic entry point, we have a number of dynamic importers, which
|
|
16624
|
+
* are the modules importing it. Using the previous ideas, we can determine
|
|
16625
|
+
* the modules already in memory for each dynamic importer by looking for all
|
|
16626
|
+
* modules that have all the dependent entry points of the dynamic importer as
|
|
16627
|
+
* dependent entry points.
|
|
16628
|
+
* So the modules that are guaranteed to be in memory when the dynamic entry
|
|
16629
|
+
* point is loaded are the intersection of the modules already in memory for
|
|
16630
|
+
* each dynamic importer.
|
|
16631
|
+
*
|
|
16632
|
+
* Assuming that A => D and B => D and A has dependent entry points XY and B
|
|
16633
|
+
* has
|
|
16634
|
+
* dependent entry points YZ, then the modules guaranteed to be in memory are
|
|
16635
|
+
* all modules that have at least XYZ as dependent entry points.
|
|
16636
|
+
* We call XYZ the *dynamically dependent entry points* of D.
|
|
16637
|
+
*
|
|
16638
|
+
* Now there is one last case to consider: If one of the dynamically dependent
|
|
16639
|
+
* entries is itself a dynamic entry, then any module is in memory that either
|
|
16640
|
+
* is a dependency of that dynamic entry or again has the dynamic dependent
|
|
16641
|
+
* entries of that dynamic entry as dependent entry points.
|
|
16642
|
+
*
|
|
16643
|
+
* A naive algorithm for this proved to be costly as it contained an O(n^3)
|
|
16644
|
+
* complexity with regard to dynamic entries that blew up for very large
|
|
16645
|
+
* projects.
|
|
16646
|
+
*
|
|
16647
|
+
* If we have an efficient way to do Set operations, an alternative approach
|
|
16648
|
+
* would be to instead collect already loaded modules per dynamic entry. And as
|
|
16649
|
+
* all chunks from the initial grouping would behave the same, we can instead
|
|
16650
|
+
* collect already loaded chunks for a performance improvement.
|
|
16651
|
+
*
|
|
16652
|
+
* To do that efficiently, need
|
|
16653
|
+
* - a Map of dynamic imports per dynamic entry, which contains all dynamic
|
|
16654
|
+
* imports that can be triggered by a dynamic entry
|
|
16655
|
+
* - a Map of static dependencies per entry
|
|
16656
|
+
* - a Map of already loaded chunks per entry that we initially populate with
|
|
16657
|
+
* empty Sets for static entries and Sets containing all entries for dynamic
|
|
16658
|
+
* entries
|
|
16659
|
+
*
|
|
16660
|
+
* For efficient operations, we assign each entry a numerical index and
|
|
16661
|
+
* represent Sets of Chunks as BigInt values where each chunk corresponds to a
|
|
16662
|
+
* bit index. Then thw last two maps can be represented as arrays of BigInt
|
|
16663
|
+
* values.
|
|
16664
|
+
*
|
|
16665
|
+
* Then we iterate through each dynamic entry. We set the already loaded modules
|
|
16666
|
+
* to the intersection of the previously already loaded modules with the union
|
|
16667
|
+
* of the already loaded modules of that chunk with its static dependencies.
|
|
16668
|
+
*
|
|
16669
|
+
* If the already loaded modules changed, then we use the Map of dynamic imports
|
|
16670
|
+
* per dynamic entry to marks all dynamic entry dependencies as "dirty" and put
|
|
16671
|
+
* them back into the iteration. As an additional optimization, we note for
|
|
16672
|
+
* each dynamic entry which dynamic dependent entries have changed and only
|
|
16673
|
+
* intersect those entries again on subsequent interations.
|
|
16674
|
+
*
|
|
16675
|
+
* Then we remove the dynamic entries from the list of dependent entries for
|
|
16676
|
+
* those chunks that are already loaded for that dynamic entry and create
|
|
16677
|
+
* another round of chunks.
|
|
16678
|
+
*/
|
|
16679
|
+
function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
|
|
16680
|
+
const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
|
|
16681
|
+
const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
|
|
16682
|
+
// Each chunk is identified by its position in this array
|
|
16683
|
+
const initialChunks = Object.values(getChunksBySignature(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks)));
|
|
16684
|
+
// This mutates initialChunks but also clears
|
|
16685
|
+
// dynamicallyDependentEntriesByDynamicEntry as side effect
|
|
16686
|
+
removeUnnecessaryDependentEntries(initialChunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
|
|
16687
|
+
chunkDefinitions.push(...createChunks(allEntries, getChunksBySignature(initialChunks), minChunkSize));
|
|
16688
|
+
return chunkDefinitions;
|
|
16689
|
+
}
|
|
16690
|
+
function getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry) {
|
|
16583
16691
|
const chunkDefinitions = [];
|
|
16584
16692
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
16585
16693
|
const manualChunkModulesByAlias = Object.create(null);
|
|
@@ -16589,16 +16697,7 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, dee
|
|
|
16589
16697
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
16590
16698
|
chunkDefinitions.push({ alias, modules });
|
|
16591
16699
|
}
|
|
16592
|
-
|
|
16593
|
-
const staticEntries = new Set(entries);
|
|
16594
|
-
const assignedEntriesByModule = new Map();
|
|
16595
|
-
for (const entry of allEntries) {
|
|
16596
|
-
if (!modulesInManualChunks.has(entry)) {
|
|
16597
|
-
assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization);
|
|
16598
|
-
}
|
|
16599
|
-
}
|
|
16600
|
-
chunkDefinitions.push(...createChunks(allEntries, assignedEntriesByModule, minChunkSize));
|
|
16601
|
-
return chunkDefinitions;
|
|
16700
|
+
return { chunkDefinitions, modulesInManualChunks };
|
|
16602
16701
|
}
|
|
16603
16702
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
16604
16703
|
const modulesToHandle = new Set([entry]);
|
|
@@ -16613,13 +16712,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
|
|
|
16613
16712
|
}
|
|
16614
16713
|
}
|
|
16615
16714
|
function analyzeModuleGraph(entries) {
|
|
16616
|
-
const
|
|
16715
|
+
const dynamicEntryModules = new Set();
|
|
16617
16716
|
const dependentEntriesByModule = new Map();
|
|
16618
|
-
const
|
|
16619
|
-
|
|
16717
|
+
const dynamicImportModulesByEntry = [];
|
|
16718
|
+
const allEntriesSet = new Set(entries);
|
|
16719
|
+
let entryIndex = 0;
|
|
16720
|
+
for (const currentEntry of allEntriesSet) {
|
|
16721
|
+
const dynamicImportsForCurrentEntry = new Set();
|
|
16722
|
+
dynamicImportModulesByEntry.push(dynamicImportsForCurrentEntry);
|
|
16620
16723
|
const modulesToHandle = new Set([currentEntry]);
|
|
16621
16724
|
for (const module of modulesToHandle) {
|
|
16622
|
-
getOrCreate(dependentEntriesByModule, module, getNewSet).add(
|
|
16725
|
+
getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
|
|
16623
16726
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16624
16727
|
if (!(dependency instanceof ExternalModule)) {
|
|
16625
16728
|
modulesToHandle.add(dependency);
|
|
@@ -16628,33 +16731,58 @@ function analyzeModuleGraph(entries) {
|
|
|
16628
16731
|
for (const { resolution } of module.dynamicImports) {
|
|
16629
16732
|
if (resolution instanceof Module &&
|
|
16630
16733
|
resolution.includedDynamicImporters.length > 0 &&
|
|
16631
|
-
!
|
|
16632
|
-
|
|
16633
|
-
|
|
16734
|
+
!allEntriesSet.has(resolution)) {
|
|
16735
|
+
dynamicEntryModules.add(resolution);
|
|
16736
|
+
allEntriesSet.add(resolution);
|
|
16737
|
+
dynamicImportsForCurrentEntry.add(resolution);
|
|
16634
16738
|
}
|
|
16635
16739
|
}
|
|
16636
16740
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
16637
|
-
if (!
|
|
16638
|
-
|
|
16639
|
-
|
|
16741
|
+
if (!allEntriesSet.has(dependency)) {
|
|
16742
|
+
dynamicEntryModules.add(dependency);
|
|
16743
|
+
allEntriesSet.add(dependency);
|
|
16640
16744
|
}
|
|
16641
16745
|
}
|
|
16642
16746
|
}
|
|
16747
|
+
entryIndex++;
|
|
16643
16748
|
}
|
|
16749
|
+
const allEntries = [...allEntriesSet];
|
|
16750
|
+
const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
|
|
16644
16751
|
return {
|
|
16645
|
-
allEntries
|
|
16752
|
+
allEntries,
|
|
16646
16753
|
dependentEntriesByModule,
|
|
16647
|
-
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
|
|
16754
|
+
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
|
|
16755
|
+
dynamicImportsByEntry
|
|
16648
16756
|
};
|
|
16649
16757
|
}
|
|
16650
|
-
function
|
|
16758
|
+
function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry) {
|
|
16759
|
+
const entryIndexByModule = new Map();
|
|
16760
|
+
const dynamicEntries = new Set();
|
|
16761
|
+
for (const [entryIndex, entry] of allEntries.entries()) {
|
|
16762
|
+
entryIndexByModule.set(entry, entryIndex);
|
|
16763
|
+
if (dynamicEntryModules.has(entry)) {
|
|
16764
|
+
dynamicEntries.add(entryIndex);
|
|
16765
|
+
}
|
|
16766
|
+
}
|
|
16767
|
+
const dynamicImportsByEntry = [];
|
|
16768
|
+
for (const dynamicImportModules of dynamicImportModulesByEntry) {
|
|
16769
|
+
const dynamicImports = new Set();
|
|
16770
|
+
for (const dynamicEntry of dynamicImportModules) {
|
|
16771
|
+
dynamicImports.add(entryIndexByModule.get(dynamicEntry));
|
|
16772
|
+
}
|
|
16773
|
+
dynamicImportsByEntry.push(dynamicImports);
|
|
16774
|
+
}
|
|
16775
|
+
return { dynamicEntries, dynamicImportsByEntry };
|
|
16776
|
+
}
|
|
16777
|
+
function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries) {
|
|
16651
16778
|
const dynamicallyDependentEntriesByDynamicEntry = new Map();
|
|
16652
|
-
for (const
|
|
16653
|
-
const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry,
|
|
16654
|
-
|
|
16655
|
-
|
|
16656
|
-
|
|
16657
|
-
|
|
16779
|
+
for (const dynamicEntryIndex of dynamicEntries) {
|
|
16780
|
+
const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntryIndex, (getNewSet));
|
|
16781
|
+
const dynamicEntry = allEntries[dynamicEntryIndex];
|
|
16782
|
+
for (const importer of concatLazy([
|
|
16783
|
+
dynamicEntry.includedDynamicImporters,
|
|
16784
|
+
dynamicEntry.implicitlyLoadedAfter
|
|
16785
|
+
])) {
|
|
16658
16786
|
for (const entry of dependentEntriesByModule.get(importer)) {
|
|
16659
16787
|
dynamicallyDependentEntries.add(entry);
|
|
16660
16788
|
}
|
|
@@ -16662,57 +16790,80 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
|
|
|
16662
16790
|
}
|
|
16663
16791
|
return dynamicallyDependentEntriesByDynamicEntry;
|
|
16664
16792
|
}
|
|
16665
|
-
function
|
|
16666
|
-
|
|
16667
|
-
const
|
|
16668
|
-
for (const
|
|
16669
|
-
|
|
16670
|
-
|
|
16671
|
-
|
|
16672
|
-
continue;
|
|
16673
|
-
}
|
|
16674
|
-
else {
|
|
16675
|
-
assignedEntries.add(entry);
|
|
16676
|
-
}
|
|
16677
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16678
|
-
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
16679
|
-
modulesToHandle.add(dependency);
|
|
16680
|
-
}
|
|
16793
|
+
function getChunksBySignature(modulesWithDependentEntries) {
|
|
16794
|
+
var _a;
|
|
16795
|
+
const chunkModules = Object.create(null);
|
|
16796
|
+
for (const { dependentEntries, modules } of modulesWithDependentEntries) {
|
|
16797
|
+
let chunkSignature = 0n;
|
|
16798
|
+
for (const entryIndex of dependentEntries) {
|
|
16799
|
+
chunkSignature |= 1n << BigInt(entryIndex);
|
|
16681
16800
|
}
|
|
16801
|
+
(chunkModules[_a = String(chunkSignature)] || (chunkModules[_a] = {
|
|
16802
|
+
dependentEntries: new Set(dependentEntries),
|
|
16803
|
+
modules: []
|
|
16804
|
+
})).modules.push(...modules);
|
|
16682
16805
|
}
|
|
16806
|
+
return chunkModules;
|
|
16683
16807
|
}
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
// -> Do not iterate by module but by equivalence group and merge chunks
|
|
16689
|
-
function isModuleAlreadyLoaded(dynamicallyDependentEntries, containedIn, staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization) {
|
|
16690
|
-
if (!deepChunkOptimization &&
|
|
16691
|
-
dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
16692
|
-
return false;
|
|
16693
|
-
}
|
|
16694
|
-
const entriesToCheck = new Set(dynamicallyDependentEntries);
|
|
16695
|
-
for (const entry of entriesToCheck) {
|
|
16696
|
-
if (!containedIn.has(entry)) {
|
|
16697
|
-
if (staticEntries.has(entry)) {
|
|
16698
|
-
return false;
|
|
16699
|
-
}
|
|
16700
|
-
const dynamicallyDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
|
|
16701
|
-
if (!deepChunkOptimization &&
|
|
16702
|
-
dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
16703
|
-
return false;
|
|
16704
|
-
}
|
|
16705
|
-
for (const dependentEntry of dynamicallyDependentEntries) {
|
|
16706
|
-
entriesToCheck.add(dependentEntry);
|
|
16707
|
-
}
|
|
16808
|
+
function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks) {
|
|
16809
|
+
for (const [module, dependentEntries] of dependentEntriesByModule) {
|
|
16810
|
+
if (!modulesInManualChunks.has(module)) {
|
|
16811
|
+
yield { dependentEntries, modules: [module] };
|
|
16708
16812
|
}
|
|
16709
16813
|
}
|
|
16710
|
-
return true;
|
|
16711
16814
|
}
|
|
16712
|
-
|
|
16713
|
-
|
|
16815
|
+
/**
|
|
16816
|
+
* This removes all unnecessary dynamic entries from the dependenEntries in its
|
|
16817
|
+
* first argument. It will also consume its second argument, so if
|
|
16818
|
+
* dynamicallyDependentEntriesByDynamicEntry is ever needed after this, we
|
|
16819
|
+
* should make a copy.
|
|
16820
|
+
*/
|
|
16821
|
+
function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
|
|
16822
|
+
// The indices correspond to the indices in allEntries. The chunks correspond
|
|
16823
|
+
// to bits in the bigint values where chunk 0 is the lowest bit.
|
|
16824
|
+
const staticDependenciesPerEntry = allEntries.map(() => 0n);
|
|
16825
|
+
const alreadyLoadedChunksPerEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
|
|
16826
|
+
// This toggles the bits for each chunk that is a dependency of an entry
|
|
16827
|
+
let chunkMask = 1n;
|
|
16828
|
+
for (const { dependentEntries } of chunks) {
|
|
16829
|
+
for (const entryIndex of dependentEntries) {
|
|
16830
|
+
staticDependenciesPerEntry[entryIndex] |= chunkMask;
|
|
16831
|
+
}
|
|
16832
|
+
chunkMask <<= 1n;
|
|
16833
|
+
}
|
|
16834
|
+
// Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
|
|
16835
|
+
// If we no longer want this, we should make a copy here.
|
|
16836
|
+
const updatedDynamicallyDependentEntriesByDynamicEntry = dynamicallyDependentEntriesByDynamicEntry;
|
|
16837
|
+
for (const [dynamicEntryIndex, updatedDynamicallyDependentEntries] of updatedDynamicallyDependentEntriesByDynamicEntry) {
|
|
16838
|
+
updatedDynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
|
|
16839
|
+
const previousLoadedModules = alreadyLoadedChunksPerEntry[dynamicEntryIndex];
|
|
16840
|
+
let newLoadedModules = previousLoadedModules;
|
|
16841
|
+
for (const entryIndex of updatedDynamicallyDependentEntries) {
|
|
16842
|
+
newLoadedModules &=
|
|
16843
|
+
staticDependenciesPerEntry[entryIndex] | alreadyLoadedChunksPerEntry[entryIndex];
|
|
16844
|
+
}
|
|
16845
|
+
if (newLoadedModules !== previousLoadedModules) {
|
|
16846
|
+
alreadyLoadedChunksPerEntry[dynamicEntryIndex] = newLoadedModules;
|
|
16847
|
+
for (const dynamicImport of dynamicImportsByEntry[dynamicEntryIndex]) {
|
|
16848
|
+
getOrCreate(updatedDynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
|
|
16849
|
+
}
|
|
16850
|
+
}
|
|
16851
|
+
}
|
|
16852
|
+
// Remove entries from dependent entries if a chunk is already loaded without
|
|
16853
|
+
// that entry.
|
|
16854
|
+
chunkMask = 1n;
|
|
16855
|
+
for (const { dependentEntries } of chunks) {
|
|
16856
|
+
for (const entryIndex of dependentEntries) {
|
|
16857
|
+
if ((alreadyLoadedChunksPerEntry[entryIndex] & chunkMask) === chunkMask) {
|
|
16858
|
+
dependentEntries.delete(entryIndex);
|
|
16859
|
+
}
|
|
16860
|
+
}
|
|
16861
|
+
chunkMask <<= 1n;
|
|
16862
|
+
}
|
|
16863
|
+
}
|
|
16864
|
+
function createChunks(allEntries, chunkModulesBySignature, minChunkSize) {
|
|
16714
16865
|
return minChunkSize === 0
|
|
16715
|
-
? Object.values(chunkModulesBySignature).map(modules => ({
|
|
16866
|
+
? Object.values(chunkModulesBySignature).map(({ modules }) => ({
|
|
16716
16867
|
alias: null,
|
|
16717
16868
|
modules
|
|
16718
16869
|
}))
|
|
@@ -16721,23 +16872,6 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16721
16872
|
modules
|
|
16722
16873
|
}));
|
|
16723
16874
|
}
|
|
16724
|
-
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16725
|
-
const chunkModules = Object.create(null);
|
|
16726
|
-
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
16727
|
-
let chunkSignature = '';
|
|
16728
|
-
for (const entry of allEntries) {
|
|
16729
|
-
chunkSignature += assignedEntries.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
16730
|
-
}
|
|
16731
|
-
const chunk = chunkModules[chunkSignature];
|
|
16732
|
-
if (chunk) {
|
|
16733
|
-
chunk.push(module);
|
|
16734
|
-
}
|
|
16735
|
-
else {
|
|
16736
|
-
chunkModules[chunkSignature] = [module];
|
|
16737
|
-
}
|
|
16738
|
-
}
|
|
16739
|
-
return chunkModules;
|
|
16740
|
-
}
|
|
16741
16875
|
/**
|
|
16742
16876
|
* This function tries to get rid of small chunks by merging them with other
|
|
16743
16877
|
* chunks.
|
|
@@ -16823,8 +16957,6 @@ function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSi
|
|
|
16823
16957
|
timeEnd('optimize chunks', 3);
|
|
16824
16958
|
return [...chunkPartition.small, ...chunkPartition.big];
|
|
16825
16959
|
}
|
|
16826
|
-
const CHAR_DEPENDENT = 'X';
|
|
16827
|
-
const CHAR_INDEPENDENT = '_';
|
|
16828
16960
|
function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
|
|
16829
16961
|
const smallChunks = [];
|
|
16830
16962
|
const bigChunks = [];
|
|
@@ -16833,13 +16965,7 @@ function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunk
|
|
|
16833
16965
|
for (let index = 0; index < numberOfEntries; index++) {
|
|
16834
16966
|
sideEffectsByEntry.push(new Set());
|
|
16835
16967
|
}
|
|
16836
|
-
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16837
|
-
const dependentEntries = new Set();
|
|
16838
|
-
for (let position = 0; position < numberOfEntries; position++) {
|
|
16839
|
-
if (signature[position] === CHAR_DEPENDENT) {
|
|
16840
|
-
dependentEntries.add(position);
|
|
16841
|
-
}
|
|
16842
|
-
}
|
|
16968
|
+
for (const [signature, { dependentEntries, modules }] of Object.entries(chunkModulesBySignature)) {
|
|
16843
16969
|
const chunkDescription = {
|
|
16844
16970
|
correlatedSideEffects: new Set(),
|
|
16845
16971
|
dependencies: new Set(),
|
|
@@ -17635,7 +17761,7 @@ class Bundle {
|
|
|
17635
17761
|
this.pluginDriver.finaliseAssets();
|
|
17636
17762
|
}
|
|
17637
17763
|
async generateChunks(bundle, getHashPlaceholder) {
|
|
17638
|
-
const {
|
|
17764
|
+
const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
17639
17765
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
17640
17766
|
? await this.addManualChunks(manualChunks)
|
|
17641
17767
|
: this.assignManualChunks(manualChunks);
|
|
@@ -17649,7 +17775,7 @@ class Bundle {
|
|
|
17649
17775
|
? [{ alias: null, modules: includedModules }]
|
|
17650
17776
|
: preserveModules
|
|
17651
17777
|
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
17652
|
-
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize
|
|
17778
|
+
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
|
|
17653
17779
|
sortByExecutionOrder(modules);
|
|
17654
17780
|
const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
|
|
17655
17781
|
chunks.push(chunk);
|
|
@@ -25347,7 +25473,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
25347
25473
|
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
25348
25474
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
25349
25475
|
esModule: config.esModule ?? 'if-default-prop',
|
|
25350
|
-
experimentalDeepDynamicChunkOptimization: config
|
|
25476
|
+
experimentalDeepDynamicChunkOptimization: getExperimentalDeepDynamicChunkOptimization(config, inputOptions),
|
|
25351
25477
|
experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
|
|
25352
25478
|
exports: getExports(config, unsetOptions),
|
|
25353
25479
|
extend: config.extend || false,
|
|
@@ -25525,6 +25651,13 @@ const getEntryFileNames = (config, unsetOptions) => {
|
|
|
25525
25651
|
}
|
|
25526
25652
|
return configEntryFileNames ?? '[name].js';
|
|
25527
25653
|
};
|
|
25654
|
+
function getExperimentalDeepDynamicChunkOptimization(config, inputOptions) {
|
|
25655
|
+
const configExperimentalDeepDynamicChunkOptimization = config.experimentalDeepDynamicChunkOptimization;
|
|
25656
|
+
if (configExperimentalDeepDynamicChunkOptimization != null) {
|
|
25657
|
+
warnDeprecation(`The "output.experimentalDeepDynamicChunkOptimization" option is deprecated as Rollup always runs the full chunking algorithm now. The option should be removed.`, URL_OUTPUT_EXPERIMENTALDEEPCHUNKOPTIMIZATION, true, inputOptions);
|
|
25658
|
+
}
|
|
25659
|
+
return configExperimentalDeepDynamicChunkOptimization || false;
|
|
25660
|
+
}
|
|
25528
25661
|
function getExports(config, unsetOptions) {
|
|
25529
25662
|
const configExports = config.exports;
|
|
25530
25663
|
if (configExports == null) {
|
|
@@ -25766,77 +25899,6 @@ function defineConfig(options) {
|
|
|
25766
25899
|
return options;
|
|
25767
25900
|
}
|
|
25768
25901
|
|
|
25769
|
-
class WatchEmitter {
|
|
25770
|
-
constructor() {
|
|
25771
|
-
this.currentHandlers = Object.create(null);
|
|
25772
|
-
this.persistentHandlers = Object.create(null);
|
|
25773
|
-
}
|
|
25774
|
-
// Will be overwritten by Rollup
|
|
25775
|
-
async close() { }
|
|
25776
|
-
emit(event, ...parameters) {
|
|
25777
|
-
return Promise.all([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(handler => handler(...parameters)));
|
|
25778
|
-
}
|
|
25779
|
-
off(event, listener) {
|
|
25780
|
-
const listeners = this.persistentHandlers[event];
|
|
25781
|
-
if (listeners) {
|
|
25782
|
-
// A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
|
|
25783
|
-
// (which would remove the last array element if used unchanged) is turned
|
|
25784
|
-
// into max_int, which is outside the array and does not change anything.
|
|
25785
|
-
listeners.splice(listeners.indexOf(listener) >>> 0, 1);
|
|
25786
|
-
}
|
|
25787
|
-
return this;
|
|
25788
|
-
}
|
|
25789
|
-
on(event, listener) {
|
|
25790
|
-
this.getPersistentHandlers(event).push(listener);
|
|
25791
|
-
return this;
|
|
25792
|
-
}
|
|
25793
|
-
onCurrentRun(event, listener) {
|
|
25794
|
-
this.getCurrentHandlers(event).push(listener);
|
|
25795
|
-
return this;
|
|
25796
|
-
}
|
|
25797
|
-
once(event, listener) {
|
|
25798
|
-
const selfRemovingListener = (...parameters) => {
|
|
25799
|
-
this.off(event, selfRemovingListener);
|
|
25800
|
-
return listener(...parameters);
|
|
25801
|
-
};
|
|
25802
|
-
this.on(event, selfRemovingListener);
|
|
25803
|
-
return this;
|
|
25804
|
-
}
|
|
25805
|
-
removeAllListeners() {
|
|
25806
|
-
this.removeListenersForCurrentRun();
|
|
25807
|
-
this.persistentHandlers = Object.create(null);
|
|
25808
|
-
return this;
|
|
25809
|
-
}
|
|
25810
|
-
removeListenersForCurrentRun() {
|
|
25811
|
-
this.currentHandlers = Object.create(null);
|
|
25812
|
-
return this;
|
|
25813
|
-
}
|
|
25814
|
-
getCurrentHandlers(event) {
|
|
25815
|
-
return this.currentHandlers[event] || (this.currentHandlers[event] = []);
|
|
25816
|
-
}
|
|
25817
|
-
getPersistentHandlers(event) {
|
|
25818
|
-
return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
|
|
25819
|
-
}
|
|
25820
|
-
}
|
|
25821
|
-
|
|
25822
|
-
function watch(configs) {
|
|
25823
|
-
const emitter = new WatchEmitter();
|
|
25824
|
-
watchInternal(configs, emitter).catch(error => {
|
|
25825
|
-
handleError(error);
|
|
25826
|
-
});
|
|
25827
|
-
return emitter;
|
|
25828
|
-
}
|
|
25829
|
-
async function watchInternal(configs, emitter) {
|
|
25830
|
-
const optionsList = await Promise.all(ensureArray$1(configs).map(config => mergeOptions(config)));
|
|
25831
|
-
const watchOptionsList = optionsList.filter(config => config.watch !== false);
|
|
25832
|
-
if (watchOptionsList.length === 0) {
|
|
25833
|
-
return error(errorInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
|
|
25834
|
-
}
|
|
25835
|
-
await loadFsEvents();
|
|
25836
|
-
const { Watcher } = await Promise.resolve().then(() => require('./watch.js'));
|
|
25837
|
-
new Watcher(watchOptionsList, emitter);
|
|
25838
|
-
}
|
|
25839
|
-
|
|
25840
25902
|
exports.URL_AVOIDING_EVAL = URL_AVOIDING_EVAL;
|
|
25841
25903
|
exports.URL_NAME_IS_NOT_EXPORTED = URL_NAME_IS_NOT_EXPORTED;
|
|
25842
25904
|
exports.URL_OUTPUT_EXPORTS = URL_OUTPUT_EXPORTS;
|
|
@@ -25844,22 +25906,24 @@ exports.URL_OUTPUT_GLOBALS = URL_OUTPUT_GLOBALS;
|
|
|
25844
25906
|
exports.URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT = URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT;
|
|
25845
25907
|
exports.URL_THIS_IS_UNDEFINED = URL_THIS_IS_UNDEFINED;
|
|
25846
25908
|
exports.URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY;
|
|
25909
|
+
exports.URL_WATCH = URL_WATCH;
|
|
25847
25910
|
exports.bold = bold;
|
|
25848
25911
|
exports.commandAliases = commandAliases;
|
|
25849
25912
|
exports.commonjsGlobal = commonjsGlobal;
|
|
25850
25913
|
exports.createFilter = createFilter;
|
|
25851
25914
|
exports.cyan = cyan;
|
|
25852
25915
|
exports.defineConfig = defineConfig;
|
|
25916
|
+
exports.ensureArray = ensureArray$1;
|
|
25853
25917
|
exports.error = error;
|
|
25854
25918
|
exports.errorCannotBundleConfigAsEsm = errorCannotBundleConfigAsEsm;
|
|
25855
25919
|
exports.errorCannotLoadConfigAsCjs = errorCannotLoadConfigAsCjs;
|
|
25856
25920
|
exports.errorCannotLoadConfigAsEsm = errorCannotLoadConfigAsEsm;
|
|
25857
25921
|
exports.errorDuplicateImportOptions = errorDuplicateImportOptions;
|
|
25858
25922
|
exports.errorFailAfterWarnings = errorFailAfterWarnings;
|
|
25923
|
+
exports.errorInvalidOption = errorInvalidOption;
|
|
25859
25924
|
exports.errorMissingConfig = errorMissingConfig;
|
|
25860
25925
|
exports.errorMissingExternalConfig = errorMissingExternalConfig;
|
|
25861
25926
|
exports.errorOnlyInlineSourcemapsForStdout = errorOnlyInlineSourcemapsForStdout;
|
|
25862
|
-
exports.fseventsImporter = fseventsImporter;
|
|
25863
25927
|
exports.getAliasName = getAliasName;
|
|
25864
25928
|
exports.getAugmentedNamespace = getAugmentedNamespace;
|
|
25865
25929
|
exports.getNewArray = getNewArray;
|
|
@@ -25869,7 +25933,6 @@ exports.gray = gray;
|
|
|
25869
25933
|
exports.green = green;
|
|
25870
25934
|
exports.handleError = handleError;
|
|
25871
25935
|
exports.isWatchEnabled = isWatchEnabled;
|
|
25872
|
-
exports.loadFsEvents = loadFsEvents;
|
|
25873
25936
|
exports.mergeOptions = mergeOptions;
|
|
25874
25937
|
exports.normalizePluginOption = normalizePluginOption;
|
|
25875
25938
|
exports.printQuotedStringList = printQuotedStringList;
|
|
@@ -25879,6 +25942,5 @@ exports.rollupInternal = rollupInternal;
|
|
|
25879
25942
|
exports.stderr = stderr;
|
|
25880
25943
|
exports.underline = underline;
|
|
25881
25944
|
exports.version = version$1;
|
|
25882
|
-
exports.watch = watch;
|
|
25883
25945
|
exports.yellow = yellow;
|
|
25884
25946
|
//# sourceMappingURL=rollup.js.map
|