rollup 3.7.3-0 → 3.7.4
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 +94 -370
- 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 +94 -371
- 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.7.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.7.4
|
|
4
|
+
Tue, 13 Dec 2022 05:29:18 GMT - commit bd3522b33f18001372638263aeb704b76edbf48c
|
|
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.7.
|
|
34
|
+
var version$1 = "3.7.4";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -5553,6 +5553,11 @@ const literalNumberMembers = assembleMemberDescriptions({
|
|
|
5553
5553
|
toPrecision: returnsString,
|
|
5554
5554
|
valueOf: returnsNumber
|
|
5555
5555
|
}, objectMembers);
|
|
5556
|
+
/**
|
|
5557
|
+
* RegExp are stateful when they have the global or sticky flags set.
|
|
5558
|
+
* But if we actually don't use them, the side effect does not matter.
|
|
5559
|
+
* the check logic in `hasEffectsOnInteractionAtPath`.
|
|
5560
|
+
*/
|
|
5556
5561
|
const literalRegExpMembers = assembleMemberDescriptions({
|
|
5557
5562
|
exec: returnsUnknown,
|
|
5558
5563
|
test: returnsBoolean
|
|
@@ -9426,6 +9431,11 @@ class Literal extends NodeBase {
|
|
|
9426
9431
|
return true;
|
|
9427
9432
|
}
|
|
9428
9433
|
case INTERACTION_CALLED: {
|
|
9434
|
+
if (this.included &&
|
|
9435
|
+
this.value instanceof RegExp &&
|
|
9436
|
+
(this.value.global || this.value.sticky)) {
|
|
9437
|
+
return true;
|
|
9438
|
+
}
|
|
9429
9439
|
return (path.length !== 1 ||
|
|
9430
9440
|
hasMemberEffectWhenCalled(this.members, path[0], interaction, context));
|
|
9431
9441
|
}
|
|
@@ -11784,12 +11794,7 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11784
11794
|
class Program extends NodeBase {
|
|
11785
11795
|
constructor() {
|
|
11786
11796
|
super(...arguments);
|
|
11787
|
-
this.hasCachedEffect =
|
|
11788
|
-
}
|
|
11789
|
-
hasCachedEffects() {
|
|
11790
|
-
return this.hasCachedEffect === null
|
|
11791
|
-
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11792
|
-
: this.hasCachedEffect;
|
|
11797
|
+
this.hasCachedEffect = false;
|
|
11793
11798
|
}
|
|
11794
11799
|
hasEffects(context) {
|
|
11795
11800
|
// We are caching here to later more efficiently identify side-effect-free modules
|
|
@@ -13649,7 +13654,8 @@ class Module {
|
|
|
13649
13654
|
return [null];
|
|
13650
13655
|
}
|
|
13651
13656
|
hasEffects() {
|
|
13652
|
-
return this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13657
|
+
return (this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13658
|
+
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13653
13659
|
}
|
|
13654
13660
|
include() {
|
|
13655
13661
|
const context = createInclusionContext();
|
|
@@ -15294,7 +15300,6 @@ class Chunk {
|
|
|
15294
15300
|
this.entryModules = [];
|
|
15295
15301
|
this.exportMode = 'named';
|
|
15296
15302
|
this.facadeModule = null;
|
|
15297
|
-
this.id = null;
|
|
15298
15303
|
this.namespaceVariableName = '';
|
|
15299
15304
|
this.variableName = '';
|
|
15300
15305
|
this.accessedGlobalsByScope = new Map();
|
|
@@ -15385,6 +15390,25 @@ class Chunk {
|
|
|
15385
15390
|
}
|
|
15386
15391
|
return true;
|
|
15387
15392
|
}
|
|
15393
|
+
finalizeChunk(code, map, hashesByPlaceholder) {
|
|
15394
|
+
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
15395
|
+
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
15396
|
+
const fileName = (this.fileName = finalize(renderedChunkInfo.fileName));
|
|
15397
|
+
return {
|
|
15398
|
+
...renderedChunkInfo,
|
|
15399
|
+
code,
|
|
15400
|
+
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
15401
|
+
fileName,
|
|
15402
|
+
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
15403
|
+
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
15404
|
+
finalize(fileName),
|
|
15405
|
+
bindings
|
|
15406
|
+
])),
|
|
15407
|
+
imports: renderedChunkInfo.imports.map(finalize),
|
|
15408
|
+
map,
|
|
15409
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
15410
|
+
};
|
|
15411
|
+
}
|
|
15388
15412
|
generateExports() {
|
|
15389
15413
|
this.sortedExportNames = null;
|
|
15390
15414
|
const remainingExports = new Set(this.exports);
|
|
@@ -15477,24 +15501,6 @@ class Chunk {
|
|
|
15477
15501
|
}
|
|
15478
15502
|
return facades;
|
|
15479
15503
|
}
|
|
15480
|
-
generateOutputChunk(code, map, hashesByPlaceholder) {
|
|
15481
|
-
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
15482
|
-
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
15483
|
-
return {
|
|
15484
|
-
...renderedChunkInfo,
|
|
15485
|
-
code,
|
|
15486
|
-
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
15487
|
-
fileName: finalize(renderedChunkInfo.fileName),
|
|
15488
|
-
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
15489
|
-
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
15490
|
-
finalize(fileName),
|
|
15491
|
-
bindings
|
|
15492
|
-
])),
|
|
15493
|
-
imports: renderedChunkInfo.imports.map(finalize),
|
|
15494
|
-
map,
|
|
15495
|
-
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
15496
|
-
};
|
|
15497
|
-
}
|
|
15498
15504
|
getChunkName() {
|
|
15499
15505
|
return (this.name ?? (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
15500
15506
|
}
|
|
@@ -15502,7 +15508,7 @@ class Chunk {
|
|
|
15502
15508
|
return (this.sortedExportNames ?? (this.sortedExportNames = [...this.exportsByName.keys()].sort()));
|
|
15503
15509
|
}
|
|
15504
15510
|
getFileName() {
|
|
15505
|
-
return this.
|
|
15511
|
+
return this.fileName || this.getPreliminaryFileName().fileName;
|
|
15506
15512
|
}
|
|
15507
15513
|
getImportPath(importer) {
|
|
15508
15514
|
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
@@ -16248,132 +16254,12 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
16248
16254
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
16249
16255
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
16250
16256
|
|
|
16251
|
-
const BYTE_UNITS = [
|
|
16252
|
-
'B',
|
|
16253
|
-
'kB',
|
|
16254
|
-
'MB',
|
|
16255
|
-
'GB',
|
|
16256
|
-
'TB',
|
|
16257
|
-
'PB',
|
|
16258
|
-
'EB',
|
|
16259
|
-
'ZB',
|
|
16260
|
-
'YB',
|
|
16261
|
-
];
|
|
16262
|
-
|
|
16263
|
-
const BIBYTE_UNITS = [
|
|
16264
|
-
'B',
|
|
16265
|
-
'kiB',
|
|
16266
|
-
'MiB',
|
|
16267
|
-
'GiB',
|
|
16268
|
-
'TiB',
|
|
16269
|
-
'PiB',
|
|
16270
|
-
'EiB',
|
|
16271
|
-
'ZiB',
|
|
16272
|
-
'YiB',
|
|
16273
|
-
];
|
|
16274
|
-
|
|
16275
|
-
const BIT_UNITS = [
|
|
16276
|
-
'b',
|
|
16277
|
-
'kbit',
|
|
16278
|
-
'Mbit',
|
|
16279
|
-
'Gbit',
|
|
16280
|
-
'Tbit',
|
|
16281
|
-
'Pbit',
|
|
16282
|
-
'Ebit',
|
|
16283
|
-
'Zbit',
|
|
16284
|
-
'Ybit',
|
|
16285
|
-
];
|
|
16286
|
-
|
|
16287
|
-
const BIBIT_UNITS = [
|
|
16288
|
-
'b',
|
|
16289
|
-
'kibit',
|
|
16290
|
-
'Mibit',
|
|
16291
|
-
'Gibit',
|
|
16292
|
-
'Tibit',
|
|
16293
|
-
'Pibit',
|
|
16294
|
-
'Eibit',
|
|
16295
|
-
'Zibit',
|
|
16296
|
-
'Yibit',
|
|
16297
|
-
];
|
|
16298
|
-
|
|
16299
|
-
/*
|
|
16300
|
-
Formats the given number using `Number#toLocaleString`.
|
|
16301
|
-
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
16302
|
-
- If locale is true, the system default locale is used for translation.
|
|
16303
|
-
- If no value for locale is specified, the number is returned unmodified.
|
|
16304
|
-
*/
|
|
16305
|
-
const toLocaleString = (number, locale, options) => {
|
|
16306
|
-
let result = number;
|
|
16307
|
-
if (typeof locale === 'string' || Array.isArray(locale)) {
|
|
16308
|
-
result = number.toLocaleString(locale, options);
|
|
16309
|
-
} else if (locale === true || options !== undefined) {
|
|
16310
|
-
result = number.toLocaleString(undefined, options);
|
|
16311
|
-
}
|
|
16312
|
-
|
|
16313
|
-
return result;
|
|
16314
|
-
};
|
|
16315
|
-
|
|
16316
|
-
function prettyBytes(number, options) {
|
|
16317
|
-
if (!Number.isFinite(number)) {
|
|
16318
|
-
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
16319
|
-
}
|
|
16320
|
-
|
|
16321
|
-
options = {
|
|
16322
|
-
bits: false,
|
|
16323
|
-
binary: false,
|
|
16324
|
-
...options,
|
|
16325
|
-
};
|
|
16326
|
-
|
|
16327
|
-
const UNITS = options.bits
|
|
16328
|
-
? (options.binary ? BIBIT_UNITS : BIT_UNITS)
|
|
16329
|
-
: (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
|
|
16330
|
-
|
|
16331
|
-
if (options.signed && number === 0) {
|
|
16332
|
-
return ` 0 ${UNITS[0]}`;
|
|
16333
|
-
}
|
|
16334
|
-
|
|
16335
|
-
const isNegative = number < 0;
|
|
16336
|
-
const prefix = isNegative ? '-' : (options.signed ? '+' : '');
|
|
16337
|
-
|
|
16338
|
-
if (isNegative) {
|
|
16339
|
-
number = -number;
|
|
16340
|
-
}
|
|
16341
|
-
|
|
16342
|
-
let localeOptions;
|
|
16343
|
-
|
|
16344
|
-
if (options.minimumFractionDigits !== undefined) {
|
|
16345
|
-
localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
|
|
16346
|
-
}
|
|
16347
|
-
|
|
16348
|
-
if (options.maximumFractionDigits !== undefined) {
|
|
16349
|
-
localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
|
|
16350
|
-
}
|
|
16351
|
-
|
|
16352
|
-
if (number < 1) {
|
|
16353
|
-
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
16354
|
-
return prefix + numberString + ' ' + UNITS[0];
|
|
16355
|
-
}
|
|
16356
|
-
|
|
16357
|
-
const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
|
|
16358
|
-
number /= (options.binary ? 1024 : 1000) ** exponent;
|
|
16359
|
-
|
|
16360
|
-
if (!localeOptions) {
|
|
16361
|
-
number = number.toPrecision(3);
|
|
16362
|
-
}
|
|
16363
|
-
|
|
16364
|
-
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
16365
|
-
|
|
16366
|
-
const unit = UNITS[exponent];
|
|
16367
|
-
|
|
16368
|
-
return prefix + numberString + ' ' + unit;
|
|
16369
|
-
}
|
|
16370
|
-
|
|
16371
16257
|
/**
|
|
16372
16258
|
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
16373
16259
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
16374
16260
|
* there is a chance that the iterators will not be fully exhausted.
|
|
16375
16261
|
*/
|
|
16376
|
-
function* concatLazy(iterables) {
|
|
16262
|
+
function* concatLazy(...iterables) {
|
|
16377
16263
|
for (const iterable of iterables) {
|
|
16378
16264
|
yield* iterable;
|
|
16379
16265
|
}
|
|
@@ -16514,11 +16400,47 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16514
16400
|
alias: null,
|
|
16515
16401
|
modules
|
|
16516
16402
|
}))
|
|
16517
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16518
|
-
alias: null,
|
|
16519
|
-
modules
|
|
16520
|
-
}));
|
|
16403
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
16521
16404
|
}
|
|
16405
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16406
|
+
timeStart('optimize chunks', 3);
|
|
16407
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
16408
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
16409
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
16410
|
+
let closestChunk = null;
|
|
16411
|
+
let closestChunkDistance = Infinity;
|
|
16412
|
+
const { signature, size, modules } = sourceChunk;
|
|
16413
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
16414
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
16415
|
+
if (distance === 1) {
|
|
16416
|
+
closestChunk = targetChunk;
|
|
16417
|
+
break;
|
|
16418
|
+
}
|
|
16419
|
+
else if (distance < closestChunkDistance) {
|
|
16420
|
+
closestChunk = targetChunk;
|
|
16421
|
+
closestChunkDistance = distance;
|
|
16422
|
+
}
|
|
16423
|
+
}
|
|
16424
|
+
if (closestChunk) {
|
|
16425
|
+
closestChunk.modules.push(...modules);
|
|
16426
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
16427
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16428
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
16429
|
+
chunksToBeMerged.delete(closestChunk);
|
|
16430
|
+
unmergeableChunks.push(closestChunk);
|
|
16431
|
+
}
|
|
16432
|
+
}
|
|
16433
|
+
}
|
|
16434
|
+
else {
|
|
16435
|
+
unmergeableChunks.push(sourceChunk);
|
|
16436
|
+
}
|
|
16437
|
+
}
|
|
16438
|
+
timeEnd('optimize chunks', 3);
|
|
16439
|
+
return unmergeableChunks;
|
|
16440
|
+
}
|
|
16441
|
+
const CHAR_DEPENDENT = 'X';
|
|
16442
|
+
const CHAR_INDEPENDENT = '_';
|
|
16443
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16522
16444
|
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16523
16445
|
const chunkModules = Object.create(null);
|
|
16524
16446
|
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
@@ -16536,225 +16458,28 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16536
16458
|
}
|
|
16537
16459
|
return chunkModules;
|
|
16538
16460
|
}
|
|
16539
|
-
|
|
16540
|
-
|
|
16541
|
-
|
|
16542
|
-
|
|
16543
|
-
* effects
|
|
16544
|
-
* - When one of the chunks has side effects, the entry points depending on that
|
|
16545
|
-
* chunk need to be a super set of the entry points depending on the other
|
|
16546
|
-
* chunks
|
|
16547
|
-
* - Pure chunks can always be merged
|
|
16548
|
-
* - We use the entry point dependence signature to calculate "chunk distance",
|
|
16549
|
-
* i.e. how likely it is that two chunks are loaded together
|
|
16550
|
-
*/
|
|
16551
|
-
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16552
|
-
timeStart('optimize chunks', 3);
|
|
16553
|
-
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
|
|
16554
|
-
console.log(`Created ${chunkPartition.big.pure.size +
|
|
16555
|
-
chunkPartition.big.sideEffect.size +
|
|
16556
|
-
chunkPartition.small.pure.size +
|
|
16557
|
-
chunkPartition.small.sideEffect.size} chunks
|
|
16558
|
-
----- pure side effects
|
|
16559
|
-
small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
|
|
16560
|
-
big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
|
|
16561
|
-
Unoptimized chunks contain ${getNumberOfCycles(chunkPartition)} cycles.
|
|
16562
|
-
`);
|
|
16563
|
-
console.log(`Trying to find merge targets for ${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`);
|
|
16564
|
-
mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16565
|
-
console.log(`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(minChunkSize)} with side effects remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
|
|
16566
|
-
console.log(`Trying to find merge targets for ${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)}...`);
|
|
16567
|
-
mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16568
|
-
console.log(`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(minChunkSize)} remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`);
|
|
16569
|
-
timeEnd('optimize chunks', 3);
|
|
16570
|
-
const result = [
|
|
16571
|
-
...chunkPartition.small.sideEffect,
|
|
16572
|
-
...chunkPartition.small.pure,
|
|
16573
|
-
...chunkPartition.big.sideEffect,
|
|
16574
|
-
...chunkPartition.big.pure
|
|
16575
|
-
];
|
|
16576
|
-
console.log(`${result.length} chunks remaining.`);
|
|
16577
|
-
return result;
|
|
16578
|
-
}
|
|
16579
|
-
const CHAR_DEPENDENT = 'X';
|
|
16580
|
-
const CHAR_INDEPENDENT = '_';
|
|
16581
|
-
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16582
|
-
function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16583
|
-
const smallPureChunks = [];
|
|
16584
|
-
const bigPureChunks = [];
|
|
16585
|
-
const smallSideEffectChunks = [];
|
|
16586
|
-
const bigSideEffectChunks = [];
|
|
16587
|
-
const chunkByModule = new Map();
|
|
16461
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
16462
|
+
const chunksToBeMerged = new Set();
|
|
16463
|
+
const unmergeableChunks = [];
|
|
16464
|
+
const alias = null;
|
|
16588
16465
|
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16589
|
-
const chunkDescription = {
|
|
16590
|
-
dependencies: new Set(),
|
|
16591
|
-
modules,
|
|
16592
|
-
pure: true,
|
|
16593
|
-
signature,
|
|
16594
|
-
size: 0,
|
|
16595
|
-
transitiveDependencies: new Set(),
|
|
16596
|
-
transitiveDependentChunks: new Set()
|
|
16597
|
-
};
|
|
16598
16466
|
let size = 0;
|
|
16599
|
-
|
|
16600
|
-
for (const module of modules) {
|
|
16601
|
-
chunkByModule.set(module, chunkDescription);
|
|
16602
|
-
pure && (pure = !module.hasEffects());
|
|
16603
|
-
size += module.magicString.toString().length;
|
|
16604
|
-
}
|
|
16605
|
-
chunkDescription.pure = pure;
|
|
16606
|
-
chunkDescription.size = size;
|
|
16607
|
-
(size < minChunkSize
|
|
16608
|
-
? pure
|
|
16609
|
-
? smallPureChunks
|
|
16610
|
-
: smallSideEffectChunks
|
|
16611
|
-
: pure
|
|
16612
|
-
? bigPureChunks
|
|
16613
|
-
: bigSideEffectChunks).push(chunkDescription);
|
|
16614
|
-
}
|
|
16615
|
-
sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
|
|
16616
|
-
return {
|
|
16617
|
-
big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
|
|
16618
|
-
small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
|
|
16619
|
-
};
|
|
16620
|
-
}
|
|
16621
|
-
function getNumberOfCycles(partition) {
|
|
16622
|
-
const parents = new Set();
|
|
16623
|
-
const analysedChunks = new Set();
|
|
16624
|
-
let cycles = 0;
|
|
16625
|
-
const analyseChunk = (chunk) => {
|
|
16626
|
-
for (const dependency of chunk.dependencies) {
|
|
16627
|
-
if (parents.has(dependency)) {
|
|
16628
|
-
if (!analysedChunks.has(dependency)) {
|
|
16629
|
-
cycles++;
|
|
16630
|
-
}
|
|
16631
|
-
continue;
|
|
16632
|
-
}
|
|
16633
|
-
parents.add(dependency);
|
|
16634
|
-
analyseChunk(dependency);
|
|
16635
|
-
}
|
|
16636
|
-
analysedChunks.add(chunk);
|
|
16637
|
-
};
|
|
16638
|
-
for (const chunk of [
|
|
16639
|
-
...partition.big.pure,
|
|
16640
|
-
...partition.big.sideEffect,
|
|
16641
|
-
...partition.small.pure,
|
|
16642
|
-
...partition.small.sideEffect
|
|
16643
|
-
]) {
|
|
16644
|
-
if (!parents.has(chunk)) {
|
|
16645
|
-
parents.add(chunk);
|
|
16646
|
-
analyseChunk(chunk);
|
|
16647
|
-
}
|
|
16648
|
-
}
|
|
16649
|
-
return cycles;
|
|
16650
|
-
}
|
|
16651
|
-
function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
16652
|
-
for (const chunks of chunkLists) {
|
|
16653
|
-
chunks.sort(compareChunks);
|
|
16654
|
-
for (const chunk of chunks) {
|
|
16655
|
-
const { dependencies, modules, transitiveDependencies } = chunk;
|
|
16656
|
-
const transitiveDependencyModules = new Set();
|
|
16467
|
+
checkModules: {
|
|
16657
16468
|
for (const module of modules) {
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
16661
|
-
dependencies.add(dependencyChunk);
|
|
16662
|
-
transitiveDependencyModules.add(dependency);
|
|
16663
|
-
}
|
|
16469
|
+
if (module.hasEffects()) {
|
|
16470
|
+
break checkModules;
|
|
16664
16471
|
}
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
16668
|
-
if (transitiveDependency !== chunk) {
|
|
16669
|
-
transitiveDependencies.add(transitiveDependency);
|
|
16670
|
-
transitiveDependency.transitiveDependentChunks.add(chunk);
|
|
16671
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16672
|
-
if (!(dependency instanceof ExternalModule)) {
|
|
16673
|
-
transitiveDependencyModules.add(dependency);
|
|
16674
|
-
}
|
|
16675
|
-
}
|
|
16472
|
+
size += module.magicString.toString().length;
|
|
16473
|
+
if (size > minChunkSize) {
|
|
16474
|
+
break checkModules;
|
|
16676
16475
|
}
|
|
16677
16476
|
}
|
|
16477
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
16478
|
+
continue;
|
|
16678
16479
|
}
|
|
16480
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
16679
16481
|
}
|
|
16680
|
-
}
|
|
16681
|
-
function compareChunks({ size: sizeA }, { size: sizeB }) {
|
|
16682
|
-
return sizeA - sizeB;
|
|
16683
|
-
}
|
|
16684
|
-
function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
|
|
16685
|
-
for (const mergedChunk of chunksToBeMerged) {
|
|
16686
|
-
let closestChunk = null;
|
|
16687
|
-
let closestChunkDistance = Infinity;
|
|
16688
|
-
const { signature, modules, pure, size } = mergedChunk;
|
|
16689
|
-
for (const targetChunk of concatLazy(targetChunks)) {
|
|
16690
|
-
if (mergedChunk === targetChunk)
|
|
16691
|
-
continue;
|
|
16692
|
-
const distance = pure
|
|
16693
|
-
? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
|
|
16694
|
-
: getSignatureDistance(targetChunk.signature, signature, true);
|
|
16695
|
-
if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
|
|
16696
|
-
if (distance === 1) {
|
|
16697
|
-
closestChunk = targetChunk;
|
|
16698
|
-
break;
|
|
16699
|
-
}
|
|
16700
|
-
closestChunk = targetChunk;
|
|
16701
|
-
closestChunkDistance = distance;
|
|
16702
|
-
}
|
|
16703
|
-
}
|
|
16704
|
-
if (closestChunk) {
|
|
16705
|
-
chunksToBeMerged.delete(mergedChunk);
|
|
16706
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16707
|
-
closestChunk.modules.push(...modules);
|
|
16708
|
-
closestChunk.size += size;
|
|
16709
|
-
closestChunk.pure && (closestChunk.pure = pure);
|
|
16710
|
-
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16711
|
-
const { dependencies, transitiveDependencies, transitiveDependentChunks } = closestChunk;
|
|
16712
|
-
for (const dependency of mergedChunk.dependencies) {
|
|
16713
|
-
dependencies.add(dependency);
|
|
16714
|
-
}
|
|
16715
|
-
for (const dependency of mergedChunk.transitiveDependencies) {
|
|
16716
|
-
transitiveDependencies.add(dependency);
|
|
16717
|
-
dependency.transitiveDependentChunks.delete(mergedChunk);
|
|
16718
|
-
dependency.transitiveDependentChunks.add(closestChunk);
|
|
16719
|
-
}
|
|
16720
|
-
for (const dependentChunk of mergedChunk.transitiveDependentChunks) {
|
|
16721
|
-
transitiveDependentChunks.add(dependentChunk);
|
|
16722
|
-
if (dependentChunk.dependencies.has(mergedChunk)) {
|
|
16723
|
-
dependentChunk.dependencies.delete(mergedChunk);
|
|
16724
|
-
dependentChunk.dependencies.add(closestChunk);
|
|
16725
|
-
}
|
|
16726
|
-
dependentChunk.transitiveDependencies.delete(mergedChunk);
|
|
16727
|
-
dependentChunk.transitiveDependencies.add(closestChunk);
|
|
16728
|
-
}
|
|
16729
|
-
dependencies.delete(closestChunk);
|
|
16730
|
-
transitiveDependencies.delete(closestChunk);
|
|
16731
|
-
transitiveDependentChunks.delete(closestChunk);
|
|
16732
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16733
|
-
}
|
|
16734
|
-
}
|
|
16735
|
-
}
|
|
16736
|
-
// Merging will not produce cycles if
|
|
16737
|
-
// - no chunk is a transitive dependency of the other, or
|
|
16738
|
-
// - none of the direct non-merged dependencies of a chunk have the other
|
|
16739
|
-
// chunk as a transitive dependency
|
|
16740
|
-
function isValidMerge(mergedChunk, targetChunk) {
|
|
16741
|
-
return !(hasTransitiveDependency(mergedChunk, targetChunk) ||
|
|
16742
|
-
hasTransitiveDependency(targetChunk, mergedChunk));
|
|
16743
|
-
}
|
|
16744
|
-
function hasTransitiveDependency(dependentChunk, dependencyChunk) {
|
|
16745
|
-
if (!dependentChunk.transitiveDependencies.has(dependencyChunk)) {
|
|
16746
|
-
return false;
|
|
16747
|
-
}
|
|
16748
|
-
for (const dependency of dependentChunk.dependencies) {
|
|
16749
|
-
if (dependency.transitiveDependencies.has(dependencyChunk)) {
|
|
16750
|
-
return true;
|
|
16751
|
-
}
|
|
16752
|
-
}
|
|
16753
|
-
return false;
|
|
16754
|
-
}
|
|
16755
|
-
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
16756
|
-
const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
16757
|
-
return chunk.pure ? subPartition.pure : subPartition.sideEffect;
|
|
16482
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
16758
16483
|
}
|
|
16759
16484
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16760
16485
|
let distance = 0;
|
|
@@ -17258,14 +16983,14 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
17258
16983
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
17259
16984
|
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
17260
16985
|
}
|
|
17261
|
-
bundle[finalFileName] = chunk.
|
|
16986
|
+
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
17262
16987
|
}
|
|
17263
16988
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
17264
16989
|
let updatedCode = hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code;
|
|
17265
16990
|
if (map) {
|
|
17266
16991
|
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
17267
16992
|
}
|
|
17268
|
-
bundle[fileName] = chunk.
|
|
16993
|
+
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
17269
16994
|
}
|
|
17270
16995
|
}
|
|
17271
16996
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -23808,8 +23533,7 @@ function getChunkFileName(file, facadeChunkByModule) {
|
|
|
23808
23533
|
return file.fileName;
|
|
23809
23534
|
}
|
|
23810
23535
|
if (facadeChunkByModule) {
|
|
23811
|
-
|
|
23812
|
-
return chunk.id || chunk.getFileName();
|
|
23536
|
+
return facadeChunkByModule.get(file.module).getFileName();
|
|
23813
23537
|
}
|
|
23814
23538
|
return error(errorChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
23815
23539
|
}
|
|
@@ -25589,7 +25313,6 @@ exports.loadFsEvents = loadFsEvents;
|
|
|
25589
25313
|
exports.mergeOptions = mergeOptions;
|
|
25590
25314
|
exports.normalizePluginOption = normalizePluginOption;
|
|
25591
25315
|
exports.picomatch = picomatch$1;
|
|
25592
|
-
exports.prettyBytes = prettyBytes;
|
|
25593
25316
|
exports.printQuotedStringList = printQuotedStringList;
|
|
25594
25317
|
exports.relativeId = relativeId;
|
|
25595
25318
|
exports.rollup = rollup;
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED