rollup 3.7.3-0 → 3.7.3
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 +84 -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 +84 -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.3
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.7.3
|
|
4
|
+
Sun, 11 Dec 2022 15:24:30 GMT - commit a0d4d69092484a0879377e16425b737ec541ae55
|
|
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.3
|
|
34
|
+
var version$1 = "3.7.3";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -11784,12 +11784,7 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11784
11784
|
class Program extends NodeBase {
|
|
11785
11785
|
constructor() {
|
|
11786
11786
|
super(...arguments);
|
|
11787
|
-
this.hasCachedEffect =
|
|
11788
|
-
}
|
|
11789
|
-
hasCachedEffects() {
|
|
11790
|
-
return this.hasCachedEffect === null
|
|
11791
|
-
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11792
|
-
: this.hasCachedEffect;
|
|
11787
|
+
this.hasCachedEffect = false;
|
|
11793
11788
|
}
|
|
11794
11789
|
hasEffects(context) {
|
|
11795
11790
|
// We are caching here to later more efficiently identify side-effect-free modules
|
|
@@ -13649,7 +13644,8 @@ class Module {
|
|
|
13649
13644
|
return [null];
|
|
13650
13645
|
}
|
|
13651
13646
|
hasEffects() {
|
|
13652
|
-
return this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13647
|
+
return (this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13648
|
+
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13653
13649
|
}
|
|
13654
13650
|
include() {
|
|
13655
13651
|
const context = createInclusionContext();
|
|
@@ -15294,7 +15290,6 @@ class Chunk {
|
|
|
15294
15290
|
this.entryModules = [];
|
|
15295
15291
|
this.exportMode = 'named';
|
|
15296
15292
|
this.facadeModule = null;
|
|
15297
|
-
this.id = null;
|
|
15298
15293
|
this.namespaceVariableName = '';
|
|
15299
15294
|
this.variableName = '';
|
|
15300
15295
|
this.accessedGlobalsByScope = new Map();
|
|
@@ -15385,6 +15380,25 @@ class Chunk {
|
|
|
15385
15380
|
}
|
|
15386
15381
|
return true;
|
|
15387
15382
|
}
|
|
15383
|
+
finalizeChunk(code, map, hashesByPlaceholder) {
|
|
15384
|
+
const renderedChunkInfo = this.getRenderedChunkInfo();
|
|
15385
|
+
const finalize = (code) => replacePlaceholders(code, hashesByPlaceholder);
|
|
15386
|
+
const fileName = (this.fileName = finalize(renderedChunkInfo.fileName));
|
|
15387
|
+
return {
|
|
15388
|
+
...renderedChunkInfo,
|
|
15389
|
+
code,
|
|
15390
|
+
dynamicImports: renderedChunkInfo.dynamicImports.map(finalize),
|
|
15391
|
+
fileName,
|
|
15392
|
+
implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize),
|
|
15393
|
+
importedBindings: Object.fromEntries(Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [
|
|
15394
|
+
finalize(fileName),
|
|
15395
|
+
bindings
|
|
15396
|
+
])),
|
|
15397
|
+
imports: renderedChunkInfo.imports.map(finalize),
|
|
15398
|
+
map,
|
|
15399
|
+
referencedFiles: renderedChunkInfo.referencedFiles.map(finalize)
|
|
15400
|
+
};
|
|
15401
|
+
}
|
|
15388
15402
|
generateExports() {
|
|
15389
15403
|
this.sortedExportNames = null;
|
|
15390
15404
|
const remainingExports = new Set(this.exports);
|
|
@@ -15477,24 +15491,6 @@ class Chunk {
|
|
|
15477
15491
|
}
|
|
15478
15492
|
return facades;
|
|
15479
15493
|
}
|
|
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
15494
|
getChunkName() {
|
|
15499
15495
|
return (this.name ?? (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName())));
|
|
15500
15496
|
}
|
|
@@ -15502,7 +15498,7 @@ class Chunk {
|
|
|
15502
15498
|
return (this.sortedExportNames ?? (this.sortedExportNames = [...this.exportsByName.keys()].sort()));
|
|
15503
15499
|
}
|
|
15504
15500
|
getFileName() {
|
|
15505
|
-
return this.
|
|
15501
|
+
return this.fileName || this.getPreliminaryFileName().fileName;
|
|
15506
15502
|
}
|
|
15507
15503
|
getImportPath(importer) {
|
|
15508
15504
|
return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
|
|
@@ -16248,132 +16244,12 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
16248
16244
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
16249
16245
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
16250
16246
|
|
|
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
16247
|
/**
|
|
16372
16248
|
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
16373
16249
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
16374
16250
|
* there is a chance that the iterators will not be fully exhausted.
|
|
16375
16251
|
*/
|
|
16376
|
-
function* concatLazy(iterables) {
|
|
16252
|
+
function* concatLazy(...iterables) {
|
|
16377
16253
|
for (const iterable of iterables) {
|
|
16378
16254
|
yield* iterable;
|
|
16379
16255
|
}
|
|
@@ -16514,11 +16390,47 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16514
16390
|
alias: null,
|
|
16515
16391
|
modules
|
|
16516
16392
|
}))
|
|
16517
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16518
|
-
alias: null,
|
|
16519
|
-
modules
|
|
16520
|
-
}));
|
|
16393
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
16521
16394
|
}
|
|
16395
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16396
|
+
timeStart('optimize chunks', 3);
|
|
16397
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
16398
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
16399
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
16400
|
+
let closestChunk = null;
|
|
16401
|
+
let closestChunkDistance = Infinity;
|
|
16402
|
+
const { signature, size, modules } = sourceChunk;
|
|
16403
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
16404
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
16405
|
+
if (distance === 1) {
|
|
16406
|
+
closestChunk = targetChunk;
|
|
16407
|
+
break;
|
|
16408
|
+
}
|
|
16409
|
+
else if (distance < closestChunkDistance) {
|
|
16410
|
+
closestChunk = targetChunk;
|
|
16411
|
+
closestChunkDistance = distance;
|
|
16412
|
+
}
|
|
16413
|
+
}
|
|
16414
|
+
if (closestChunk) {
|
|
16415
|
+
closestChunk.modules.push(...modules);
|
|
16416
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
16417
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16418
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
16419
|
+
chunksToBeMerged.delete(closestChunk);
|
|
16420
|
+
unmergeableChunks.push(closestChunk);
|
|
16421
|
+
}
|
|
16422
|
+
}
|
|
16423
|
+
}
|
|
16424
|
+
else {
|
|
16425
|
+
unmergeableChunks.push(sourceChunk);
|
|
16426
|
+
}
|
|
16427
|
+
}
|
|
16428
|
+
timeEnd('optimize chunks', 3);
|
|
16429
|
+
return unmergeableChunks;
|
|
16430
|
+
}
|
|
16431
|
+
const CHAR_DEPENDENT = 'X';
|
|
16432
|
+
const CHAR_INDEPENDENT = '_';
|
|
16433
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16522
16434
|
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16523
16435
|
const chunkModules = Object.create(null);
|
|
16524
16436
|
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
@@ -16536,225 +16448,28 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16536
16448
|
}
|
|
16537
16449
|
return chunkModules;
|
|
16538
16450
|
}
|
|
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();
|
|
16451
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
16452
|
+
const chunksToBeMerged = new Set();
|
|
16453
|
+
const unmergeableChunks = [];
|
|
16454
|
+
const alias = null;
|
|
16588
16455
|
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
16456
|
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();
|
|
16457
|
+
checkModules: {
|
|
16657
16458
|
for (const module of modules) {
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
16661
|
-
dependencies.add(dependencyChunk);
|
|
16662
|
-
transitiveDependencyModules.add(dependency);
|
|
16663
|
-
}
|
|
16664
|
-
}
|
|
16665
|
-
}
|
|
16666
|
-
for (const module of transitiveDependencyModules) {
|
|
16667
|
-
const transitiveDependency = chunkByModule.get(module);
|
|
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
|
-
}
|
|
16676
|
-
}
|
|
16677
|
-
}
|
|
16678
|
-
}
|
|
16679
|
-
}
|
|
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;
|
|
16459
|
+
if (module.hasEffects()) {
|
|
16460
|
+
break checkModules;
|
|
16699
16461
|
}
|
|
16700
|
-
|
|
16701
|
-
|
|
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);
|
|
16462
|
+
size += module.magicString.toString().length;
|
|
16463
|
+
if (size > minChunkSize) {
|
|
16464
|
+
break checkModules;
|
|
16725
16465
|
}
|
|
16726
|
-
dependentChunk.transitiveDependencies.delete(mergedChunk);
|
|
16727
|
-
dependentChunk.transitiveDependencies.add(closestChunk);
|
|
16728
16466
|
}
|
|
16729
|
-
|
|
16730
|
-
|
|
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;
|
|
16467
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
16468
|
+
continue;
|
|
16751
16469
|
}
|
|
16470
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
16752
16471
|
}
|
|
16753
|
-
return
|
|
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;
|
|
16472
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
16758
16473
|
}
|
|
16759
16474
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16760
16475
|
let distance = 0;
|
|
@@ -17258,14 +16973,14 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
17258
16973
|
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
17259
16974
|
updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
|
|
17260
16975
|
}
|
|
17261
|
-
bundle[finalFileName] = chunk.
|
|
16976
|
+
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
17262
16977
|
}
|
|
17263
16978
|
for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
|
|
17264
16979
|
let updatedCode = hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code;
|
|
17265
16980
|
if (map) {
|
|
17266
16981
|
updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
|
|
17267
16982
|
}
|
|
17268
|
-
bundle[fileName] = chunk.
|
|
16983
|
+
bundle[fileName] = chunk.finalizeChunk(updatedCode, map, hashesByPlaceholder);
|
|
17269
16984
|
}
|
|
17270
16985
|
}
|
|
17271
16986
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
@@ -23808,8 +23523,7 @@ function getChunkFileName(file, facadeChunkByModule) {
|
|
|
23808
23523
|
return file.fileName;
|
|
23809
23524
|
}
|
|
23810
23525
|
if (facadeChunkByModule) {
|
|
23811
|
-
|
|
23812
|
-
return chunk.id || chunk.getFileName();
|
|
23526
|
+
return facadeChunkByModule.get(file.module).getFileName();
|
|
23813
23527
|
}
|
|
23814
23528
|
return error(errorChunkNotGeneratedForFileName(file.fileName || file.name));
|
|
23815
23529
|
}
|
|
@@ -25589,7 +25303,6 @@ exports.loadFsEvents = loadFsEvents;
|
|
|
25589
25303
|
exports.mergeOptions = mergeOptions;
|
|
25590
25304
|
exports.normalizePluginOption = normalizePluginOption;
|
|
25591
25305
|
exports.picomatch = picomatch$1;
|
|
25592
|
-
exports.prettyBytes = prettyBytes;
|
|
25593
25306
|
exports.printQuotedStringList = printQuotedStringList;
|
|
25594
25307
|
exports.relativeId = relativeId;
|
|
25595
25308
|
exports.rollup = rollup;
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED