rollup 4.6.1 → 4.8.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/LICENSE.md +22 -0
- package/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +163 -148
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/native.js +23 -0
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +76 -8
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +163 -148
- package/dist/shared/watch-cli.js +4 -4
- package/dist/shared/watch.js +2 -2
- package/package.json +36 -34
- package/dist/shared/watch-proxy.js +0 -88
package/dist/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.8.0
|
|
4
|
+
Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -12,21 +12,89 @@
|
|
|
12
12
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
13
13
|
|
|
14
14
|
const rollup = require('./shared/rollup.js');
|
|
15
|
-
const
|
|
16
|
-
require('./shared/
|
|
17
|
-
require('./native.js');
|
|
18
|
-
require('node:path');
|
|
15
|
+
const parseAst_js = require('./shared/parseAst.js');
|
|
16
|
+
const fseventsImporter = require('./shared/fsevents-importer.js');
|
|
19
17
|
require('node:process');
|
|
20
18
|
require('tty');
|
|
19
|
+
require('node:path');
|
|
21
20
|
require('path');
|
|
22
21
|
require('node:perf_hooks');
|
|
22
|
+
require('./native.js');
|
|
23
23
|
require('node:fs/promises');
|
|
24
|
-
require('./shared/fsevents-importer.js');
|
|
25
24
|
|
|
25
|
+
class WatchEmitter {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.currentHandlers = Object.create(null);
|
|
28
|
+
this.persistentHandlers = Object.create(null);
|
|
29
|
+
}
|
|
30
|
+
// Will be overwritten by Rollup
|
|
31
|
+
async close() { }
|
|
32
|
+
emit(event, ...parameters) {
|
|
33
|
+
return Promise.all([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(handler => handler(...parameters)));
|
|
34
|
+
}
|
|
35
|
+
off(event, listener) {
|
|
36
|
+
const listeners = this.persistentHandlers[event];
|
|
37
|
+
if (listeners) {
|
|
38
|
+
// A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
|
|
39
|
+
// (which would remove the last array element if used unchanged) is turned
|
|
40
|
+
// into max_int, which is outside the array and does not change anything.
|
|
41
|
+
listeners.splice(listeners.indexOf(listener) >>> 0, 1);
|
|
42
|
+
}
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
on(event, listener) {
|
|
46
|
+
this.getPersistentHandlers(event).push(listener);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
onCurrentRun(event, listener) {
|
|
50
|
+
this.getCurrentHandlers(event).push(listener);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
once(event, listener) {
|
|
54
|
+
const selfRemovingListener = (...parameters) => {
|
|
55
|
+
this.off(event, selfRemovingListener);
|
|
56
|
+
return listener(...parameters);
|
|
57
|
+
};
|
|
58
|
+
this.on(event, selfRemovingListener);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
removeAllListeners() {
|
|
62
|
+
this.removeListenersForCurrentRun();
|
|
63
|
+
this.persistentHandlers = Object.create(null);
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
removeListenersForCurrentRun() {
|
|
67
|
+
this.currentHandlers = Object.create(null);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
getCurrentHandlers(event) {
|
|
71
|
+
return this.currentHandlers[event] || (this.currentHandlers[event] = []);
|
|
72
|
+
}
|
|
73
|
+
getPersistentHandlers(event) {
|
|
74
|
+
return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
26
77
|
|
|
78
|
+
function watch(configs) {
|
|
79
|
+
const emitter = new WatchEmitter();
|
|
80
|
+
watchInternal(configs, emitter).catch(error => {
|
|
81
|
+
rollup.handleError(error);
|
|
82
|
+
});
|
|
83
|
+
return emitter;
|
|
84
|
+
}
|
|
85
|
+
async function watchInternal(configs, emitter) {
|
|
86
|
+
const optionsList = await Promise.all(rollup.ensureArray(configs).map(config => rollup.mergeOptions(config, true)));
|
|
87
|
+
const watchOptionsList = optionsList.filter(config => config.watch !== false);
|
|
88
|
+
if (watchOptionsList.length === 0) {
|
|
89
|
+
return parseAst_js.error(parseAst_js.logInvalidOption('watch', parseAst_js.URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
|
|
90
|
+
}
|
|
91
|
+
await fseventsImporter.loadFsEvents();
|
|
92
|
+
const { Watcher } = await Promise.resolve().then(() => require('./shared/watch.js'));
|
|
93
|
+
new Watcher(watchOptionsList, emitter);
|
|
94
|
+
}
|
|
27
95
|
|
|
28
96
|
exports.VERSION = rollup.version;
|
|
29
97
|
exports.defineConfig = rollup.defineConfig;
|
|
30
98
|
exports.rollup = rollup.rollup;
|
|
31
|
-
exports.watch =
|
|
99
|
+
exports.watch = watch;
|
|
32
100
|
//# sourceMappingURL=rollup.js.map
|
package/dist/shared/index.js
CHANGED
package/dist/shared/parseAst.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.8.0
|
|
4
|
+
Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
|
|
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 = "4.
|
|
34
|
+
var version = "4.8.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -17233,11 +17233,15 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log
|
|
|
17233
17233
|
const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
|
|
17234
17234
|
const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
|
|
17235
17235
|
// Each chunk is identified by its position in this array
|
|
17236
|
-
const
|
|
17237
|
-
|
|
17238
|
-
//
|
|
17239
|
-
|
|
17240
|
-
|
|
17236
|
+
const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
|
|
17237
|
+
const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
|
|
17238
|
+
// Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
|
|
17239
|
+
// If we no longer want this, we should make a copy here.
|
|
17240
|
+
const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
|
|
17241
|
+
// This mutates the dependentEntries in chunkAtoms
|
|
17242
|
+
removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
|
|
17243
|
+
const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
|
|
17244
|
+
chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
|
|
17241
17245
|
alias: null,
|
|
17242
17246
|
modules
|
|
17243
17247
|
})));
|
|
@@ -17346,7 +17350,7 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
|
|
|
17346
17350
|
}
|
|
17347
17351
|
return dynamicallyDependentEntriesByDynamicEntry;
|
|
17348
17352
|
}
|
|
17349
|
-
function
|
|
17353
|
+
function getChunksWithSameDependentEntries(modulesWithDependentEntries) {
|
|
17350
17354
|
const chunkModules = Object.create(null);
|
|
17351
17355
|
for (const { dependentEntries, modules } of modulesWithDependentEntries) {
|
|
17352
17356
|
let chunkSignature = 0n;
|
|
@@ -17367,55 +17371,152 @@ function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManu
|
|
|
17367
17371
|
}
|
|
17368
17372
|
}
|
|
17369
17373
|
}
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
* first argument. It will also consume its second argument, so if
|
|
17373
|
-
* dynamicallyDependentEntriesByDynamicEntry is ever needed after this, we
|
|
17374
|
-
* should make a copy.
|
|
17375
|
-
*/
|
|
17376
|
-
function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
|
|
17377
|
-
// The indices correspond to the indices in allEntries. The chunks correspond
|
|
17374
|
+
function getStaticDependencyAtomsByEntry(allEntries, chunkAtoms) {
|
|
17375
|
+
// The indices correspond to the indices in allEntries. The atoms correspond
|
|
17378
17376
|
// to bits in the bigint values where chunk 0 is the lowest bit.
|
|
17379
|
-
const
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
for (const { dependentEntries } of chunks) {
|
|
17377
|
+
const staticDependencyAtomsByEntry = allEntries.map(() => 0n);
|
|
17378
|
+
// This toggles the bits for each atom that is a dependency of an entry
|
|
17379
|
+
let atomMask = 1n;
|
|
17380
|
+
for (const { dependentEntries } of chunkAtoms) {
|
|
17384
17381
|
for (const entryIndex of dependentEntries) {
|
|
17385
|
-
|
|
17386
|
-
}
|
|
17387
|
-
|
|
17388
|
-
}
|
|
17389
|
-
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17393
|
-
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17397
|
-
|
|
17398
|
-
|
|
17399
|
-
|
|
17400
|
-
|
|
17401
|
-
|
|
17382
|
+
staticDependencyAtomsByEntry[entryIndex] |= atomMask;
|
|
17383
|
+
}
|
|
17384
|
+
atomMask <<= 1n;
|
|
17385
|
+
}
|
|
17386
|
+
return staticDependencyAtomsByEntry;
|
|
17387
|
+
}
|
|
17388
|
+
// Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
|
|
17389
|
+
function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
|
|
17390
|
+
// Dynamic entries have all atoms as already loaded initially because we then
|
|
17391
|
+
// intersect with the static dependency atoms of all dynamic importers.
|
|
17392
|
+
// Static entries cannot have already loaded atoms.
|
|
17393
|
+
const alreadyLoadedAtomsByEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
|
|
17394
|
+
for (const [dynamicEntryIndex, dynamicallyDependentEntries] of dynamicallyDependentEntriesByDynamicEntry) {
|
|
17395
|
+
// We delete here so that they can be added again if necessary to be handled
|
|
17396
|
+
// again by the loop
|
|
17397
|
+
dynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
|
|
17398
|
+
const knownLoadedAtoms = alreadyLoadedAtomsByEntry[dynamicEntryIndex];
|
|
17399
|
+
let updatedLoadedAtoms = knownLoadedAtoms;
|
|
17400
|
+
for (const entryIndex of dynamicallyDependentEntries) {
|
|
17401
|
+
updatedLoadedAtoms &=
|
|
17402
|
+
staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
|
|
17403
|
+
}
|
|
17404
|
+
// If the knownLoadedAtoms changed, all dependent dynamic entries need to be
|
|
17405
|
+
// updated again
|
|
17406
|
+
if (updatedLoadedAtoms !== knownLoadedAtoms) {
|
|
17407
|
+
alreadyLoadedAtomsByEntry[dynamicEntryIndex] = updatedLoadedAtoms;
|
|
17402
17408
|
for (const dynamicImport of dynamicImportsByEntry[dynamicEntryIndex]) {
|
|
17403
|
-
|
|
17409
|
+
// If this adds an entry that was deleted before, it will be handled
|
|
17410
|
+
// again. This is the reason why we delete every entry from this map
|
|
17411
|
+
// that we processed.
|
|
17412
|
+
getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
|
|
17404
17413
|
}
|
|
17405
17414
|
}
|
|
17406
17415
|
}
|
|
17416
|
+
return alreadyLoadedAtomsByEntry;
|
|
17417
|
+
}
|
|
17418
|
+
/**
|
|
17419
|
+
* This removes all unnecessary dynamic entries from the dependentEntries in its
|
|
17420
|
+
* first argument if a chunk is already loaded without that entry.
|
|
17421
|
+
*/
|
|
17422
|
+
function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
|
|
17407
17423
|
// Remove entries from dependent entries if a chunk is already loaded without
|
|
17408
17424
|
// that entry.
|
|
17409
|
-
chunkMask = 1n;
|
|
17410
|
-
for (const { dependentEntries } of
|
|
17425
|
+
let chunkMask = 1n;
|
|
17426
|
+
for (const { dependentEntries } of chunkAtoms) {
|
|
17411
17427
|
for (const entryIndex of dependentEntries) {
|
|
17412
|
-
if ((
|
|
17428
|
+
if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
|
|
17413
17429
|
dependentEntries.delete(entryIndex);
|
|
17414
17430
|
}
|
|
17415
17431
|
}
|
|
17416
17432
|
chunkMask <<= 1n;
|
|
17417
17433
|
}
|
|
17418
17434
|
}
|
|
17435
|
+
function getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize) {
|
|
17436
|
+
const chunksBySignature = Object.create(null);
|
|
17437
|
+
const chunkByModule = new Map();
|
|
17438
|
+
const sizeByAtom = [];
|
|
17439
|
+
let sideEffectAtoms = 0n;
|
|
17440
|
+
let atomMask = 1n;
|
|
17441
|
+
for (const { dependentEntries, modules } of chunkAtoms) {
|
|
17442
|
+
let chunkSignature = 0n;
|
|
17443
|
+
let correlatedAtoms = -1n;
|
|
17444
|
+
for (const entryIndex of dependentEntries) {
|
|
17445
|
+
chunkSignature |= 1n << BigInt(entryIndex);
|
|
17446
|
+
// Correlated atoms are the atoms that are guaranteed to be loaded as
|
|
17447
|
+
// well when a given atom is loaded. It is the intersection of the already
|
|
17448
|
+
// loaded modules of each chunk merged with its static dependencies.
|
|
17449
|
+
correlatedAtoms &=
|
|
17450
|
+
staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
|
|
17451
|
+
}
|
|
17452
|
+
const chunk = (chunksBySignature[String(chunkSignature)] ||= {
|
|
17453
|
+
containedAtoms: 0n,
|
|
17454
|
+
correlatedAtoms,
|
|
17455
|
+
dependencies: new Set(),
|
|
17456
|
+
dependentChunks: new Set(),
|
|
17457
|
+
dependentEntries: new Set(dependentEntries),
|
|
17458
|
+
modules: [],
|
|
17459
|
+
pure: true,
|
|
17460
|
+
size: 0
|
|
17461
|
+
});
|
|
17462
|
+
let atomSize = 0;
|
|
17463
|
+
let pure = true;
|
|
17464
|
+
for (const module of modules) {
|
|
17465
|
+
chunkByModule.set(module, chunk);
|
|
17466
|
+
// Unfortunately, we cannot take tree-shaking into account here because
|
|
17467
|
+
// rendering did not happen yet, but we can detect empty modules
|
|
17468
|
+
if (module.isIncluded()) {
|
|
17469
|
+
pure &&= !module.hasEffects();
|
|
17470
|
+
// we use a trivial size for the default minChunkSize to improve
|
|
17471
|
+
// performance
|
|
17472
|
+
atomSize += minChunkSize > 1 ? module.estimateSize() : 1;
|
|
17473
|
+
}
|
|
17474
|
+
}
|
|
17475
|
+
if (!pure) {
|
|
17476
|
+
sideEffectAtoms |= atomMask;
|
|
17477
|
+
}
|
|
17478
|
+
sizeByAtom.push(atomSize);
|
|
17479
|
+
chunk.containedAtoms |= atomMask;
|
|
17480
|
+
chunk.modules.push(...modules);
|
|
17481
|
+
chunk.pure &&= pure;
|
|
17482
|
+
chunk.size += atomSize;
|
|
17483
|
+
atomMask <<= 1n;
|
|
17484
|
+
}
|
|
17485
|
+
const chunks = Object.values(chunksBySignature);
|
|
17486
|
+
sideEffectAtoms |= addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, atomMask);
|
|
17487
|
+
return { chunks, sideEffectAtoms, sizeByAtom };
|
|
17488
|
+
}
|
|
17489
|
+
function addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, nextAvailableAtomMask) {
|
|
17490
|
+
const signatureByExternalModule = new Map();
|
|
17491
|
+
let externalSideEffectAtoms = 0n;
|
|
17492
|
+
for (const chunk of chunks) {
|
|
17493
|
+
const { dependencies, modules } = chunk;
|
|
17494
|
+
for (const module of modules) {
|
|
17495
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
17496
|
+
if (dependency instanceof ExternalModule) {
|
|
17497
|
+
if (dependency.info.moduleSideEffects) {
|
|
17498
|
+
const signature = getOrCreate(signatureByExternalModule, dependency, () => {
|
|
17499
|
+
const signature = nextAvailableAtomMask;
|
|
17500
|
+
nextAvailableAtomMask <<= 1n;
|
|
17501
|
+
externalSideEffectAtoms |= signature;
|
|
17502
|
+
return signature;
|
|
17503
|
+
});
|
|
17504
|
+
chunk.containedAtoms |= signature;
|
|
17505
|
+
chunk.correlatedAtoms |= signature;
|
|
17506
|
+
}
|
|
17507
|
+
}
|
|
17508
|
+
else {
|
|
17509
|
+
const dependencyChunk = chunkByModule.get(dependency);
|
|
17510
|
+
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
17511
|
+
dependencies.add(dependencyChunk);
|
|
17512
|
+
dependencyChunk.dependentChunks.add(chunk);
|
|
17513
|
+
}
|
|
17514
|
+
}
|
|
17515
|
+
}
|
|
17516
|
+
}
|
|
17517
|
+
}
|
|
17518
|
+
return externalSideEffectAtoms;
|
|
17519
|
+
}
|
|
17419
17520
|
/**
|
|
17420
17521
|
* This function tries to get rid of small chunks by merging them with other
|
|
17421
17522
|
* chunks.
|
|
@@ -17492,77 +17593,44 @@ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesBy
|
|
|
17492
17593
|
* following the rule (a), starting with the smallest chunks to look for
|
|
17493
17594
|
* possible merge targets.
|
|
17494
17595
|
*/
|
|
17495
|
-
function getOptimizedChunks(
|
|
17596
|
+
function getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log) {
|
|
17496
17597
|
timeStart('optimize chunks', 3);
|
|
17497
|
-
const chunkPartition = getPartitionedChunks(
|
|
17598
|
+
const chunkPartition = getPartitionedChunks(chunks, minChunkSize);
|
|
17498
17599
|
if (!chunkPartition) {
|
|
17499
17600
|
timeEnd('optimize chunks', 3);
|
|
17500
|
-
return
|
|
17601
|
+
return chunks; // the actual modules
|
|
17501
17602
|
}
|
|
17502
17603
|
minChunkSize > 1 &&
|
|
17503
|
-
log('info', parseAst_js.logOptimizeChunkStatus(
|
|
17504
|
-
mergeChunks(chunkPartition, minChunkSize);
|
|
17604
|
+
log('info', parseAst_js.logOptimizeChunkStatus(chunks.length, chunkPartition.small.size, 'Initially'));
|
|
17605
|
+
mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom);
|
|
17505
17606
|
minChunkSize > 1 &&
|
|
17506
17607
|
log('info', parseAst_js.logOptimizeChunkStatus(chunkPartition.small.size + chunkPartition.big.size, chunkPartition.small.size, 'After merging chunks'));
|
|
17507
17608
|
timeEnd('optimize chunks', 3);
|
|
17508
17609
|
return [...chunkPartition.small, ...chunkPartition.big];
|
|
17509
17610
|
}
|
|
17510
|
-
function getPartitionedChunks(
|
|
17611
|
+
function getPartitionedChunks(chunks, minChunkSize) {
|
|
17511
17612
|
const smallChunks = [];
|
|
17512
17613
|
const bigChunks = [];
|
|
17513
|
-
const
|
|
17514
|
-
|
|
17515
|
-
let sideEffectAtoms = 0n;
|
|
17516
|
-
let containedAtoms = 1n;
|
|
17517
|
-
for (const { dependentEntries, modules } of initialChunks) {
|
|
17518
|
-
const chunkDescription = {
|
|
17519
|
-
containedAtoms,
|
|
17520
|
-
correlatedAtoms: 0n,
|
|
17521
|
-
dependencies: new Set(),
|
|
17522
|
-
dependentChunks: new Set(),
|
|
17523
|
-
dependentEntries,
|
|
17524
|
-
modules,
|
|
17525
|
-
pure: true,
|
|
17526
|
-
size: 0
|
|
17527
|
-
};
|
|
17528
|
-
let size = 0;
|
|
17529
|
-
let pure = true;
|
|
17530
|
-
for (const module of modules) {
|
|
17531
|
-
chunkByModule.set(module, chunkDescription);
|
|
17532
|
-
// Unfortunately, we cannot take tree-shaking into account here because
|
|
17533
|
-
// rendering did not happen yet, but we can detect empty modules
|
|
17534
|
-
if (module.isIncluded()) {
|
|
17535
|
-
pure &&= !module.hasEffects();
|
|
17536
|
-
// we use a trivial size for the default minChunkSize to improve
|
|
17537
|
-
// performance
|
|
17538
|
-
size += minChunkSize > 1 ? module.estimateSize() : 1;
|
|
17539
|
-
}
|
|
17540
|
-
}
|
|
17541
|
-
chunkDescription.pure = pure;
|
|
17542
|
-
chunkDescription.size = size;
|
|
17543
|
-
sizeByAtom.push(size);
|
|
17544
|
-
if (!pure) {
|
|
17545
|
-
sideEffectAtoms |= containedAtoms;
|
|
17546
|
-
}
|
|
17547
|
-
(size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
|
|
17548
|
-
containedAtoms <<= 1n;
|
|
17614
|
+
for (const chunk of chunks) {
|
|
17615
|
+
(chunk.size < minChunkSize ? smallChunks : bigChunks).push(chunk);
|
|
17549
17616
|
}
|
|
17550
|
-
// If there are no small chunks, we will not optimize
|
|
17551
17617
|
if (smallChunks.length === 0) {
|
|
17552
17618
|
return null;
|
|
17553
17619
|
}
|
|
17554
|
-
|
|
17620
|
+
smallChunks.sort(compareChunkSize);
|
|
17621
|
+
bigChunks.sort(compareChunkSize);
|
|
17555
17622
|
return {
|
|
17556
17623
|
big: new Set(bigChunks),
|
|
17557
|
-
sideEffectAtoms,
|
|
17558
|
-
sizeByAtom,
|
|
17559
17624
|
small: new Set(smallChunks)
|
|
17560
17625
|
};
|
|
17561
17626
|
}
|
|
17562
|
-
function
|
|
17627
|
+
function compareChunkSize({ size: sizeA }, { size: sizeB }) {
|
|
17628
|
+
return sizeA - sizeB;
|
|
17629
|
+
}
|
|
17630
|
+
function mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom) {
|
|
17563
17631
|
const { small } = chunkPartition;
|
|
17564
17632
|
for (const mergedChunk of small) {
|
|
17565
|
-
const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition,
|
|
17633
|
+
const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition, sideEffectAtoms, sizeByAtom,
|
|
17566
17634
|
// In the default case, we do not accept size increases
|
|
17567
17635
|
minChunkSize <= 1 ? 1 : Infinity);
|
|
17568
17636
|
if (bestTargetChunk) {
|
|
@@ -17594,57 +17662,7 @@ function mergeChunks(chunkPartition, minChunkSize) {
|
|
|
17594
17662
|
}
|
|
17595
17663
|
}
|
|
17596
17664
|
}
|
|
17597
|
-
function
|
|
17598
|
-
const signatureByExternalModule = new Map();
|
|
17599
|
-
let sideEffectAtoms = 0n;
|
|
17600
|
-
const atomsByEntry = [];
|
|
17601
|
-
for (let index = 0; index < numberOfEntries; index++) {
|
|
17602
|
-
atomsByEntry.push(0n);
|
|
17603
|
-
}
|
|
17604
|
-
for (const chunks of chunkLists) {
|
|
17605
|
-
chunks.sort(compareChunkSize);
|
|
17606
|
-
for (const chunk of chunks) {
|
|
17607
|
-
const { dependencies, dependentEntries, modules } = chunk;
|
|
17608
|
-
for (const module of modules) {
|
|
17609
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
17610
|
-
if (dependency instanceof ExternalModule) {
|
|
17611
|
-
if (dependency.info.moduleSideEffects) {
|
|
17612
|
-
chunk.containedAtoms |= getOrCreate(signatureByExternalModule, dependency, () => {
|
|
17613
|
-
const signature = nextAtomSignature;
|
|
17614
|
-
nextAtomSignature <<= 1n;
|
|
17615
|
-
sideEffectAtoms |= signature;
|
|
17616
|
-
return signature;
|
|
17617
|
-
});
|
|
17618
|
-
}
|
|
17619
|
-
}
|
|
17620
|
-
else {
|
|
17621
|
-
const dependencyChunk = chunkByModule.get(dependency);
|
|
17622
|
-
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
17623
|
-
dependencies.add(dependencyChunk);
|
|
17624
|
-
dependencyChunk.dependentChunks.add(chunk);
|
|
17625
|
-
}
|
|
17626
|
-
}
|
|
17627
|
-
}
|
|
17628
|
-
}
|
|
17629
|
-
const { containedAtoms } = chunk;
|
|
17630
|
-
for (const entryIndex of dependentEntries) {
|
|
17631
|
-
atomsByEntry[entryIndex] |= containedAtoms;
|
|
17632
|
-
}
|
|
17633
|
-
}
|
|
17634
|
-
}
|
|
17635
|
-
for (const chunks of chunkLists) {
|
|
17636
|
-
for (const chunk of chunks) {
|
|
17637
|
-
const { dependentEntries } = chunk;
|
|
17638
|
-
// Correlated atoms are the intersection of all entry atoms
|
|
17639
|
-
chunk.correlatedAtoms = -1n;
|
|
17640
|
-
for (const entryIndex of dependentEntries) {
|
|
17641
|
-
chunk.correlatedAtoms &= atomsByEntry[entryIndex];
|
|
17642
|
-
}
|
|
17643
|
-
}
|
|
17644
|
-
}
|
|
17645
|
-
return sideEffectAtoms;
|
|
17646
|
-
}
|
|
17647
|
-
function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, small }, smallestAdditionalSize) {
|
|
17665
|
+
function findBestMergeTarget(mergedChunk, { big, small }, sideEffectAtoms, sizeByAtom, smallestAdditionalSize) {
|
|
17648
17666
|
let bestTargetChunk = null;
|
|
17649
17667
|
// In the default case, we do not accept size increases
|
|
17650
17668
|
for (const targetChunk of concatLazy([small, big])) {
|
|
@@ -17660,12 +17678,6 @@ function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, sm
|
|
|
17660
17678
|
}
|
|
17661
17679
|
return bestTargetChunk;
|
|
17662
17680
|
}
|
|
17663
|
-
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
17664
|
-
return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
17665
|
-
}
|
|
17666
|
-
function compareChunkSize({ size: sizeA }, { size: sizeB }) {
|
|
17667
|
-
return sizeA - sizeB;
|
|
17668
|
-
}
|
|
17669
17681
|
/**
|
|
17670
17682
|
* Determine the additional unused code size that would be added by merging the
|
|
17671
17683
|
* two chunks. This is not an exact measurement but rather an upper bound. If
|
|
@@ -17723,6 +17735,9 @@ function getAtomsSizeIfBelowLimit(atoms, currentAdditionalSize, sizeByAtom) {
|
|
|
17723
17735
|
}
|
|
17724
17736
|
return size;
|
|
17725
17737
|
}
|
|
17738
|
+
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
17739
|
+
return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
17740
|
+
}
|
|
17726
17741
|
|
|
17727
17742
|
// ported from https://github.com/substack/node-commondir
|
|
17728
17743
|
function commondir(files) {
|
package/dist/shared/watch-cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.8.0
|
|
4
|
+
Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ const rollup = require('./rollup.js');
|
|
|
19
19
|
const parseAst_js = require('./parseAst.js');
|
|
20
20
|
const loadConfigFile_js = require('./loadConfigFile.js');
|
|
21
21
|
const node_child_process = require('node:child_process');
|
|
22
|
-
const
|
|
22
|
+
const rollup_js = require('../rollup.js');
|
|
23
23
|
require('fs');
|
|
24
24
|
require('util');
|
|
25
25
|
require('stream');
|
|
@@ -485,7 +485,7 @@ async function watch(command) {
|
|
|
485
485
|
await start(options, warnings);
|
|
486
486
|
}
|
|
487
487
|
async function start(configs, warnings) {
|
|
488
|
-
watcher =
|
|
488
|
+
watcher = rollup_js.watch(configs);
|
|
489
489
|
watcher.on('event', event => {
|
|
490
490
|
switch (event.code) {
|
|
491
491
|
case 'ERROR': {
|
package/dist/shared/watch.js
CHANGED