rollup 3.15.1-1 → 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} +302 -178
- package/dist/es/shared/watch.js +3 -3
- package/dist/loadConfigFile.js +3 -3
- package/dist/rollup.d.ts +11 -1
- 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 +307 -277
- 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';
|
|
@@ -973,7 +974,7 @@ async function mergeOptions(config, rawCommandOptions = EMPTY_COMMAND_OPTIONS, d
|
|
|
973
974
|
const outputOptions = await Promise.all(outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, warn)));
|
|
974
975
|
warnUnknownOptions(command, [
|
|
975
976
|
...Object.keys(inputOptions),
|
|
976
|
-
...Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapPathTransform'),
|
|
977
|
+
...Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapIgnoreList' && option !== 'sourcemapPathTransform'),
|
|
977
978
|
...Object.keys(commandAliases),
|
|
978
979
|
'bundleConfigAsCjs',
|
|
979
980
|
'config',
|
|
@@ -1114,6 +1115,7 @@ async function mergeOutputOptions(config, overrides, warn) {
|
|
|
1114
1115
|
sourcemapBaseUrl: getOption('sourcemapBaseUrl'),
|
|
1115
1116
|
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
|
|
1116
1117
|
sourcemapFile: getOption('sourcemapFile'),
|
|
1118
|
+
sourcemapIgnoreList: getOption('sourcemapIgnoreList'),
|
|
1117
1119
|
sourcemapPathTransform: getOption('sourcemapPathTransform'),
|
|
1118
1120
|
strict: getOption('strict'),
|
|
1119
1121
|
systemNullSetters: getOption('systemNullSetters'),
|
|
@@ -1123,29 +1125,6 @@ async function mergeOutputOptions(config, overrides, warn) {
|
|
|
1123
1125
|
return outputOptions;
|
|
1124
1126
|
}
|
|
1125
1127
|
|
|
1126
|
-
let fsEvents;
|
|
1127
|
-
let fsEventsImportError;
|
|
1128
|
-
async function loadFsEvents() {
|
|
1129
|
-
try {
|
|
1130
|
-
({ default: fsEvents } = await import('fsevents'));
|
|
1131
|
-
}
|
|
1132
|
-
catch (error) {
|
|
1133
|
-
fsEventsImportError = error;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
// A call to this function will be injected into the chokidar code
|
|
1137
|
-
function getFsEvents() {
|
|
1138
|
-
if (fsEventsImportError)
|
|
1139
|
-
throw fsEventsImportError;
|
|
1140
|
-
return fsEvents;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
const fseventsImporter = /*#__PURE__*/Object.defineProperty({
|
|
1144
|
-
__proto__: null,
|
|
1145
|
-
getFsEvents,
|
|
1146
|
-
loadFsEvents
|
|
1147
|
-
}, Symbol.toStringTag, { value: 'Module' });
|
|
1148
|
-
|
|
1149
1128
|
const {
|
|
1150
1129
|
env = {},
|
|
1151
1130
|
argv = [],
|
|
@@ -3005,7 +2984,7 @@ class DiscriminatedPathTracker {
|
|
|
3005
2984
|
currentPaths[pathSegment] ||
|
|
3006
2985
|
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
3007
2986
|
}
|
|
3008
|
-
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, getNewSet);
|
|
2987
|
+
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
3009
2988
|
if (trackedEntities.has(entity))
|
|
3010
2989
|
return true;
|
|
3011
2990
|
trackedEntities.add(entity);
|
|
@@ -13485,7 +13464,7 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
|
|
|
13485
13464
|
});
|
|
13486
13465
|
}
|
|
13487
13466
|
function getAndExtendSideEffectModules(variable, module) {
|
|
13488
|
-
const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, getNewSet);
|
|
13467
|
+
const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, (getNewSet));
|
|
13489
13468
|
let currentVariable = variable;
|
|
13490
13469
|
const referencedVariables = new Set([currentVariable]);
|
|
13491
13470
|
while (true) {
|
|
@@ -13824,7 +13803,7 @@ class Module {
|
|
|
13824
13803
|
searchedNamesAndModules
|
|
13825
13804
|
});
|
|
13826
13805
|
if (importerForSideEffects) {
|
|
13827
|
-
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, getNewSet).add(this);
|
|
13806
|
+
getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, (getNewSet)).add(this);
|
|
13828
13807
|
setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
|
|
13829
13808
|
}
|
|
13830
13809
|
return [variable];
|
|
@@ -16578,7 +16557,137 @@ function* concatLazy(iterables) {
|
|
|
16578
16557
|
}
|
|
16579
16558
|
}
|
|
16580
16559
|
|
|
16581
|
-
|
|
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) {
|
|
16582
16691
|
const chunkDefinitions = [];
|
|
16583
16692
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
16584
16693
|
const manualChunkModulesByAlias = Object.create(null);
|
|
@@ -16588,16 +16697,7 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, dee
|
|
|
16588
16697
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
16589
16698
|
chunkDefinitions.push({ alias, modules });
|
|
16590
16699
|
}
|
|
16591
|
-
|
|
16592
|
-
const staticEntries = new Set(entries);
|
|
16593
|
-
const assignedEntriesByModule = new Map();
|
|
16594
|
-
for (const entry of allEntries) {
|
|
16595
|
-
if (!modulesInManualChunks.has(entry)) {
|
|
16596
|
-
assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization);
|
|
16597
|
-
}
|
|
16598
|
-
}
|
|
16599
|
-
chunkDefinitions.push(...createChunks(allEntries, assignedEntriesByModule, minChunkSize));
|
|
16600
|
-
return chunkDefinitions;
|
|
16700
|
+
return { chunkDefinitions, modulesInManualChunks };
|
|
16601
16701
|
}
|
|
16602
16702
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
16603
16703
|
const modulesToHandle = new Set([entry]);
|
|
@@ -16612,13 +16712,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
|
|
|
16612
16712
|
}
|
|
16613
16713
|
}
|
|
16614
16714
|
function analyzeModuleGraph(entries) {
|
|
16615
|
-
const
|
|
16715
|
+
const dynamicEntryModules = new Set();
|
|
16616
16716
|
const dependentEntriesByModule = new Map();
|
|
16617
|
-
const
|
|
16618
|
-
|
|
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);
|
|
16619
16723
|
const modulesToHandle = new Set([currentEntry]);
|
|
16620
16724
|
for (const module of modulesToHandle) {
|
|
16621
|
-
getOrCreate(dependentEntriesByModule, module, getNewSet).add(
|
|
16725
|
+
getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
|
|
16622
16726
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16623
16727
|
if (!(dependency instanceof ExternalModule)) {
|
|
16624
16728
|
modulesToHandle.add(dependency);
|
|
@@ -16627,33 +16731,58 @@ function analyzeModuleGraph(entries) {
|
|
|
16627
16731
|
for (const { resolution } of module.dynamicImports) {
|
|
16628
16732
|
if (resolution instanceof Module &&
|
|
16629
16733
|
resolution.includedDynamicImporters.length > 0 &&
|
|
16630
|
-
!
|
|
16631
|
-
|
|
16632
|
-
|
|
16734
|
+
!allEntriesSet.has(resolution)) {
|
|
16735
|
+
dynamicEntryModules.add(resolution);
|
|
16736
|
+
allEntriesSet.add(resolution);
|
|
16737
|
+
dynamicImportsForCurrentEntry.add(resolution);
|
|
16633
16738
|
}
|
|
16634
16739
|
}
|
|
16635
16740
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
16636
|
-
if (!
|
|
16637
|
-
|
|
16638
|
-
|
|
16741
|
+
if (!allEntriesSet.has(dependency)) {
|
|
16742
|
+
dynamicEntryModules.add(dependency);
|
|
16743
|
+
allEntriesSet.add(dependency);
|
|
16639
16744
|
}
|
|
16640
16745
|
}
|
|
16641
16746
|
}
|
|
16747
|
+
entryIndex++;
|
|
16642
16748
|
}
|
|
16749
|
+
const allEntries = [...allEntriesSet];
|
|
16750
|
+
const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
|
|
16643
16751
|
return {
|
|
16644
|
-
allEntries
|
|
16752
|
+
allEntries,
|
|
16645
16753
|
dependentEntriesByModule,
|
|
16646
|
-
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
|
|
16754
|
+
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
|
|
16755
|
+
dynamicImportsByEntry
|
|
16647
16756
|
};
|
|
16648
16757
|
}
|
|
16649
|
-
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) {
|
|
16650
16778
|
const dynamicallyDependentEntriesByDynamicEntry = new Map();
|
|
16651
|
-
for (const
|
|
16652
|
-
const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry,
|
|
16653
|
-
|
|
16654
|
-
|
|
16655
|
-
|
|
16656
|
-
|
|
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
|
+
])) {
|
|
16657
16786
|
for (const entry of dependentEntriesByModule.get(importer)) {
|
|
16658
16787
|
dynamicallyDependentEntries.add(entry);
|
|
16659
16788
|
}
|
|
@@ -16661,57 +16790,80 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
|
|
|
16661
16790
|
}
|
|
16662
16791
|
return dynamicallyDependentEntriesByDynamicEntry;
|
|
16663
16792
|
}
|
|
16664
|
-
function
|
|
16665
|
-
|
|
16666
|
-
const
|
|
16667
|
-
for (const
|
|
16668
|
-
|
|
16669
|
-
|
|
16670
|
-
|
|
16671
|
-
continue;
|
|
16672
|
-
}
|
|
16673
|
-
else {
|
|
16674
|
-
assignedEntries.add(entry);
|
|
16675
|
-
}
|
|
16676
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16677
|
-
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
16678
|
-
modulesToHandle.add(dependency);
|
|
16679
|
-
}
|
|
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);
|
|
16680
16800
|
}
|
|
16801
|
+
(chunkModules[_a = String(chunkSignature)] || (chunkModules[_a] = {
|
|
16802
|
+
dependentEntries: new Set(dependentEntries),
|
|
16803
|
+
modules: []
|
|
16804
|
+
})).modules.push(...modules);
|
|
16681
16805
|
}
|
|
16806
|
+
return chunkModules;
|
|
16682
16807
|
}
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
// -> Do not iterate by module but by equivalence group and merge chunks
|
|
16688
|
-
function isModuleAlreadyLoaded(dynamicallyDependentEntries, containedIn, staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization) {
|
|
16689
|
-
if (!deepChunkOptimization &&
|
|
16690
|
-
dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
16691
|
-
return false;
|
|
16692
|
-
}
|
|
16693
|
-
const entriesToCheck = new Set(dynamicallyDependentEntries);
|
|
16694
|
-
for (const entry of entriesToCheck) {
|
|
16695
|
-
if (!containedIn.has(entry)) {
|
|
16696
|
-
if (staticEntries.has(entry)) {
|
|
16697
|
-
return false;
|
|
16698
|
-
}
|
|
16699
|
-
const dynamicallyDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
|
|
16700
|
-
if (!deepChunkOptimization &&
|
|
16701
|
-
dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
|
|
16702
|
-
return false;
|
|
16703
|
-
}
|
|
16704
|
-
for (const dependentEntry of dynamicallyDependentEntries) {
|
|
16705
|
-
entriesToCheck.add(dependentEntry);
|
|
16706
|
-
}
|
|
16808
|
+
function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks) {
|
|
16809
|
+
for (const [module, dependentEntries] of dependentEntriesByModule) {
|
|
16810
|
+
if (!modulesInManualChunks.has(module)) {
|
|
16811
|
+
yield { dependentEntries, modules: [module] };
|
|
16707
16812
|
}
|
|
16708
16813
|
}
|
|
16709
|
-
return true;
|
|
16710
16814
|
}
|
|
16711
|
-
|
|
16712
|
-
|
|
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) {
|
|
16713
16865
|
return minChunkSize === 0
|
|
16714
|
-
? Object.values(chunkModulesBySignature).map(modules => ({
|
|
16866
|
+
? Object.values(chunkModulesBySignature).map(({ modules }) => ({
|
|
16715
16867
|
alias: null,
|
|
16716
16868
|
modules
|
|
16717
16869
|
}))
|
|
@@ -16720,23 +16872,6 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16720
16872
|
modules
|
|
16721
16873
|
}));
|
|
16722
16874
|
}
|
|
16723
|
-
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16724
|
-
const chunkModules = Object.create(null);
|
|
16725
|
-
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
16726
|
-
let chunkSignature = '';
|
|
16727
|
-
for (const entry of allEntries) {
|
|
16728
|
-
chunkSignature += assignedEntries.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
16729
|
-
}
|
|
16730
|
-
const chunk = chunkModules[chunkSignature];
|
|
16731
|
-
if (chunk) {
|
|
16732
|
-
chunk.push(module);
|
|
16733
|
-
}
|
|
16734
|
-
else {
|
|
16735
|
-
chunkModules[chunkSignature] = [module];
|
|
16736
|
-
}
|
|
16737
|
-
}
|
|
16738
|
-
return chunkModules;
|
|
16739
|
-
}
|
|
16740
16875
|
/**
|
|
16741
16876
|
* This function tries to get rid of small chunks by merging them with other
|
|
16742
16877
|
* chunks.
|
|
@@ -16808,17 +16943,20 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16808
16943
|
* following the above rules (a) and (b), starting with the smallest chunks
|
|
16809
16944
|
* to look for possible merge targets.
|
|
16810
16945
|
*/
|
|
16946
|
+
// TODO instead of picking the "closest" chunk, we could actually use a
|
|
16947
|
+
// technique similar to what we do for side effects to compare the size of the
|
|
16948
|
+
// static dependencies that are not part of the correlated dependencies
|
|
16811
16949
|
function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
|
|
16812
16950
|
timeStart('optimize chunks', 3);
|
|
16813
16951
|
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize);
|
|
16952
|
+
console.log('Before eliminating small chunks, there were\n', Object.keys(chunkModulesBySignature).length, 'chunks, of which\n', chunkPartition.small.size, 'were below minChunkSize.');
|
|
16814
16953
|
if (chunkPartition.small.size > 0) {
|
|
16815
16954
|
mergeChunks(chunkPartition, minChunkSize);
|
|
16816
16955
|
}
|
|
16956
|
+
console.log('After merging chunks,\n', chunkPartition.small.size + chunkPartition.big.size, 'chunks remain, of which\n', chunkPartition.small.size, 'are below minChunkSize.');
|
|
16817
16957
|
timeEnd('optimize chunks', 3);
|
|
16818
16958
|
return [...chunkPartition.small, ...chunkPartition.big];
|
|
16819
16959
|
}
|
|
16820
|
-
const CHAR_DEPENDENT = 'X';
|
|
16821
|
-
const CHAR_INDEPENDENT = '_';
|
|
16822
16960
|
function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
|
|
16823
16961
|
const smallChunks = [];
|
|
16824
16962
|
const bigChunks = [];
|
|
@@ -16827,13 +16965,7 @@ function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunk
|
|
|
16827
16965
|
for (let index = 0; index < numberOfEntries; index++) {
|
|
16828
16966
|
sideEffectsByEntry.push(new Set());
|
|
16829
16967
|
}
|
|
16830
|
-
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16831
|
-
const dependentEntries = new Set();
|
|
16832
|
-
for (let position = 0; position < numberOfEntries; position++) {
|
|
16833
|
-
if (signature[position] === CHAR_DEPENDENT) {
|
|
16834
|
-
dependentEntries.add(position);
|
|
16835
|
-
}
|
|
16836
|
-
}
|
|
16968
|
+
for (const [signature, { dependentEntries, modules }] of Object.entries(chunkModulesBySignature)) {
|
|
16837
16969
|
const chunkDescription = {
|
|
16838
16970
|
correlatedSideEffects: new Set(),
|
|
16839
16971
|
dependencies: new Set(),
|
|
@@ -16910,8 +17042,6 @@ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
|
|
|
16910
17042
|
return sizeA - sizeB;
|
|
16911
17043
|
}
|
|
16912
17044
|
function mergeChunks(chunkPartition, minChunkSize) {
|
|
16913
|
-
console.log('---- Initial chunks');
|
|
16914
|
-
printConsistencyCheck(chunkPartition);
|
|
16915
17045
|
for (const allowArbitraryMerges of [false, true]) {
|
|
16916
17046
|
for (const mergedChunk of chunkPartition.small) {
|
|
16917
17047
|
let closestChunk = null;
|
|
@@ -16959,11 +17089,10 @@ function mergeChunks(chunkPartition, minChunkSize) {
|
|
|
16959
17089
|
dependentChunk.dependencies.add(closestChunk);
|
|
16960
17090
|
}
|
|
16961
17091
|
dependencies.delete(closestChunk);
|
|
17092
|
+
dependentChunks.delete(closestChunk);
|
|
16962
17093
|
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16963
17094
|
}
|
|
16964
17095
|
}
|
|
16965
|
-
console.log('---- After run with arbitrary merges:', allowArbitraryMerges);
|
|
16966
|
-
printConsistencyCheck(chunkPartition);
|
|
16967
17096
|
}
|
|
16968
17097
|
}
|
|
16969
17098
|
// Merging will not produce cycles if none of the direct non-merged dependencies
|
|
@@ -17019,58 +17148,6 @@ function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentE
|
|
|
17019
17148
|
}
|
|
17020
17149
|
return distance;
|
|
17021
17150
|
}
|
|
17022
|
-
function printConsistencyCheck(partition) {
|
|
17023
|
-
console.log(`Chunks\n small: ${partition.small.size},\n large: ${partition.big.size}`);
|
|
17024
|
-
const chunks = new Set([...partition.big, ...partition.small]);
|
|
17025
|
-
console.log('Number of cycles:', getNumberOfCycles(chunks));
|
|
17026
|
-
let missingDependencies = 0;
|
|
17027
|
-
let missingDependentChunks = 0;
|
|
17028
|
-
const seenModules = new Set();
|
|
17029
|
-
for (const { modules, dependencies, dependentChunks } of chunks) {
|
|
17030
|
-
for (const module of modules) {
|
|
17031
|
-
if (seenModules.has(module)) {
|
|
17032
|
-
console.log(`Module ${module.id} is duplicated between chunks.`);
|
|
17033
|
-
}
|
|
17034
|
-
seenModules.add(module);
|
|
17035
|
-
}
|
|
17036
|
-
for (const dependency of dependencies) {
|
|
17037
|
-
if (!chunks.has(dependency)) {
|
|
17038
|
-
missingDependencies++;
|
|
17039
|
-
}
|
|
17040
|
-
}
|
|
17041
|
-
for (const dependency of dependentChunks) {
|
|
17042
|
-
if (!chunks.has(dependency)) {
|
|
17043
|
-
missingDependentChunks++;
|
|
17044
|
-
}
|
|
17045
|
-
}
|
|
17046
|
-
}
|
|
17047
|
-
console.log(`Missing\n dependencies: ${missingDependencies},\n dependent chunks: ${missingDependentChunks}\n`);
|
|
17048
|
-
}
|
|
17049
|
-
function getNumberOfCycles(chunks) {
|
|
17050
|
-
const parents = new Set();
|
|
17051
|
-
const analysedChunks = new Set();
|
|
17052
|
-
let cycles = 0;
|
|
17053
|
-
const analyseChunk = (chunk) => {
|
|
17054
|
-
for (const dependency of chunk.dependencies) {
|
|
17055
|
-
if (parents.has(dependency)) {
|
|
17056
|
-
if (!analysedChunks.has(dependency)) {
|
|
17057
|
-
cycles++;
|
|
17058
|
-
}
|
|
17059
|
-
continue;
|
|
17060
|
-
}
|
|
17061
|
-
parents.add(dependency);
|
|
17062
|
-
analyseChunk(dependency);
|
|
17063
|
-
}
|
|
17064
|
-
analysedChunks.add(chunk);
|
|
17065
|
-
};
|
|
17066
|
-
for (const chunk of chunks) {
|
|
17067
|
-
if (!parents.has(chunk)) {
|
|
17068
|
-
parents.add(chunk);
|
|
17069
|
-
analyseChunk(chunk);
|
|
17070
|
-
}
|
|
17071
|
-
}
|
|
17072
|
-
return cycles;
|
|
17073
|
-
}
|
|
17074
17151
|
|
|
17075
17152
|
// ported from https://github.com/substack/node-commondir
|
|
17076
17153
|
function commondir(files) {
|
|
@@ -17428,7 +17505,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
|
|
|
17428
17505
|
}
|
|
17429
17506
|
return result.code;
|
|
17430
17507
|
});
|
|
17431
|
-
const { compact, dir, file, sourcemap, sourcemapExcludeSources, sourcemapFile, sourcemapPathTransform } = options;
|
|
17508
|
+
const { compact, dir, file, sourcemap, sourcemapExcludeSources, sourcemapFile, sourcemapPathTransform, sourcemapIgnoreList } = options;
|
|
17432
17509
|
if (!compact && code[code.length - 1] !== '\n')
|
|
17433
17510
|
code += '\n';
|
|
17434
17511
|
if (sourcemap) {
|
|
@@ -17442,18 +17519,31 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
|
|
|
17442
17519
|
resultingFile = node_path.resolve(fileName);
|
|
17443
17520
|
const decodedMap = magicString.generateDecodedMap({});
|
|
17444
17521
|
map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, onwarn);
|
|
17445
|
-
|
|
17446
|
-
|
|
17522
|
+
for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
|
|
17523
|
+
let sourcePath = map.sources[sourcesIndex];
|
|
17524
|
+
const sourcemapPath = `${resultingFile}.map`;
|
|
17525
|
+
if (sourcemapIgnoreList) {
|
|
17526
|
+
const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
|
|
17527
|
+
if (typeof ignoreList !== 'boolean') {
|
|
17528
|
+
error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
|
|
17529
|
+
}
|
|
17530
|
+
if (ignoreList) {
|
|
17531
|
+
if (map.x_google_ignoreList === undefined) {
|
|
17532
|
+
map.x_google_ignoreList = [];
|
|
17533
|
+
}
|
|
17534
|
+
if (!map.x_google_ignoreList.includes(sourcesIndex)) {
|
|
17535
|
+
map.x_google_ignoreList.push(sourcesIndex);
|
|
17536
|
+
}
|
|
17537
|
+
}
|
|
17538
|
+
}
|
|
17447
17539
|
if (sourcemapPathTransform) {
|
|
17448
|
-
|
|
17449
|
-
if (typeof
|
|
17540
|
+
sourcePath = sourcemapPathTransform(sourcePath, sourcemapPath);
|
|
17541
|
+
if (typeof sourcePath !== 'string') {
|
|
17450
17542
|
error(errorFailedValidation(`sourcemapPathTransform function must return a string.`));
|
|
17451
17543
|
}
|
|
17452
|
-
return newSourcePath;
|
|
17453
17544
|
}
|
|
17454
|
-
|
|
17455
|
-
}
|
|
17456
|
-
.map(normalize);
|
|
17545
|
+
map.sources[sourcesIndex] = normalize(sourcePath);
|
|
17546
|
+
}
|
|
17457
17547
|
timeEnd('sourcemaps', 3);
|
|
17458
17548
|
}
|
|
17459
17549
|
return {
|
|
@@ -17671,7 +17761,7 @@ class Bundle {
|
|
|
17671
17761
|
this.pluginDriver.finaliseAssets();
|
|
17672
17762
|
}
|
|
17673
17763
|
async generateChunks(bundle, getHashPlaceholder) {
|
|
17674
|
-
const {
|
|
17764
|
+
const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
17675
17765
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
17676
17766
|
? await this.addManualChunks(manualChunks)
|
|
17677
17767
|
: this.assignManualChunks(manualChunks);
|
|
@@ -17685,7 +17775,7 @@ class Bundle {
|
|
|
17685
17775
|
? [{ alias: null, modules: includedModules }]
|
|
17686
17776
|
: preserveModules
|
|
17687
17777
|
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
17688
|
-
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize
|
|
17778
|
+
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
|
|
17689
17779
|
sortByExecutionOrder(modules);
|
|
17690
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);
|
|
17691
17781
|
chunks.push(chunk);
|
|
@@ -24820,7 +24910,8 @@ class Graph {
|
|
|
24820
24910
|
}
|
|
24821
24911
|
}
|
|
24822
24912
|
includeStatements() {
|
|
24823
|
-
|
|
24913
|
+
const entryModules = [...this.entryModules, ...this.implicitEntryModules];
|
|
24914
|
+
for (const module of entryModules) {
|
|
24824
24915
|
markModuleAndImpureDependenciesAsExecuted(module);
|
|
24825
24916
|
}
|
|
24826
24917
|
if (this.options.treeshake) {
|
|
@@ -24841,7 +24932,7 @@ class Graph {
|
|
|
24841
24932
|
if (treeshakingPass === 1) {
|
|
24842
24933
|
// We only include exports after the first pass to avoid issues with
|
|
24843
24934
|
// the TDZ detection logic
|
|
24844
|
-
for (const module of
|
|
24935
|
+
for (const module of entryModules) {
|
|
24845
24936
|
if (module.preserveSignature !== false) {
|
|
24846
24937
|
module.includeAllExports(false);
|
|
24847
24938
|
this.needsTreeshakingPass = true;
|
|
@@ -25233,7 +25324,9 @@ const getAcornInjectPlugins = (config) => [
|
|
|
25233
25324
|
importAssertions,
|
|
25234
25325
|
...ensureArray$1(config.acornInjectPlugins)
|
|
25235
25326
|
];
|
|
25236
|
-
const getCache = (config) => config.cache
|
|
25327
|
+
const getCache = (config) => config.cache === true // `true` is the default
|
|
25328
|
+
? undefined
|
|
25329
|
+
: config.cache?.cache || config.cache;
|
|
25237
25330
|
const getIdMatcher = (option) => {
|
|
25238
25331
|
if (option === true) {
|
|
25239
25332
|
return () => true;
|
|
@@ -25380,7 +25473,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
25380
25473
|
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
25381
25474
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
25382
25475
|
esModule: config.esModule ?? 'if-default-prop',
|
|
25383
|
-
experimentalDeepDynamicChunkOptimization: config
|
|
25476
|
+
experimentalDeepDynamicChunkOptimization: getExperimentalDeepDynamicChunkOptimization(config, inputOptions),
|
|
25384
25477
|
experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
|
|
25385
25478
|
exports: getExports(config, unsetOptions),
|
|
25386
25479
|
extend: config.extend || false,
|
|
@@ -25417,6 +25510,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
25417
25510
|
sourcemapBaseUrl: getSourcemapBaseUrl(config),
|
|
25418
25511
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
25419
25512
|
sourcemapFile: config.sourcemapFile,
|
|
25513
|
+
sourcemapIgnoreList: config.sourcemapIgnoreList,
|
|
25420
25514
|
sourcemapPathTransform: config.sourcemapPathTransform,
|
|
25421
25515
|
strict: config.strict ?? true,
|
|
25422
25516
|
systemNullSetters: config.systemNullSetters ?? true,
|
|
@@ -25557,6 +25651,13 @@ const getEntryFileNames = (config, unsetOptions) => {
|
|
|
25557
25651
|
}
|
|
25558
25652
|
return configEntryFileNames ?? '[name].js';
|
|
25559
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
|
+
}
|
|
25560
25661
|
function getExports(config, unsetOptions) {
|
|
25561
25662
|
const configExports = config.exports;
|
|
25562
25663
|
if (configExports == null) {
|
|
@@ -25798,77 +25899,6 @@ function defineConfig(options) {
|
|
|
25798
25899
|
return options;
|
|
25799
25900
|
}
|
|
25800
25901
|
|
|
25801
|
-
class WatchEmitter {
|
|
25802
|
-
constructor() {
|
|
25803
|
-
this.currentHandlers = Object.create(null);
|
|
25804
|
-
this.persistentHandlers = Object.create(null);
|
|
25805
|
-
}
|
|
25806
|
-
// Will be overwritten by Rollup
|
|
25807
|
-
async close() { }
|
|
25808
|
-
emit(event, ...parameters) {
|
|
25809
|
-
return Promise.all([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(handler => handler(...parameters)));
|
|
25810
|
-
}
|
|
25811
|
-
off(event, listener) {
|
|
25812
|
-
const listeners = this.persistentHandlers[event];
|
|
25813
|
-
if (listeners) {
|
|
25814
|
-
// A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
|
|
25815
|
-
// (which would remove the last array element if used unchanged) is turned
|
|
25816
|
-
// into max_int, which is outside the array and does not change anything.
|
|
25817
|
-
listeners.splice(listeners.indexOf(listener) >>> 0, 1);
|
|
25818
|
-
}
|
|
25819
|
-
return this;
|
|
25820
|
-
}
|
|
25821
|
-
on(event, listener) {
|
|
25822
|
-
this.getPersistentHandlers(event).push(listener);
|
|
25823
|
-
return this;
|
|
25824
|
-
}
|
|
25825
|
-
onCurrentRun(event, listener) {
|
|
25826
|
-
this.getCurrentHandlers(event).push(listener);
|
|
25827
|
-
return this;
|
|
25828
|
-
}
|
|
25829
|
-
once(event, listener) {
|
|
25830
|
-
const selfRemovingListener = (...parameters) => {
|
|
25831
|
-
this.off(event, selfRemovingListener);
|
|
25832
|
-
return listener(...parameters);
|
|
25833
|
-
};
|
|
25834
|
-
this.on(event, selfRemovingListener);
|
|
25835
|
-
return this;
|
|
25836
|
-
}
|
|
25837
|
-
removeAllListeners() {
|
|
25838
|
-
this.removeListenersForCurrentRun();
|
|
25839
|
-
this.persistentHandlers = Object.create(null);
|
|
25840
|
-
return this;
|
|
25841
|
-
}
|
|
25842
|
-
removeListenersForCurrentRun() {
|
|
25843
|
-
this.currentHandlers = Object.create(null);
|
|
25844
|
-
return this;
|
|
25845
|
-
}
|
|
25846
|
-
getCurrentHandlers(event) {
|
|
25847
|
-
return this.currentHandlers[event] || (this.currentHandlers[event] = []);
|
|
25848
|
-
}
|
|
25849
|
-
getPersistentHandlers(event) {
|
|
25850
|
-
return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
|
|
25851
|
-
}
|
|
25852
|
-
}
|
|
25853
|
-
|
|
25854
|
-
function watch(configs) {
|
|
25855
|
-
const emitter = new WatchEmitter();
|
|
25856
|
-
watchInternal(configs, emitter).catch(error => {
|
|
25857
|
-
handleError(error);
|
|
25858
|
-
});
|
|
25859
|
-
return emitter;
|
|
25860
|
-
}
|
|
25861
|
-
async function watchInternal(configs, emitter) {
|
|
25862
|
-
const optionsList = await Promise.all(ensureArray$1(configs).map(config => mergeOptions(config)));
|
|
25863
|
-
const watchOptionsList = optionsList.filter(config => config.watch !== false);
|
|
25864
|
-
if (watchOptionsList.length === 0) {
|
|
25865
|
-
return error(errorInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
|
|
25866
|
-
}
|
|
25867
|
-
await loadFsEvents();
|
|
25868
|
-
const { Watcher } = await Promise.resolve().then(() => require('./watch.js'));
|
|
25869
|
-
new Watcher(watchOptionsList, emitter);
|
|
25870
|
-
}
|
|
25871
|
-
|
|
25872
25902
|
exports.URL_AVOIDING_EVAL = URL_AVOIDING_EVAL;
|
|
25873
25903
|
exports.URL_NAME_IS_NOT_EXPORTED = URL_NAME_IS_NOT_EXPORTED;
|
|
25874
25904
|
exports.URL_OUTPUT_EXPORTS = URL_OUTPUT_EXPORTS;
|
|
@@ -25876,22 +25906,24 @@ exports.URL_OUTPUT_GLOBALS = URL_OUTPUT_GLOBALS;
|
|
|
25876
25906
|
exports.URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT = URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT;
|
|
25877
25907
|
exports.URL_THIS_IS_UNDEFINED = URL_THIS_IS_UNDEFINED;
|
|
25878
25908
|
exports.URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY;
|
|
25909
|
+
exports.URL_WATCH = URL_WATCH;
|
|
25879
25910
|
exports.bold = bold;
|
|
25880
25911
|
exports.commandAliases = commandAliases;
|
|
25881
25912
|
exports.commonjsGlobal = commonjsGlobal;
|
|
25882
25913
|
exports.createFilter = createFilter;
|
|
25883
25914
|
exports.cyan = cyan;
|
|
25884
25915
|
exports.defineConfig = defineConfig;
|
|
25916
|
+
exports.ensureArray = ensureArray$1;
|
|
25885
25917
|
exports.error = error;
|
|
25886
25918
|
exports.errorCannotBundleConfigAsEsm = errorCannotBundleConfigAsEsm;
|
|
25887
25919
|
exports.errorCannotLoadConfigAsCjs = errorCannotLoadConfigAsCjs;
|
|
25888
25920
|
exports.errorCannotLoadConfigAsEsm = errorCannotLoadConfigAsEsm;
|
|
25889
25921
|
exports.errorDuplicateImportOptions = errorDuplicateImportOptions;
|
|
25890
25922
|
exports.errorFailAfterWarnings = errorFailAfterWarnings;
|
|
25923
|
+
exports.errorInvalidOption = errorInvalidOption;
|
|
25891
25924
|
exports.errorMissingConfig = errorMissingConfig;
|
|
25892
25925
|
exports.errorMissingExternalConfig = errorMissingExternalConfig;
|
|
25893
25926
|
exports.errorOnlyInlineSourcemapsForStdout = errorOnlyInlineSourcemapsForStdout;
|
|
25894
|
-
exports.fseventsImporter = fseventsImporter;
|
|
25895
25927
|
exports.getAliasName = getAliasName;
|
|
25896
25928
|
exports.getAugmentedNamespace = getAugmentedNamespace;
|
|
25897
25929
|
exports.getNewArray = getNewArray;
|
|
@@ -25901,7 +25933,6 @@ exports.gray = gray;
|
|
|
25901
25933
|
exports.green = green;
|
|
25902
25934
|
exports.handleError = handleError;
|
|
25903
25935
|
exports.isWatchEnabled = isWatchEnabled;
|
|
25904
|
-
exports.loadFsEvents = loadFsEvents;
|
|
25905
25936
|
exports.mergeOptions = mergeOptions;
|
|
25906
25937
|
exports.normalizePluginOption = normalizePluginOption;
|
|
25907
25938
|
exports.printQuotedStringList = printQuotedStringList;
|
|
@@ -25911,6 +25942,5 @@ exports.rollupInternal = rollupInternal;
|
|
|
25911
25942
|
exports.stderr = stderr;
|
|
25912
25943
|
exports.underline = underline;
|
|
25913
25944
|
exports.version = version$1;
|
|
25914
|
-
exports.watch = watch;
|
|
25915
25945
|
exports.yellow = yellow;
|
|
25916
25946
|
//# sourceMappingURL=rollup.js.map
|