rollup 3.6.1-0 → 3.7.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 +123 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +119 -361
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +119 -362
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.7.0
|
|
4
|
+
Thu, 08 Dec 2022 05:38:14 GMT - commit e83d53900e7ef2b71c12762a7fe7c91ef715a289
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version$1 = "3.
|
|
34
|
+
var version$1 = "3.7.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -2828,7 +2828,7 @@ function formatAssertions(assertions, { getObject }) {
|
|
|
2828
2828
|
|
|
2829
2829
|
function getOrCreate(map, key, init) {
|
|
2830
2830
|
const existing = map.get(key);
|
|
2831
|
-
if (existing
|
|
2831
|
+
if (existing) {
|
|
2832
2832
|
return existing;
|
|
2833
2833
|
}
|
|
2834
2834
|
const value = init();
|
|
@@ -5546,6 +5546,10 @@ const literalNumberMembers = assembleMemberDescriptions({
|
|
|
5546
5546
|
toPrecision: returnsString,
|
|
5547
5547
|
valueOf: returnsNumber
|
|
5548
5548
|
}, objectMembers);
|
|
5549
|
+
const literalRegExpMembers = assembleMemberDescriptions({
|
|
5550
|
+
exec: returnsUnknown,
|
|
5551
|
+
test: returnsBoolean
|
|
5552
|
+
}, objectMembers);
|
|
5549
5553
|
const literalStringMembers = assembleMemberDescriptions({
|
|
5550
5554
|
anchor: returnsString,
|
|
5551
5555
|
at: returnsUnknown,
|
|
@@ -5597,6 +5601,9 @@ const literalStringMembers = assembleMemberDescriptions({
|
|
|
5597
5601
|
valueOf: returnsString
|
|
5598
5602
|
}, objectMembers);
|
|
5599
5603
|
function getLiteralMembersForValue(value) {
|
|
5604
|
+
if (value instanceof RegExp) {
|
|
5605
|
+
return literalRegExpMembers;
|
|
5606
|
+
}
|
|
5600
5607
|
switch (typeof value) {
|
|
5601
5608
|
case 'boolean': {
|
|
5602
5609
|
return literalBooleanMembers;
|
|
@@ -11770,12 +11777,7 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11770
11777
|
class Program extends NodeBase {
|
|
11771
11778
|
constructor() {
|
|
11772
11779
|
super(...arguments);
|
|
11773
|
-
this.hasCachedEffect =
|
|
11774
|
-
}
|
|
11775
|
-
hasCachedEffects() {
|
|
11776
|
-
return this.hasCachedEffect === null
|
|
11777
|
-
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11778
|
-
: this.hasCachedEffect;
|
|
11780
|
+
this.hasCachedEffect = false;
|
|
11779
11781
|
}
|
|
11780
11782
|
hasEffects(context) {
|
|
11781
11783
|
// We are caching here to later more efficiently identify side-effect-free modules
|
|
@@ -13635,7 +13637,8 @@ class Module {
|
|
|
13635
13637
|
return [null];
|
|
13636
13638
|
}
|
|
13637
13639
|
hasEffects() {
|
|
13638
|
-
return this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13640
|
+
return (this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13641
|
+
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13639
13642
|
}
|
|
13640
13643
|
include() {
|
|
13641
13644
|
const context = createInclusionContext();
|
|
@@ -16234,138 +16237,18 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
16234
16237
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
16235
16238
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
16236
16239
|
|
|
16237
|
-
const BYTE_UNITS = [
|
|
16238
|
-
'B',
|
|
16239
|
-
'kB',
|
|
16240
|
-
'MB',
|
|
16241
|
-
'GB',
|
|
16242
|
-
'TB',
|
|
16243
|
-
'PB',
|
|
16244
|
-
'EB',
|
|
16245
|
-
'ZB',
|
|
16246
|
-
'YB',
|
|
16247
|
-
];
|
|
16248
|
-
|
|
16249
|
-
const BIBYTE_UNITS = [
|
|
16250
|
-
'B',
|
|
16251
|
-
'kiB',
|
|
16252
|
-
'MiB',
|
|
16253
|
-
'GiB',
|
|
16254
|
-
'TiB',
|
|
16255
|
-
'PiB',
|
|
16256
|
-
'EiB',
|
|
16257
|
-
'ZiB',
|
|
16258
|
-
'YiB',
|
|
16259
|
-
];
|
|
16260
|
-
|
|
16261
|
-
const BIT_UNITS = [
|
|
16262
|
-
'b',
|
|
16263
|
-
'kbit',
|
|
16264
|
-
'Mbit',
|
|
16265
|
-
'Gbit',
|
|
16266
|
-
'Tbit',
|
|
16267
|
-
'Pbit',
|
|
16268
|
-
'Ebit',
|
|
16269
|
-
'Zbit',
|
|
16270
|
-
'Ybit',
|
|
16271
|
-
];
|
|
16272
|
-
|
|
16273
|
-
const BIBIT_UNITS = [
|
|
16274
|
-
'b',
|
|
16275
|
-
'kibit',
|
|
16276
|
-
'Mibit',
|
|
16277
|
-
'Gibit',
|
|
16278
|
-
'Tibit',
|
|
16279
|
-
'Pibit',
|
|
16280
|
-
'Eibit',
|
|
16281
|
-
'Zibit',
|
|
16282
|
-
'Yibit',
|
|
16283
|
-
];
|
|
16284
|
-
|
|
16285
|
-
/*
|
|
16286
|
-
Formats the given number using `Number#toLocaleString`.
|
|
16287
|
-
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
16288
|
-
- If locale is true, the system default locale is used for translation.
|
|
16289
|
-
- If no value for locale is specified, the number is returned unmodified.
|
|
16290
|
-
*/
|
|
16291
|
-
const toLocaleString = (number, locale, options) => {
|
|
16292
|
-
let result = number;
|
|
16293
|
-
if (typeof locale === 'string' || Array.isArray(locale)) {
|
|
16294
|
-
result = number.toLocaleString(locale, options);
|
|
16295
|
-
} else if (locale === true || options !== undefined) {
|
|
16296
|
-
result = number.toLocaleString(undefined, options);
|
|
16297
|
-
}
|
|
16298
|
-
|
|
16299
|
-
return result;
|
|
16300
|
-
};
|
|
16301
|
-
|
|
16302
|
-
function prettyBytes(number, options) {
|
|
16303
|
-
if (!Number.isFinite(number)) {
|
|
16304
|
-
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
16305
|
-
}
|
|
16306
|
-
|
|
16307
|
-
options = {
|
|
16308
|
-
bits: false,
|
|
16309
|
-
binary: false,
|
|
16310
|
-
...options,
|
|
16311
|
-
};
|
|
16312
|
-
|
|
16313
|
-
const UNITS = options.bits
|
|
16314
|
-
? (options.binary ? BIBIT_UNITS : BIT_UNITS)
|
|
16315
|
-
: (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
|
|
16316
|
-
|
|
16317
|
-
if (options.signed && number === 0) {
|
|
16318
|
-
return ` 0 ${UNITS[0]}`;
|
|
16319
|
-
}
|
|
16320
|
-
|
|
16321
|
-
const isNegative = number < 0;
|
|
16322
|
-
const prefix = isNegative ? '-' : (options.signed ? '+' : '');
|
|
16323
|
-
|
|
16324
|
-
if (isNegative) {
|
|
16325
|
-
number = -number;
|
|
16326
|
-
}
|
|
16327
|
-
|
|
16328
|
-
let localeOptions;
|
|
16329
|
-
|
|
16330
|
-
if (options.minimumFractionDigits !== undefined) {
|
|
16331
|
-
localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
|
|
16332
|
-
}
|
|
16333
|
-
|
|
16334
|
-
if (options.maximumFractionDigits !== undefined) {
|
|
16335
|
-
localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
|
|
16336
|
-
}
|
|
16337
|
-
|
|
16338
|
-
if (number < 1) {
|
|
16339
|
-
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
16340
|
-
return prefix + numberString + ' ' + UNITS[0];
|
|
16341
|
-
}
|
|
16342
|
-
|
|
16343
|
-
const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
|
|
16344
|
-
number /= (options.binary ? 1024 : 1000) ** exponent;
|
|
16345
|
-
|
|
16346
|
-
if (!localeOptions) {
|
|
16347
|
-
number = number.toPrecision(3);
|
|
16348
|
-
}
|
|
16349
|
-
|
|
16350
|
-
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
16351
|
-
|
|
16352
|
-
const unit = UNITS[exponent];
|
|
16353
|
-
|
|
16354
|
-
return prefix + numberString + ' ' + unit;
|
|
16355
|
-
}
|
|
16356
|
-
|
|
16357
16240
|
/**
|
|
16358
16241
|
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
16359
16242
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
16360
16243
|
* there is a chance that the iterators will not be fully exhausted.
|
|
16361
16244
|
*/
|
|
16362
|
-
function* concatLazy(iterables) {
|
|
16245
|
+
function* concatLazy(...iterables) {
|
|
16363
16246
|
for (const iterable of iterables) {
|
|
16364
16247
|
yield* iterable;
|
|
16365
16248
|
}
|
|
16366
16249
|
}
|
|
16367
16250
|
|
|
16368
|
-
function getChunkAssignments(
|
|
16251
|
+
function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
|
|
16369
16252
|
const chunkDefinitions = [];
|
|
16370
16253
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
16371
16254
|
const manualChunkModulesByAlias = Object.create(null);
|
|
@@ -16375,19 +16258,53 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
|
|
|
16375
16258
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
16376
16259
|
chunkDefinitions.push({ alias, modules });
|
|
16377
16260
|
}
|
|
16378
|
-
const alreadyLoadedModulesByDynamicEntry = getAlreadyLoadedModulesByDynamicEntry(entries);
|
|
16379
16261
|
const assignedEntryPointsByModule = new Map();
|
|
16380
|
-
|
|
16262
|
+
const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
|
|
16263
|
+
const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
|
|
16264
|
+
const staticEntries = new Set(entryModules);
|
|
16265
|
+
function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
|
|
16266
|
+
const modulesToHandle = new Set([entry]);
|
|
16267
|
+
for (const module of modulesToHandle) {
|
|
16268
|
+
const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
|
|
16269
|
+
if (dynamicDependentEntryPoints &&
|
|
16270
|
+
areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
|
|
16271
|
+
continue;
|
|
16272
|
+
}
|
|
16273
|
+
else {
|
|
16274
|
+
assignedEntryPoints.add(entry);
|
|
16275
|
+
}
|
|
16276
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16277
|
+
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
16278
|
+
modulesToHandle.add(dependency);
|
|
16279
|
+
}
|
|
16280
|
+
}
|
|
16281
|
+
}
|
|
16282
|
+
}
|
|
16283
|
+
function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
|
|
16284
|
+
const entriesToCheck = new Set(entryPoints);
|
|
16285
|
+
for (const entry of entriesToCheck) {
|
|
16286
|
+
if (!containedIn.has(entry)) {
|
|
16287
|
+
if (staticEntries.has(entry))
|
|
16288
|
+
return false;
|
|
16289
|
+
const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
|
|
16290
|
+
for (const dependentEntry of dynamicallyDependentEntryPoints) {
|
|
16291
|
+
entriesToCheck.add(dependentEntry);
|
|
16292
|
+
}
|
|
16293
|
+
}
|
|
16294
|
+
}
|
|
16295
|
+
return true;
|
|
16296
|
+
}
|
|
16297
|
+
for (const entry of entryModules) {
|
|
16381
16298
|
if (!modulesInManualChunks.has(entry)) {
|
|
16382
|
-
assignEntryToStaticDependencies(entry,
|
|
16299
|
+
assignEntryToStaticDependencies(entry, null);
|
|
16383
16300
|
}
|
|
16384
16301
|
}
|
|
16385
|
-
for (const entry of
|
|
16302
|
+
for (const entry of dynamicEntryModules) {
|
|
16386
16303
|
if (!modulesInManualChunks.has(entry)) {
|
|
16387
|
-
assignEntryToStaticDependencies(entry,
|
|
16304
|
+
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
16388
16305
|
}
|
|
16389
16306
|
}
|
|
16390
|
-
chunkDefinitions.push(...createChunks([...
|
|
16307
|
+
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
|
|
16391
16308
|
return chunkDefinitions;
|
|
16392
16309
|
}
|
|
16393
16310
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -16402,87 +16319,47 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
|
|
|
16402
16319
|
}
|
|
16403
16320
|
}
|
|
16404
16321
|
}
|
|
16405
|
-
function
|
|
16406
|
-
const
|
|
16322
|
+
function analyzeModuleGraph(entryModules) {
|
|
16323
|
+
const dynamicEntryModules = new Set();
|
|
16407
16324
|
const dependentEntryPointsByModule = new Map();
|
|
16408
|
-
const dynamicImportsByEntry = new Map();
|
|
16409
|
-
const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
|
|
16410
16325
|
const entriesToHandle = new Set(entryModules);
|
|
16411
16326
|
for (const currentEntry of entriesToHandle) {
|
|
16412
16327
|
const modulesToHandle = new Set([currentEntry]);
|
|
16413
|
-
const dynamicImports = new Set();
|
|
16414
|
-
dynamicImportsByEntry.set(currentEntry, dynamicImports);
|
|
16415
16328
|
for (const module of modulesToHandle) {
|
|
16416
16329
|
getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry);
|
|
16417
16330
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16418
16331
|
if (!(dependency instanceof ExternalModule)) {
|
|
16419
16332
|
modulesToHandle.add(dependency);
|
|
16420
|
-
allModules.add(dependency);
|
|
16421
16333
|
}
|
|
16422
16334
|
}
|
|
16423
16335
|
for (const { resolution } of module.dynamicImports) {
|
|
16424
16336
|
if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
|
|
16425
|
-
|
|
16426
|
-
getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, resolution, () => new Set()).add(currentEntry);
|
|
16337
|
+
dynamicEntryModules.add(resolution);
|
|
16427
16338
|
entriesToHandle.add(resolution);
|
|
16428
|
-
allModules.add(resolution);
|
|
16429
16339
|
}
|
|
16430
16340
|
}
|
|
16431
16341
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
16432
|
-
|
|
16433
|
-
getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dependency, () => new Set()).add(currentEntry);
|
|
16342
|
+
dynamicEntryModules.add(dependency);
|
|
16434
16343
|
entriesToHandle.add(dependency);
|
|
16435
|
-
allModules.add(dependency);
|
|
16436
|
-
}
|
|
16437
|
-
}
|
|
16438
|
-
}
|
|
16439
|
-
return buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry);
|
|
16440
|
-
}
|
|
16441
|
-
function buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry) {
|
|
16442
|
-
const alreadyLoadedModulesByDynamicEntry = new Map();
|
|
16443
|
-
for (const dynamicEntry of dynamicallyDependentEntryPointsByDynamicEntry.keys()) {
|
|
16444
|
-
alreadyLoadedModulesByDynamicEntry.set(dynamicEntry, new Set());
|
|
16445
|
-
}
|
|
16446
|
-
for (const module of allModules) {
|
|
16447
|
-
const dependentEntryPoints = dependentEntryPointsByModule.get(module);
|
|
16448
|
-
for (const entry of dependentEntryPoints) {
|
|
16449
|
-
const dynamicEntriesToHandle = [...dynamicImportsByEntry.get(entry)];
|
|
16450
|
-
nextDynamicEntry: for (const dynamicEntry of dynamicEntriesToHandle) {
|
|
16451
|
-
const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
|
|
16452
|
-
if (alreadyLoadedModules.has(module)) {
|
|
16453
|
-
continue;
|
|
16454
|
-
}
|
|
16455
|
-
for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
|
|
16456
|
-
if (!(dependentEntryPoints.has(siblingDependentEntry) ||
|
|
16457
|
-
alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
|
|
16458
|
-
continue nextDynamicEntry;
|
|
16459
|
-
}
|
|
16460
|
-
}
|
|
16461
|
-
alreadyLoadedModules.add(module);
|
|
16462
|
-
dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
|
|
16463
16344
|
}
|
|
16464
16345
|
}
|
|
16465
16346
|
}
|
|
16466
|
-
return
|
|
16347
|
+
return { dependentEntryPointsByModule, dynamicEntryModules };
|
|
16467
16348
|
}
|
|
16468
|
-
function
|
|
16469
|
-
const
|
|
16470
|
-
for (const
|
|
16471
|
-
const
|
|
16472
|
-
|
|
16473
|
-
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16477
|
-
|
|
16478
|
-
assignedEntryPoints.add(entry);
|
|
16479
|
-
}
|
|
16480
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16481
|
-
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
16482
|
-
modulesToHandle.add(dependency);
|
|
16349
|
+
function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules) {
|
|
16350
|
+
const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
|
|
16351
|
+
for (const dynamicEntry of dynamicEntryModules) {
|
|
16352
|
+
const dynamicDependentEntryPoints = getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dynamicEntry, () => new Set());
|
|
16353
|
+
for (const importer of [
|
|
16354
|
+
...dynamicEntry.includedDynamicImporters,
|
|
16355
|
+
...dynamicEntry.implicitlyLoadedAfter
|
|
16356
|
+
]) {
|
|
16357
|
+
for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
|
|
16358
|
+
dynamicDependentEntryPoints.add(entryPoint);
|
|
16483
16359
|
}
|
|
16484
16360
|
}
|
|
16485
16361
|
}
|
|
16362
|
+
return dynamicallyDependentEntryPointsByDynamicEntry;
|
|
16486
16363
|
}
|
|
16487
16364
|
function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
|
|
16488
16365
|
const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
|
|
@@ -16491,49 +16368,43 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize)
|
|
|
16491
16368
|
alias: null,
|
|
16492
16369
|
modules
|
|
16493
16370
|
}))
|
|
16494
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16495
|
-
alias: null,
|
|
16496
|
-
modules
|
|
16497
|
-
}));
|
|
16371
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
16498
16372
|
}
|
|
16499
|
-
/**
|
|
16500
|
-
* This function tries to get rid of small chunks by merging them with other
|
|
16501
|
-
* chunks. In order to merge chunks, one must obey the following rule:
|
|
16502
|
-
* - When merging several chunks, at most one of the chunks can have side
|
|
16503
|
-
* effects
|
|
16504
|
-
* - When one of the chunks has side effects, the entry points depending on that
|
|
16505
|
-
* chunk need to be a super set of the entry points depending on the other
|
|
16506
|
-
* chunks
|
|
16507
|
-
* - Pure chunks can always be merged
|
|
16508
|
-
* - We use the entry point dependence signature to calculate "chunk distance",
|
|
16509
|
-
* i.e. how likely it is that two chunks are loaded together
|
|
16510
|
-
*/
|
|
16511
16373
|
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16512
16374
|
timeStart('optimize chunks', 3);
|
|
16513
|
-
const
|
|
16514
|
-
|
|
16515
|
-
|
|
16516
|
-
|
|
16517
|
-
|
|
16518
|
-
|
|
16519
|
-
|
|
16520
|
-
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16375
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
16376
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
16377
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
16378
|
+
let closestChunk = null;
|
|
16379
|
+
let closestChunkDistance = Infinity;
|
|
16380
|
+
const { signature, size, modules } = sourceChunk;
|
|
16381
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
16382
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
16383
|
+
if (distance === 1) {
|
|
16384
|
+
closestChunk = targetChunk;
|
|
16385
|
+
break;
|
|
16386
|
+
}
|
|
16387
|
+
else if (distance < closestChunkDistance) {
|
|
16388
|
+
closestChunk = targetChunk;
|
|
16389
|
+
closestChunkDistance = distance;
|
|
16390
|
+
}
|
|
16391
|
+
}
|
|
16392
|
+
if (closestChunk) {
|
|
16393
|
+
closestChunk.modules.push(...modules);
|
|
16394
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
16395
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16396
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
16397
|
+
chunksToBeMerged.delete(closestChunk);
|
|
16398
|
+
unmergeableChunks.push(closestChunk);
|
|
16399
|
+
}
|
|
16400
|
+
}
|
|
16401
|
+
}
|
|
16402
|
+
else {
|
|
16403
|
+
unmergeableChunks.push(sourceChunk);
|
|
16404
|
+
}
|
|
16405
|
+
}
|
|
16528
16406
|
timeEnd('optimize chunks', 3);
|
|
16529
|
-
|
|
16530
|
-
...chunkPartition.small.sideEffect,
|
|
16531
|
-
...chunkPartition.small.pure,
|
|
16532
|
-
...chunkPartition.big.sideEffect,
|
|
16533
|
-
...chunkPartition.big.pure
|
|
16534
|
-
];
|
|
16535
|
-
console.log(`${result.length} chunks remaining.`);
|
|
16536
|
-
return result;
|
|
16407
|
+
return unmergeableChunks;
|
|
16537
16408
|
}
|
|
16538
16409
|
const CHAR_DEPENDENT = 'X';
|
|
16539
16410
|
const CHAR_INDEPENDENT = '_';
|
|
@@ -16555,141 +16426,28 @@ function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints)
|
|
|
16555
16426
|
}
|
|
16556
16427
|
return chunkModules;
|
|
16557
16428
|
}
|
|
16558
|
-
function
|
|
16559
|
-
const
|
|
16560
|
-
const
|
|
16561
|
-
const
|
|
16562
|
-
const bigSideEffectChunks = [];
|
|
16563
|
-
const chunkByModule = new Map();
|
|
16429
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
16430
|
+
const chunksToBeMerged = new Set();
|
|
16431
|
+
const unmergeableChunks = [];
|
|
16432
|
+
const alias = null;
|
|
16564
16433
|
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16565
|
-
const chunkDescription = {
|
|
16566
|
-
dependencies: new Set(),
|
|
16567
|
-
modules,
|
|
16568
|
-
pure: true,
|
|
16569
|
-
signature,
|
|
16570
|
-
size: 0,
|
|
16571
|
-
transitiveDependencies: new Set(),
|
|
16572
|
-
transitiveDependentChunks: new Set()
|
|
16573
|
-
};
|
|
16574
16434
|
let size = 0;
|
|
16575
|
-
|
|
16576
|
-
for (const module of modules) {
|
|
16577
|
-
chunkByModule.set(module, chunkDescription);
|
|
16578
|
-
pure && (pure = !module.hasEffects());
|
|
16579
|
-
size += module.magicString.toString().length;
|
|
16580
|
-
}
|
|
16581
|
-
chunkDescription.pure = pure;
|
|
16582
|
-
chunkDescription.size = size;
|
|
16583
|
-
(size < minChunkSize
|
|
16584
|
-
? pure
|
|
16585
|
-
? smallPureChunks
|
|
16586
|
-
: smallSideEffectChunks
|
|
16587
|
-
: pure
|
|
16588
|
-
? bigPureChunks
|
|
16589
|
-
: bigSideEffectChunks).push(chunkDescription);
|
|
16590
|
-
}
|
|
16591
|
-
sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
|
|
16592
|
-
return {
|
|
16593
|
-
big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
|
|
16594
|
-
small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
|
|
16595
|
-
};
|
|
16596
|
-
}
|
|
16597
|
-
function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
16598
|
-
for (const chunks of chunkLists) {
|
|
16599
|
-
chunks.sort(compareChunks);
|
|
16600
|
-
for (const chunk of chunks) {
|
|
16601
|
-
const { dependencies, modules, transitiveDependencies } = chunk;
|
|
16602
|
-
const transitiveDependencyModules = new Set();
|
|
16435
|
+
checkModules: {
|
|
16603
16436
|
for (const module of modules) {
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
16607
|
-
dependencies.add(dependencyChunk);
|
|
16608
|
-
transitiveDependencyModules.add(dependency);
|
|
16609
|
-
}
|
|
16610
|
-
}
|
|
16611
|
-
}
|
|
16612
|
-
for (const module of transitiveDependencyModules) {
|
|
16613
|
-
const transitiveDependency = chunkByModule.get(module);
|
|
16614
|
-
if (transitiveDependency !== chunk) {
|
|
16615
|
-
transitiveDependencies.add(transitiveDependency);
|
|
16616
|
-
transitiveDependency.transitiveDependentChunks.add(chunk);
|
|
16617
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16618
|
-
if (!(dependency instanceof ExternalModule)) {
|
|
16619
|
-
transitiveDependencyModules.add(dependency);
|
|
16620
|
-
}
|
|
16621
|
-
}
|
|
16622
|
-
}
|
|
16623
|
-
}
|
|
16624
|
-
}
|
|
16625
|
-
}
|
|
16626
|
-
}
|
|
16627
|
-
function compareChunks({ size: sizeA }, { size: sizeB }) {
|
|
16628
|
-
return sizeA - sizeB;
|
|
16629
|
-
}
|
|
16630
|
-
function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
|
|
16631
|
-
for (const mergedChunk of chunksToBeMerged) {
|
|
16632
|
-
let closestChunk = null;
|
|
16633
|
-
let closestChunkDistance = Infinity;
|
|
16634
|
-
const { signature, modules, pure, size } = mergedChunk;
|
|
16635
|
-
for (const targetChunk of concatLazy(targetChunks)) {
|
|
16636
|
-
if (mergedChunk === targetChunk)
|
|
16637
|
-
continue;
|
|
16638
|
-
const distance = pure
|
|
16639
|
-
? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
|
|
16640
|
-
: getSignatureDistance(targetChunk.signature, signature, true);
|
|
16641
|
-
if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
|
|
16642
|
-
if (distance === 1) {
|
|
16643
|
-
closestChunk = targetChunk;
|
|
16644
|
-
break;
|
|
16437
|
+
if (module.hasEffects()) {
|
|
16438
|
+
break checkModules;
|
|
16645
16439
|
}
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
|
|
16649
|
-
}
|
|
16650
|
-
if (closestChunk) {
|
|
16651
|
-
chunksToBeMerged.delete(mergedChunk);
|
|
16652
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16653
|
-
closestChunk.modules.push(...modules);
|
|
16654
|
-
closestChunk.size += size;
|
|
16655
|
-
closestChunk.pure && (closestChunk.pure = pure);
|
|
16656
|
-
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16657
|
-
const { dependencies, transitiveDependencies, transitiveDependentChunks } = closestChunk;
|
|
16658
|
-
for (const dependency of mergedChunk.dependencies) {
|
|
16659
|
-
dependencies.add(dependency);
|
|
16660
|
-
}
|
|
16661
|
-
for (const dependency of mergedChunk.transitiveDependencies) {
|
|
16662
|
-
transitiveDependencies.add(dependency);
|
|
16663
|
-
dependency.transitiveDependentChunks.delete(mergedChunk);
|
|
16664
|
-
dependency.transitiveDependentChunks.add(closestChunk);
|
|
16665
|
-
}
|
|
16666
|
-
for (const dependentChunk of mergedChunk.transitiveDependentChunks) {
|
|
16667
|
-
transitiveDependentChunks.add(dependentChunk);
|
|
16668
|
-
if (dependentChunk.dependencies.has(mergedChunk)) {
|
|
16669
|
-
dependentChunk.dependencies.delete(mergedChunk);
|
|
16670
|
-
dependentChunk.dependencies.add(closestChunk);
|
|
16440
|
+
size += module.magicString.toString().length;
|
|
16441
|
+
if (size > minChunkSize) {
|
|
16442
|
+
break checkModules;
|
|
16671
16443
|
}
|
|
16672
|
-
dependentChunk.transitiveDependencies.delete(mergedChunk);
|
|
16673
|
-
dependentChunk.transitiveDependencies.add(closestChunk);
|
|
16674
16444
|
}
|
|
16675
|
-
|
|
16676
|
-
|
|
16677
|
-
transitiveDependentChunks.delete(closestChunk);
|
|
16678
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16445
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
16446
|
+
continue;
|
|
16679
16447
|
}
|
|
16448
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
16680
16449
|
}
|
|
16681
|
-
}
|
|
16682
|
-
// If a module is a transitive but not a direct dependency of the other chunk,
|
|
16683
|
-
// merging is prohibited as that would create a new cyclic dependency.
|
|
16684
|
-
function isValidMerge(mergedChunk, targetChunk) {
|
|
16685
|
-
return ((!targetChunk.transitiveDependencies.has(mergedChunk) ||
|
|
16686
|
-
targetChunk.dependencies.has(mergedChunk)) &&
|
|
16687
|
-
(!mergedChunk.transitiveDependencies.has(targetChunk) ||
|
|
16688
|
-
mergedChunk.dependencies.has(targetChunk)));
|
|
16689
|
-
}
|
|
16690
|
-
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
16691
|
-
const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
16692
|
-
return chunk.pure ? subPartition.pure : subPartition.sideEffect;
|
|
16450
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
16693
16451
|
}
|
|
16694
16452
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16695
16453
|
let distance = 0;
|
|
@@ -25523,7 +25281,6 @@ exports.loadFsEvents = loadFsEvents;
|
|
|
25523
25281
|
exports.mergeOptions = mergeOptions;
|
|
25524
25282
|
exports.normalizePluginOption = normalizePluginOption;
|
|
25525
25283
|
exports.picomatch = picomatch$1;
|
|
25526
|
-
exports.prettyBytes = prettyBytes;
|
|
25527
25284
|
exports.printQuotedStringList = printQuotedStringList;
|
|
25528
25285
|
exports.relativeId = relativeId;
|
|
25529
25286
|
exports.rollup = rollup;
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED