rollup 3.12.0 → 3.13.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 +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +198 -80
- 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 +198 -80
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +12 -13
package/dist/bin/rollup
CHANGED
package/dist/es/rollup.js
CHANGED
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.13.0
|
|
4
|
+
Fri, 03 Feb 2023 12:52:06 GMT - commit 45980b51bc13f52a9583d6c898814040f4ee9128
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version$1 = "3.
|
|
19
|
+
var version$1 = "3.13.0";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -222,7 +222,7 @@ let Chunk$1 = class Chunk {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
clone() {
|
|
225
|
-
const chunk = new Chunk
|
|
225
|
+
const chunk = new Chunk(this.start, this.end, this.original);
|
|
226
226
|
|
|
227
227
|
chunk.intro = this.intro;
|
|
228
228
|
chunk.outro = this.outro;
|
|
@@ -282,7 +282,7 @@ let Chunk$1 = class Chunk {
|
|
|
282
282
|
|
|
283
283
|
this.original = originalBefore;
|
|
284
284
|
|
|
285
|
-
const newChunk = new Chunk
|
|
285
|
+
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
286
286
|
newChunk.outro = this.outro;
|
|
287
287
|
this.outro = '';
|
|
288
288
|
|
|
@@ -1380,7 +1380,7 @@ let Bundle$1 = class Bundle {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
|
|
1382
1382
|
clone() {
|
|
1383
|
-
const bundle = new Bundle
|
|
1383
|
+
const bundle = new Bundle({
|
|
1384
1384
|
intro: this.intro,
|
|
1385
1385
|
separator: this.separator,
|
|
1386
1386
|
});
|
|
@@ -1898,7 +1898,10 @@ class Variable extends ExpressionEntity {
|
|
|
1898
1898
|
getBaseVariableName() {
|
|
1899
1899
|
return this.renderBaseName || this.renderName || this.name;
|
|
1900
1900
|
}
|
|
1901
|
-
getName(getPropertyAccess) {
|
|
1901
|
+
getName(getPropertyAccess, useOriginalName) {
|
|
1902
|
+
if (useOriginalName?.(this)) {
|
|
1903
|
+
return this.name;
|
|
1904
|
+
}
|
|
1902
1905
|
const name = this.renderName || this.name;
|
|
1903
1906
|
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
1904
1907
|
}
|
|
@@ -2206,12 +2209,12 @@ function errorCircularReexport(exportName, exporter) {
|
|
|
2206
2209
|
message: `"${exportName}" cannot be exported from "${relativeId(exporter)}" as it is a reexport that references itself.`
|
|
2207
2210
|
};
|
|
2208
2211
|
}
|
|
2209
|
-
function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importer) {
|
|
2212
|
+
function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importer, preserveModules) {
|
|
2210
2213
|
return {
|
|
2211
2214
|
code: CYCLIC_CROSS_CHUNK_REEXPORT,
|
|
2212
2215
|
exporter,
|
|
2213
2216
|
id: importer,
|
|
2214
|
-
message: `Export "${exportName}" of module "${relativeId(exporter)}" was reexported through module "${relativeId(reexporter)}" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "${relativeId(importer)}" to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.`,
|
|
2217
|
+
message: `Export "${exportName}" of module "${relativeId(exporter)}" was reexported through module "${relativeId(reexporter)}" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "${relativeId(importer)}" to point directly to the exporting module or ${preserveModules ? 'do not use "output.preserveModules"' : 'reconfigure "output.manualChunks"'} to ensure these modules end up in the same chunk.`,
|
|
2215
2218
|
reexporter
|
|
2216
2219
|
};
|
|
2217
2220
|
}
|
|
@@ -8034,9 +8037,9 @@ class Identifier extends NodeBase {
|
|
|
8034
8037
|
markDeclarationReached() {
|
|
8035
8038
|
this.variable.initReached = true;
|
|
8036
8039
|
}
|
|
8037
|
-
render(code, { snippets: { getPropertyAccess } }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
|
|
8040
|
+
render(code, { snippets: { getPropertyAccess }, useOriginalName }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
|
|
8038
8041
|
if (this.variable) {
|
|
8039
|
-
const name = this.variable.getName(getPropertyAccess);
|
|
8042
|
+
const name = this.variable.getName(getPropertyAccess, useOriginalName);
|
|
8040
8043
|
if (name !== this.name) {
|
|
8041
8044
|
code.overwrite(this.start, this.end, name, {
|
|
8042
8045
|
contentOnly: true,
|
|
@@ -9835,7 +9838,10 @@ class ClassDeclaration extends ClassNode {
|
|
|
9835
9838
|
const renderedVariable = variable.getName(getPropertyAccess);
|
|
9836
9839
|
if (renderedVariable !== name) {
|
|
9837
9840
|
this.superClass?.render(code, options);
|
|
9838
|
-
this.body.render(code,
|
|
9841
|
+
this.body.render(code, {
|
|
9842
|
+
...options,
|
|
9843
|
+
useOriginalName: (_variable) => _variable === variable
|
|
9844
|
+
});
|
|
9839
9845
|
code.prependRight(this.start, `let ${renderedVariable}${_}=${_}`);
|
|
9840
9846
|
code.prependLeft(this.end, ';');
|
|
9841
9847
|
return;
|
|
@@ -11413,12 +11419,14 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11413
11419
|
class Program extends NodeBase {
|
|
11414
11420
|
constructor() {
|
|
11415
11421
|
super(...arguments);
|
|
11416
|
-
this.hasCachedEffect =
|
|
11422
|
+
this.hasCachedEffect = null;
|
|
11423
|
+
}
|
|
11424
|
+
hasCachedEffects() {
|
|
11425
|
+
return this.hasCachedEffect === null
|
|
11426
|
+
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11427
|
+
: this.hasCachedEffect;
|
|
11417
11428
|
}
|
|
11418
11429
|
hasEffects(context) {
|
|
11419
|
-
// We are caching here to later more efficiently identify side-effect-free modules
|
|
11420
|
-
if (this.hasCachedEffect)
|
|
11421
|
-
return true;
|
|
11422
11430
|
for (const node of this.body) {
|
|
11423
11431
|
if (node.hasEffects(context)) {
|
|
11424
11432
|
return (this.hasCachedEffect = true);
|
|
@@ -13316,8 +13324,7 @@ class Module {
|
|
|
13316
13324
|
return [null];
|
|
13317
13325
|
}
|
|
13318
13326
|
hasEffects() {
|
|
13319
|
-
return
|
|
13320
|
-
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13327
|
+
return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
|
|
13321
13328
|
}
|
|
13322
13329
|
include() {
|
|
13323
13330
|
const context = createInclusionContext();
|
|
@@ -15428,8 +15435,10 @@ class Chunk {
|
|
|
15428
15435
|
alternativeReexportModule = importingModule.alternativeReexportModules.get(variable);
|
|
15429
15436
|
if (alternativeReexportModule) {
|
|
15430
15437
|
const exportingChunk = this.chunkByModule.get(alternativeReexportModule);
|
|
15431
|
-
if (exportingChunk
|
|
15432
|
-
this.inputOptions.onwarn(errorCyclicCrossChunkReexport(
|
|
15438
|
+
if (exportingChunk !== exportChunk) {
|
|
15439
|
+
this.inputOptions.onwarn(errorCyclicCrossChunkReexport(
|
|
15440
|
+
// Namespaces do not have an export name
|
|
15441
|
+
variableModule.getExportNamesByVariable().get(variable)?.[0] || '*', variableModule.id, alternativeReexportModule.id, importingModule.id, this.outputOptions.preserveModules));
|
|
15433
15442
|
}
|
|
15434
15443
|
importingModule = alternativeReexportModule;
|
|
15435
15444
|
}
|
|
@@ -15442,8 +15451,10 @@ class Chunk {
|
|
|
15442
15451
|
for (const exportedVariable of map.keys()) {
|
|
15443
15452
|
const isSynthetic = exportedVariable instanceof SyntheticNamedExportVariable;
|
|
15444
15453
|
const importedVariable = isSynthetic ? exportedVariable.getBaseVariable() : exportedVariable;
|
|
15454
|
+
this.checkCircularDependencyImport(importedVariable, module);
|
|
15455
|
+
// When preserving modules, we do not create namespace objects but directly
|
|
15456
|
+
// use the actual namespaces, which would be broken by this logic.
|
|
15445
15457
|
if (!(importedVariable instanceof NamespaceVariable && this.outputOptions.preserveModules)) {
|
|
15446
|
-
this.checkCircularDependencyImport(importedVariable, module);
|
|
15447
15458
|
const exportingModule = importedVariable.module;
|
|
15448
15459
|
if (exportingModule instanceof Module) {
|
|
15449
15460
|
const chunk = this.chunkByModule.get(exportingModule);
|
|
@@ -15814,7 +15825,8 @@ class Chunk {
|
|
|
15814
15825
|
indent,
|
|
15815
15826
|
namespaceToStringTag,
|
|
15816
15827
|
pluginDriver,
|
|
15817
|
-
snippets
|
|
15828
|
+
snippets,
|
|
15829
|
+
useOriginalName: null
|
|
15818
15830
|
};
|
|
15819
15831
|
let usesTopLevelAwait = false;
|
|
15820
15832
|
for (const module of orderedModules) {
|
|
@@ -15972,10 +15984,13 @@ class Chunk {
|
|
|
15972
15984
|
const chunk = this.chunkByModule.get(variable.module);
|
|
15973
15985
|
if (chunk !== this) {
|
|
15974
15986
|
this.imports.add(variable);
|
|
15975
|
-
if (
|
|
15976
|
-
variable.module instanceof Module) {
|
|
15977
|
-
chunk.exports.add(variable);
|
|
15987
|
+
if (variable.module instanceof Module) {
|
|
15978
15988
|
this.checkCircularDependencyImport(variable, module);
|
|
15989
|
+
// When preserving modules, we do not create namespace objects but directly
|
|
15990
|
+
// use the actual namespaces, which would be broken by this logic.
|
|
15991
|
+
if (!(variable instanceof NamespaceVariable && this.outputOptions.preserveModules)) {
|
|
15992
|
+
chunk.exports.add(variable);
|
|
15993
|
+
}
|
|
15979
15994
|
}
|
|
15980
15995
|
}
|
|
15981
15996
|
}
|
|
@@ -16027,7 +16042,7 @@ const resolveFileName = (dependency) => dependency.getFileName();
|
|
|
16027
16042
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
16028
16043
|
* there is a chance that the iterators will not be fully exhausted.
|
|
16029
16044
|
*/
|
|
16030
|
-
function* concatLazy(
|
|
16045
|
+
function* concatLazy(iterables) {
|
|
16031
16046
|
for (const iterable of iterables) {
|
|
16032
16047
|
yield* iterable;
|
|
16033
16048
|
}
|
|
@@ -16168,47 +16183,11 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16168
16183
|
alias: null,
|
|
16169
16184
|
modules
|
|
16170
16185
|
}))
|
|
16171
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
16176
|
-
for (const sourceChunk of chunksToBeMerged) {
|
|
16177
|
-
chunksToBeMerged.delete(sourceChunk);
|
|
16178
|
-
let closestChunk = null;
|
|
16179
|
-
let closestChunkDistance = Infinity;
|
|
16180
|
-
const { signature, size, modules } = sourceChunk;
|
|
16181
|
-
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
16182
|
-
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
16183
|
-
if (distance === 1) {
|
|
16184
|
-
closestChunk = targetChunk;
|
|
16185
|
-
break;
|
|
16186
|
-
}
|
|
16187
|
-
else if (distance < closestChunkDistance) {
|
|
16188
|
-
closestChunk = targetChunk;
|
|
16189
|
-
closestChunkDistance = distance;
|
|
16190
|
-
}
|
|
16191
|
-
}
|
|
16192
|
-
if (closestChunk) {
|
|
16193
|
-
closestChunk.modules.push(...modules);
|
|
16194
|
-
if (chunksToBeMerged.has(closestChunk)) {
|
|
16195
|
-
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16196
|
-
if ((closestChunk.size += size) > minChunkSize) {
|
|
16197
|
-
chunksToBeMerged.delete(closestChunk);
|
|
16198
|
-
unmergeableChunks.push(closestChunk);
|
|
16199
|
-
}
|
|
16200
|
-
}
|
|
16201
|
-
}
|
|
16202
|
-
else {
|
|
16203
|
-
unmergeableChunks.push(sourceChunk);
|
|
16204
|
-
}
|
|
16205
|
-
}
|
|
16206
|
-
timeEnd('optimize chunks', 3);
|
|
16207
|
-
return unmergeableChunks;
|
|
16186
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
|
|
16187
|
+
alias: null,
|
|
16188
|
+
modules
|
|
16189
|
+
}));
|
|
16208
16190
|
}
|
|
16209
|
-
const CHAR_DEPENDENT = 'X';
|
|
16210
|
-
const CHAR_INDEPENDENT = '_';
|
|
16211
|
-
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16212
16191
|
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16213
16192
|
const chunkModules = Object.create(null);
|
|
16214
16193
|
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
@@ -16226,28 +16205,167 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16226
16205
|
}
|
|
16227
16206
|
return chunkModules;
|
|
16228
16207
|
}
|
|
16229
|
-
|
|
16230
|
-
|
|
16231
|
-
|
|
16232
|
-
|
|
16208
|
+
/**
|
|
16209
|
+
* This function tries to get rid of small chunks by merging them with other
|
|
16210
|
+
* chunks. In order to merge chunks, one must obey the following rule:
|
|
16211
|
+
* - When merging several chunks, at most one of the chunks can have side
|
|
16212
|
+
* effects
|
|
16213
|
+
* - When one of the chunks has side effects, the entry points depending on that
|
|
16214
|
+
* chunk need to be a super set of the entry points depending on the other
|
|
16215
|
+
* chunks
|
|
16216
|
+
* - Pure chunks can always be merged
|
|
16217
|
+
* - We use the entry point dependence signature to calculate "chunk distance",
|
|
16218
|
+
* i.e. how likely it is that two chunks are loaded together
|
|
16219
|
+
*/
|
|
16220
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16221
|
+
timeStart('optimize chunks', 3);
|
|
16222
|
+
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
|
|
16223
|
+
if (chunkPartition.small.sideEffect.size > 0) {
|
|
16224
|
+
mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16225
|
+
}
|
|
16226
|
+
if (chunkPartition.small.pure.size > 0) {
|
|
16227
|
+
mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16228
|
+
}
|
|
16229
|
+
timeEnd('optimize chunks', 3);
|
|
16230
|
+
return [
|
|
16231
|
+
...chunkPartition.small.sideEffect,
|
|
16232
|
+
...chunkPartition.small.pure,
|
|
16233
|
+
...chunkPartition.big.sideEffect,
|
|
16234
|
+
...chunkPartition.big.pure
|
|
16235
|
+
];
|
|
16236
|
+
}
|
|
16237
|
+
const CHAR_DEPENDENT = 'X';
|
|
16238
|
+
const CHAR_INDEPENDENT = '_';
|
|
16239
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16240
|
+
function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16241
|
+
const smallPureChunks = [];
|
|
16242
|
+
const bigPureChunks = [];
|
|
16243
|
+
const smallSideEffectChunks = [];
|
|
16244
|
+
const bigSideEffectChunks = [];
|
|
16245
|
+
const chunkByModule = new Map();
|
|
16233
16246
|
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16247
|
+
const chunkDescription = {
|
|
16248
|
+
dependencies: new Set(),
|
|
16249
|
+
dependentChunks: new Set(),
|
|
16250
|
+
modules,
|
|
16251
|
+
pure: true,
|
|
16252
|
+
signature,
|
|
16253
|
+
size: 0
|
|
16254
|
+
};
|
|
16234
16255
|
let size = 0;
|
|
16235
|
-
|
|
16256
|
+
let pure = true;
|
|
16257
|
+
for (const module of modules) {
|
|
16258
|
+
chunkByModule.set(module, chunkDescription);
|
|
16259
|
+
pure && (pure = !module.hasEffects());
|
|
16260
|
+
// Unfortunately, we cannot take tree-shaking into account here because
|
|
16261
|
+
// rendering did not happen yet
|
|
16262
|
+
size += module.originalCode.length;
|
|
16263
|
+
}
|
|
16264
|
+
chunkDescription.pure = pure;
|
|
16265
|
+
chunkDescription.size = size;
|
|
16266
|
+
(size < minChunkSize
|
|
16267
|
+
? pure
|
|
16268
|
+
? smallPureChunks
|
|
16269
|
+
: smallSideEffectChunks
|
|
16270
|
+
: pure
|
|
16271
|
+
? bigPureChunks
|
|
16272
|
+
: bigSideEffectChunks).push(chunkDescription);
|
|
16273
|
+
}
|
|
16274
|
+
sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
|
|
16275
|
+
return {
|
|
16276
|
+
big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
|
|
16277
|
+
small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
|
|
16278
|
+
};
|
|
16279
|
+
}
|
|
16280
|
+
function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
16281
|
+
for (const chunks of chunkLists) {
|
|
16282
|
+
chunks.sort(compareChunks);
|
|
16283
|
+
for (const chunk of chunks) {
|
|
16284
|
+
const { dependencies, modules } = chunk;
|
|
16236
16285
|
for (const module of modules) {
|
|
16237
|
-
|
|
16238
|
-
|
|
16286
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16287
|
+
const dependencyChunk = chunkByModule.get(dependency);
|
|
16288
|
+
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
16289
|
+
dependencies.add(dependencyChunk);
|
|
16290
|
+
dependencyChunk.dependentChunks.add(chunk);
|
|
16291
|
+
}
|
|
16239
16292
|
}
|
|
16240
|
-
|
|
16241
|
-
|
|
16242
|
-
|
|
16293
|
+
}
|
|
16294
|
+
}
|
|
16295
|
+
}
|
|
16296
|
+
}
|
|
16297
|
+
function compareChunks({ size: sizeA }, { size: sizeB }) {
|
|
16298
|
+
return sizeA - sizeB;
|
|
16299
|
+
}
|
|
16300
|
+
function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
|
|
16301
|
+
for (const mergedChunk of chunksToBeMerged) {
|
|
16302
|
+
let closestChunk = null;
|
|
16303
|
+
let closestChunkDistance = Infinity;
|
|
16304
|
+
const { signature, modules, pure, size } = mergedChunk;
|
|
16305
|
+
for (const targetChunk of concatLazy(targetChunks)) {
|
|
16306
|
+
if (mergedChunk === targetChunk)
|
|
16307
|
+
continue;
|
|
16308
|
+
// Possible improvement:
|
|
16309
|
+
// For dynamic entries depending on a pure chunk, it is safe to merge that
|
|
16310
|
+
// chunk into the chunk doing the dynamic import (i.e. into an "already
|
|
16311
|
+
// loaded chunk") even if it is not pure.
|
|
16312
|
+
// One way of handling this could be to add all "already loaded entries"
|
|
16313
|
+
// of the dynamic importers into the signature as well. That could also
|
|
16314
|
+
// change the way we do code-splitting for already loaded entries.
|
|
16315
|
+
const distance = pure
|
|
16316
|
+
? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
|
|
16317
|
+
: getSignatureDistance(targetChunk.signature, signature, true);
|
|
16318
|
+
if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
|
|
16319
|
+
if (distance === 1) {
|
|
16320
|
+
closestChunk = targetChunk;
|
|
16321
|
+
break;
|
|
16243
16322
|
}
|
|
16323
|
+
closestChunk = targetChunk;
|
|
16324
|
+
closestChunkDistance = distance;
|
|
16244
16325
|
}
|
|
16245
|
-
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
16246
|
-
continue;
|
|
16247
16326
|
}
|
|
16248
|
-
|
|
16327
|
+
if (closestChunk) {
|
|
16328
|
+
chunksToBeMerged.delete(mergedChunk);
|
|
16329
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16330
|
+
closestChunk.modules.push(...modules);
|
|
16331
|
+
closestChunk.size += size;
|
|
16332
|
+
closestChunk.pure && (closestChunk.pure = pure);
|
|
16333
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16334
|
+
const { dependencies, dependentChunks } = closestChunk;
|
|
16335
|
+
for (const dependency of mergedChunk.dependencies) {
|
|
16336
|
+
dependencies.add(dependency);
|
|
16337
|
+
}
|
|
16338
|
+
for (const dependentChunk of mergedChunk.dependentChunks) {
|
|
16339
|
+
dependentChunks.add(dependentChunk);
|
|
16340
|
+
dependentChunk.dependencies.delete(mergedChunk);
|
|
16341
|
+
dependentChunk.dependencies.add(closestChunk);
|
|
16342
|
+
}
|
|
16343
|
+
dependencies.delete(closestChunk);
|
|
16344
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16345
|
+
}
|
|
16249
16346
|
}
|
|
16250
|
-
|
|
16347
|
+
}
|
|
16348
|
+
// Merging will not produce cycles if none of the direct non-merged dependencies
|
|
16349
|
+
// of a chunk have the other chunk as a transitive dependency
|
|
16350
|
+
function isValidMerge(mergedChunk, targetChunk) {
|
|
16351
|
+
return !(hasTransitiveDependency(mergedChunk, targetChunk) ||
|
|
16352
|
+
hasTransitiveDependency(targetChunk, mergedChunk));
|
|
16353
|
+
}
|
|
16354
|
+
function hasTransitiveDependency(dependentChunk, dependencyChunk) {
|
|
16355
|
+
const chunksToCheck = new Set(dependentChunk.dependencies);
|
|
16356
|
+
for (const { dependencies } of chunksToCheck) {
|
|
16357
|
+
for (const dependency of dependencies) {
|
|
16358
|
+
if (dependency === dependencyChunk) {
|
|
16359
|
+
return true;
|
|
16360
|
+
}
|
|
16361
|
+
chunksToCheck.add(dependency);
|
|
16362
|
+
}
|
|
16363
|
+
}
|
|
16364
|
+
return false;
|
|
16365
|
+
}
|
|
16366
|
+
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
16367
|
+
const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
16368
|
+
return chunk.pure ? subPartition.pure : subPartition.sideEffect;
|
|
16251
16369
|
}
|
|
16252
16370
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16253
16371
|
let distance = 0;
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.13.0
|
|
4
|
+
Fri, 03 Feb 2023 12:52:06 GMT - commit 45980b51bc13f52a9583d6c898814040f4ee9128
|
|
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.13.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -378,12 +378,12 @@ function errorCircularReexport(exportName, exporter) {
|
|
|
378
378
|
message: `"${exportName}" cannot be exported from "${relativeId(exporter)}" as it is a reexport that references itself.`
|
|
379
379
|
};
|
|
380
380
|
}
|
|
381
|
-
function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importer) {
|
|
381
|
+
function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importer, preserveModules) {
|
|
382
382
|
return {
|
|
383
383
|
code: CYCLIC_CROSS_CHUNK_REEXPORT,
|
|
384
384
|
exporter,
|
|
385
385
|
id: importer,
|
|
386
|
-
message: `Export "${exportName}" of module "${relativeId(exporter)}" was reexported through module "${relativeId(reexporter)}" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "${relativeId(importer)}" to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.`,
|
|
386
|
+
message: `Export "${exportName}" of module "${relativeId(exporter)}" was reexported through module "${relativeId(reexporter)}" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "${relativeId(importer)}" to point directly to the exporting module or ${preserveModules ? 'do not use "output.preserveModules"' : 'reconfigure "output.manualChunks"'} to ensure these modules end up in the same chunk.`,
|
|
387
387
|
reexporter
|
|
388
388
|
};
|
|
389
389
|
}
|
|
@@ -1492,7 +1492,7 @@ let Chunk$1 = class Chunk {
|
|
|
1492
1492
|
}
|
|
1493
1493
|
|
|
1494
1494
|
clone() {
|
|
1495
|
-
const chunk = new Chunk
|
|
1495
|
+
const chunk = new Chunk(this.start, this.end, this.original);
|
|
1496
1496
|
|
|
1497
1497
|
chunk.intro = this.intro;
|
|
1498
1498
|
chunk.outro = this.outro;
|
|
@@ -1552,7 +1552,7 @@ let Chunk$1 = class Chunk {
|
|
|
1552
1552
|
|
|
1553
1553
|
this.original = originalBefore;
|
|
1554
1554
|
|
|
1555
|
-
const newChunk = new Chunk
|
|
1555
|
+
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
1556
1556
|
newChunk.outro = this.outro;
|
|
1557
1557
|
this.outro = '';
|
|
1558
1558
|
|
|
@@ -2650,7 +2650,7 @@ let Bundle$1 = class Bundle {
|
|
|
2650
2650
|
}
|
|
2651
2651
|
|
|
2652
2652
|
clone() {
|
|
2653
|
-
const bundle = new Bundle
|
|
2653
|
+
const bundle = new Bundle({
|
|
2654
2654
|
intro: this.intro,
|
|
2655
2655
|
separator: this.separator,
|
|
2656
2656
|
});
|
|
@@ -3104,7 +3104,10 @@ class Variable extends ExpressionEntity {
|
|
|
3104
3104
|
getBaseVariableName() {
|
|
3105
3105
|
return this.renderBaseName || this.renderName || this.name;
|
|
3106
3106
|
}
|
|
3107
|
-
getName(getPropertyAccess) {
|
|
3107
|
+
getName(getPropertyAccess, useOriginalName) {
|
|
3108
|
+
if (useOriginalName?.(this)) {
|
|
3109
|
+
return this.name;
|
|
3110
|
+
}
|
|
3108
3111
|
const name = this.renderName || this.name;
|
|
3109
3112
|
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
3110
3113
|
}
|
|
@@ -8552,9 +8555,9 @@ class Identifier extends NodeBase {
|
|
|
8552
8555
|
markDeclarationReached() {
|
|
8553
8556
|
this.variable.initReached = true;
|
|
8554
8557
|
}
|
|
8555
|
-
render(code, { snippets: { getPropertyAccess } }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
|
|
8558
|
+
render(code, { snippets: { getPropertyAccess }, useOriginalName }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
|
|
8556
8559
|
if (this.variable) {
|
|
8557
|
-
const name = this.variable.getName(getPropertyAccess);
|
|
8560
|
+
const name = this.variable.getName(getPropertyAccess, useOriginalName);
|
|
8558
8561
|
if (name !== this.name) {
|
|
8559
8562
|
code.overwrite(this.start, this.end, name, {
|
|
8560
8563
|
contentOnly: true,
|
|
@@ -10353,7 +10356,10 @@ class ClassDeclaration extends ClassNode {
|
|
|
10353
10356
|
const renderedVariable = variable.getName(getPropertyAccess);
|
|
10354
10357
|
if (renderedVariable !== name) {
|
|
10355
10358
|
this.superClass?.render(code, options);
|
|
10356
|
-
this.body.render(code,
|
|
10359
|
+
this.body.render(code, {
|
|
10360
|
+
...options,
|
|
10361
|
+
useOriginalName: (_variable) => _variable === variable
|
|
10362
|
+
});
|
|
10357
10363
|
code.prependRight(this.start, `let ${renderedVariable}${_}=${_}`);
|
|
10358
10364
|
code.prependLeft(this.end, ';');
|
|
10359
10365
|
return;
|
|
@@ -11931,12 +11937,14 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11931
11937
|
class Program extends NodeBase {
|
|
11932
11938
|
constructor() {
|
|
11933
11939
|
super(...arguments);
|
|
11934
|
-
this.hasCachedEffect =
|
|
11940
|
+
this.hasCachedEffect = null;
|
|
11941
|
+
}
|
|
11942
|
+
hasCachedEffects() {
|
|
11943
|
+
return this.hasCachedEffect === null
|
|
11944
|
+
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11945
|
+
: this.hasCachedEffect;
|
|
11935
11946
|
}
|
|
11936
11947
|
hasEffects(context) {
|
|
11937
|
-
// We are caching here to later more efficiently identify side-effect-free modules
|
|
11938
|
-
if (this.hasCachedEffect)
|
|
11939
|
-
return true;
|
|
11940
11948
|
for (const node of this.body) {
|
|
11941
11949
|
if (node.hasEffects(context)) {
|
|
11942
11950
|
return (this.hasCachedEffect = true);
|
|
@@ -13834,8 +13842,7 @@ class Module {
|
|
|
13834
13842
|
return [null];
|
|
13835
13843
|
}
|
|
13836
13844
|
hasEffects() {
|
|
13837
|
-
return
|
|
13838
|
-
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13845
|
+
return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
|
|
13839
13846
|
}
|
|
13840
13847
|
include() {
|
|
13841
13848
|
const context = createInclusionContext();
|
|
@@ -15946,8 +15953,10 @@ class Chunk {
|
|
|
15946
15953
|
alternativeReexportModule = importingModule.alternativeReexportModules.get(variable);
|
|
15947
15954
|
if (alternativeReexportModule) {
|
|
15948
15955
|
const exportingChunk = this.chunkByModule.get(alternativeReexportModule);
|
|
15949
|
-
if (exportingChunk
|
|
15950
|
-
this.inputOptions.onwarn(errorCyclicCrossChunkReexport(
|
|
15956
|
+
if (exportingChunk !== exportChunk) {
|
|
15957
|
+
this.inputOptions.onwarn(errorCyclicCrossChunkReexport(
|
|
15958
|
+
// Namespaces do not have an export name
|
|
15959
|
+
variableModule.getExportNamesByVariable().get(variable)?.[0] || '*', variableModule.id, alternativeReexportModule.id, importingModule.id, this.outputOptions.preserveModules));
|
|
15951
15960
|
}
|
|
15952
15961
|
importingModule = alternativeReexportModule;
|
|
15953
15962
|
}
|
|
@@ -15960,8 +15969,10 @@ class Chunk {
|
|
|
15960
15969
|
for (const exportedVariable of map.keys()) {
|
|
15961
15970
|
const isSynthetic = exportedVariable instanceof SyntheticNamedExportVariable;
|
|
15962
15971
|
const importedVariable = isSynthetic ? exportedVariable.getBaseVariable() : exportedVariable;
|
|
15972
|
+
this.checkCircularDependencyImport(importedVariable, module);
|
|
15973
|
+
// When preserving modules, we do not create namespace objects but directly
|
|
15974
|
+
// use the actual namespaces, which would be broken by this logic.
|
|
15963
15975
|
if (!(importedVariable instanceof NamespaceVariable && this.outputOptions.preserveModules)) {
|
|
15964
|
-
this.checkCircularDependencyImport(importedVariable, module);
|
|
15965
15976
|
const exportingModule = importedVariable.module;
|
|
15966
15977
|
if (exportingModule instanceof Module) {
|
|
15967
15978
|
const chunk = this.chunkByModule.get(exportingModule);
|
|
@@ -16332,7 +16343,8 @@ class Chunk {
|
|
|
16332
16343
|
indent,
|
|
16333
16344
|
namespaceToStringTag,
|
|
16334
16345
|
pluginDriver,
|
|
16335
|
-
snippets
|
|
16346
|
+
snippets,
|
|
16347
|
+
useOriginalName: null
|
|
16336
16348
|
};
|
|
16337
16349
|
let usesTopLevelAwait = false;
|
|
16338
16350
|
for (const module of orderedModules) {
|
|
@@ -16490,10 +16502,13 @@ class Chunk {
|
|
|
16490
16502
|
const chunk = this.chunkByModule.get(variable.module);
|
|
16491
16503
|
if (chunk !== this) {
|
|
16492
16504
|
this.imports.add(variable);
|
|
16493
|
-
if (
|
|
16494
|
-
variable.module instanceof Module) {
|
|
16495
|
-
chunk.exports.add(variable);
|
|
16505
|
+
if (variable.module instanceof Module) {
|
|
16496
16506
|
this.checkCircularDependencyImport(variable, module);
|
|
16507
|
+
// When preserving modules, we do not create namespace objects but directly
|
|
16508
|
+
// use the actual namespaces, which would be broken by this logic.
|
|
16509
|
+
if (!(variable instanceof NamespaceVariable && this.outputOptions.preserveModules)) {
|
|
16510
|
+
chunk.exports.add(variable);
|
|
16511
|
+
}
|
|
16497
16512
|
}
|
|
16498
16513
|
}
|
|
16499
16514
|
}
|
|
@@ -16545,7 +16560,7 @@ const resolveFileName = (dependency) => dependency.getFileName();
|
|
|
16545
16560
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
16546
16561
|
* there is a chance that the iterators will not be fully exhausted.
|
|
16547
16562
|
*/
|
|
16548
|
-
function* concatLazy(
|
|
16563
|
+
function* concatLazy(iterables) {
|
|
16549
16564
|
for (const iterable of iterables) {
|
|
16550
16565
|
yield* iterable;
|
|
16551
16566
|
}
|
|
@@ -16686,47 +16701,11 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
|
|
|
16686
16701
|
alias: null,
|
|
16687
16702
|
modules
|
|
16688
16703
|
}))
|
|
16689
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16690
|
-
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
16694
|
-
for (const sourceChunk of chunksToBeMerged) {
|
|
16695
|
-
chunksToBeMerged.delete(sourceChunk);
|
|
16696
|
-
let closestChunk = null;
|
|
16697
|
-
let closestChunkDistance = Infinity;
|
|
16698
|
-
const { signature, size, modules } = sourceChunk;
|
|
16699
|
-
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
16700
|
-
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
16701
|
-
if (distance === 1) {
|
|
16702
|
-
closestChunk = targetChunk;
|
|
16703
|
-
break;
|
|
16704
|
-
}
|
|
16705
|
-
else if (distance < closestChunkDistance) {
|
|
16706
|
-
closestChunk = targetChunk;
|
|
16707
|
-
closestChunkDistance = distance;
|
|
16708
|
-
}
|
|
16709
|
-
}
|
|
16710
|
-
if (closestChunk) {
|
|
16711
|
-
closestChunk.modules.push(...modules);
|
|
16712
|
-
if (chunksToBeMerged.has(closestChunk)) {
|
|
16713
|
-
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16714
|
-
if ((closestChunk.size += size) > minChunkSize) {
|
|
16715
|
-
chunksToBeMerged.delete(closestChunk);
|
|
16716
|
-
unmergeableChunks.push(closestChunk);
|
|
16717
|
-
}
|
|
16718
|
-
}
|
|
16719
|
-
}
|
|
16720
|
-
else {
|
|
16721
|
-
unmergeableChunks.push(sourceChunk);
|
|
16722
|
-
}
|
|
16723
|
-
}
|
|
16724
|
-
timeEnd('optimize chunks', 3);
|
|
16725
|
-
return unmergeableChunks;
|
|
16704
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize).map(({ modules }) => ({
|
|
16705
|
+
alias: null,
|
|
16706
|
+
modules
|
|
16707
|
+
}));
|
|
16726
16708
|
}
|
|
16727
|
-
const CHAR_DEPENDENT = 'X';
|
|
16728
|
-
const CHAR_INDEPENDENT = '_';
|
|
16729
|
-
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16730
16709
|
function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
16731
16710
|
const chunkModules = Object.create(null);
|
|
16732
16711
|
for (const [module, assignedEntries] of assignedEntriesByModule) {
|
|
@@ -16744,28 +16723,167 @@ function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
|
|
|
16744
16723
|
}
|
|
16745
16724
|
return chunkModules;
|
|
16746
16725
|
}
|
|
16747
|
-
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
|
|
16726
|
+
/**
|
|
16727
|
+
* This function tries to get rid of small chunks by merging them with other
|
|
16728
|
+
* chunks. In order to merge chunks, one must obey the following rule:
|
|
16729
|
+
* - When merging several chunks, at most one of the chunks can have side
|
|
16730
|
+
* effects
|
|
16731
|
+
* - When one of the chunks has side effects, the entry points depending on that
|
|
16732
|
+
* chunk need to be a super set of the entry points depending on the other
|
|
16733
|
+
* chunks
|
|
16734
|
+
* - Pure chunks can always be merged
|
|
16735
|
+
* - We use the entry point dependence signature to calculate "chunk distance",
|
|
16736
|
+
* i.e. how likely it is that two chunks are loaded together
|
|
16737
|
+
*/
|
|
16738
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16739
|
+
timeStart('optimize chunks', 3);
|
|
16740
|
+
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
|
|
16741
|
+
if (chunkPartition.small.sideEffect.size > 0) {
|
|
16742
|
+
mergeChunks(chunkPartition.small.sideEffect, [chunkPartition.small.pure, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16743
|
+
}
|
|
16744
|
+
if (chunkPartition.small.pure.size > 0) {
|
|
16745
|
+
mergeChunks(chunkPartition.small.pure, [chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure], minChunkSize, chunkPartition);
|
|
16746
|
+
}
|
|
16747
|
+
timeEnd('optimize chunks', 3);
|
|
16748
|
+
return [
|
|
16749
|
+
...chunkPartition.small.sideEffect,
|
|
16750
|
+
...chunkPartition.small.pure,
|
|
16751
|
+
...chunkPartition.big.sideEffect,
|
|
16752
|
+
...chunkPartition.big.pure
|
|
16753
|
+
];
|
|
16754
|
+
}
|
|
16755
|
+
const CHAR_DEPENDENT = 'X';
|
|
16756
|
+
const CHAR_INDEPENDENT = '_';
|
|
16757
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16758
|
+
function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16759
|
+
const smallPureChunks = [];
|
|
16760
|
+
const bigPureChunks = [];
|
|
16761
|
+
const smallSideEffectChunks = [];
|
|
16762
|
+
const bigSideEffectChunks = [];
|
|
16763
|
+
const chunkByModule = new Map();
|
|
16751
16764
|
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16765
|
+
const chunkDescription = {
|
|
16766
|
+
dependencies: new Set(),
|
|
16767
|
+
dependentChunks: new Set(),
|
|
16768
|
+
modules,
|
|
16769
|
+
pure: true,
|
|
16770
|
+
signature,
|
|
16771
|
+
size: 0
|
|
16772
|
+
};
|
|
16752
16773
|
let size = 0;
|
|
16753
|
-
|
|
16774
|
+
let pure = true;
|
|
16775
|
+
for (const module of modules) {
|
|
16776
|
+
chunkByModule.set(module, chunkDescription);
|
|
16777
|
+
pure && (pure = !module.hasEffects());
|
|
16778
|
+
// Unfortunately, we cannot take tree-shaking into account here because
|
|
16779
|
+
// rendering did not happen yet
|
|
16780
|
+
size += module.originalCode.length;
|
|
16781
|
+
}
|
|
16782
|
+
chunkDescription.pure = pure;
|
|
16783
|
+
chunkDescription.size = size;
|
|
16784
|
+
(size < minChunkSize
|
|
16785
|
+
? pure
|
|
16786
|
+
? smallPureChunks
|
|
16787
|
+
: smallSideEffectChunks
|
|
16788
|
+
: pure
|
|
16789
|
+
? bigPureChunks
|
|
16790
|
+
: bigSideEffectChunks).push(chunkDescription);
|
|
16791
|
+
}
|
|
16792
|
+
sortChunksAndAddDependencies([bigPureChunks, bigSideEffectChunks, smallPureChunks, smallSideEffectChunks], chunkByModule);
|
|
16793
|
+
return {
|
|
16794
|
+
big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
|
|
16795
|
+
small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
|
|
16796
|
+
};
|
|
16797
|
+
}
|
|
16798
|
+
function sortChunksAndAddDependencies(chunkLists, chunkByModule) {
|
|
16799
|
+
for (const chunks of chunkLists) {
|
|
16800
|
+
chunks.sort(compareChunks);
|
|
16801
|
+
for (const chunk of chunks) {
|
|
16802
|
+
const { dependencies, modules } = chunk;
|
|
16754
16803
|
for (const module of modules) {
|
|
16755
|
-
|
|
16756
|
-
|
|
16804
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16805
|
+
const dependencyChunk = chunkByModule.get(dependency);
|
|
16806
|
+
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
16807
|
+
dependencies.add(dependencyChunk);
|
|
16808
|
+
dependencyChunk.dependentChunks.add(chunk);
|
|
16809
|
+
}
|
|
16757
16810
|
}
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16811
|
+
}
|
|
16812
|
+
}
|
|
16813
|
+
}
|
|
16814
|
+
}
|
|
16815
|
+
function compareChunks({ size: sizeA }, { size: sizeB }) {
|
|
16816
|
+
return sizeA - sizeB;
|
|
16817
|
+
}
|
|
16818
|
+
function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
|
|
16819
|
+
for (const mergedChunk of chunksToBeMerged) {
|
|
16820
|
+
let closestChunk = null;
|
|
16821
|
+
let closestChunkDistance = Infinity;
|
|
16822
|
+
const { signature, modules, pure, size } = mergedChunk;
|
|
16823
|
+
for (const targetChunk of concatLazy(targetChunks)) {
|
|
16824
|
+
if (mergedChunk === targetChunk)
|
|
16825
|
+
continue;
|
|
16826
|
+
// Possible improvement:
|
|
16827
|
+
// For dynamic entries depending on a pure chunk, it is safe to merge that
|
|
16828
|
+
// chunk into the chunk doing the dynamic import (i.e. into an "already
|
|
16829
|
+
// loaded chunk") even if it is not pure.
|
|
16830
|
+
// One way of handling this could be to add all "already loaded entries"
|
|
16831
|
+
// of the dynamic importers into the signature as well. That could also
|
|
16832
|
+
// change the way we do code-splitting for already loaded entries.
|
|
16833
|
+
const distance = pure
|
|
16834
|
+
? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
|
|
16835
|
+
: getSignatureDistance(targetChunk.signature, signature, true);
|
|
16836
|
+
if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
|
|
16837
|
+
if (distance === 1) {
|
|
16838
|
+
closestChunk = targetChunk;
|
|
16839
|
+
break;
|
|
16761
16840
|
}
|
|
16841
|
+
closestChunk = targetChunk;
|
|
16842
|
+
closestChunkDistance = distance;
|
|
16762
16843
|
}
|
|
16763
|
-
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
16764
|
-
continue;
|
|
16765
16844
|
}
|
|
16766
|
-
|
|
16845
|
+
if (closestChunk) {
|
|
16846
|
+
chunksToBeMerged.delete(mergedChunk);
|
|
16847
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16848
|
+
closestChunk.modules.push(...modules);
|
|
16849
|
+
closestChunk.size += size;
|
|
16850
|
+
closestChunk.pure && (closestChunk.pure = pure);
|
|
16851
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16852
|
+
const { dependencies, dependentChunks } = closestChunk;
|
|
16853
|
+
for (const dependency of mergedChunk.dependencies) {
|
|
16854
|
+
dependencies.add(dependency);
|
|
16855
|
+
}
|
|
16856
|
+
for (const dependentChunk of mergedChunk.dependentChunks) {
|
|
16857
|
+
dependentChunks.add(dependentChunk);
|
|
16858
|
+
dependentChunk.dependencies.delete(mergedChunk);
|
|
16859
|
+
dependentChunk.dependencies.add(closestChunk);
|
|
16860
|
+
}
|
|
16861
|
+
dependencies.delete(closestChunk);
|
|
16862
|
+
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16863
|
+
}
|
|
16767
16864
|
}
|
|
16768
|
-
|
|
16865
|
+
}
|
|
16866
|
+
// Merging will not produce cycles if none of the direct non-merged dependencies
|
|
16867
|
+
// of a chunk have the other chunk as a transitive dependency
|
|
16868
|
+
function isValidMerge(mergedChunk, targetChunk) {
|
|
16869
|
+
return !(hasTransitiveDependency(mergedChunk, targetChunk) ||
|
|
16870
|
+
hasTransitiveDependency(targetChunk, mergedChunk));
|
|
16871
|
+
}
|
|
16872
|
+
function hasTransitiveDependency(dependentChunk, dependencyChunk) {
|
|
16873
|
+
const chunksToCheck = new Set(dependentChunk.dependencies);
|
|
16874
|
+
for (const { dependencies } of chunksToCheck) {
|
|
16875
|
+
for (const dependency of dependencies) {
|
|
16876
|
+
if (dependency === dependencyChunk) {
|
|
16877
|
+
return true;
|
|
16878
|
+
}
|
|
16879
|
+
chunksToCheck.add(dependency);
|
|
16880
|
+
}
|
|
16881
|
+
}
|
|
16882
|
+
return false;
|
|
16883
|
+
}
|
|
16884
|
+
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
16885
|
+
const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
16886
|
+
return chunk.pure ? subPartition.pure : subPartition.sideEffect;
|
|
16769
16887
|
}
|
|
16770
16888
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16771
16889
|
let distance = 0;
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "Next-generation ES module bundler",
|
|
5
5
|
"main": "dist/rollup.js",
|
|
6
6
|
"module": "dist/es/rollup.js",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"fsevents": "~2.3.2"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@codemirror/commands": "^6.
|
|
65
|
+
"@codemirror/commands": "^6.2.0",
|
|
66
66
|
"@codemirror/lang-javascript": "^6.1.2",
|
|
67
|
-
"@codemirror/language": "^6.
|
|
67
|
+
"@codemirror/language": "^6.4.0",
|
|
68
68
|
"@codemirror/search": "^6.2.3",
|
|
69
69
|
"@codemirror/state": "^6.2.0",
|
|
70
|
-
"@codemirror/view": "^6.7.
|
|
70
|
+
"@codemirror/view": "^6.7.3",
|
|
71
71
|
"@jridgewell/sourcemap-codec": "^1.4.14",
|
|
72
72
|
"@rollup/plugin-alias": "^4.0.2",
|
|
73
73
|
"@rollup/plugin-buble": "^1.0.1",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@types/node": "^14.18.36",
|
|
83
83
|
"@types/signal-exit": "^3.0.1",
|
|
84
84
|
"@types/yargs-parser": "^21.0.0",
|
|
85
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
86
|
-
"@typescript-eslint/parser": "^5.
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
|
86
|
+
"@typescript-eslint/parser": "^5.50.0",
|
|
87
87
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
88
88
|
"@vue/eslint-config-typescript": "^11.0.2",
|
|
89
89
|
"acorn": "^8.8.1",
|
|
@@ -99,12 +99,12 @@
|
|
|
99
99
|
"date-time": "^4.0.0",
|
|
100
100
|
"es5-shim": "^4.6.7",
|
|
101
101
|
"es6-shim": "^0.35.7",
|
|
102
|
-
"eslint": "^8.
|
|
102
|
+
"eslint": "^8.33.0",
|
|
103
103
|
"eslint-config-prettier": "^8.6.0",
|
|
104
|
-
"eslint-plugin-import": "^2.
|
|
104
|
+
"eslint-plugin-import": "^2.27.5",
|
|
105
105
|
"eslint-plugin-prettier": "^4.2.1",
|
|
106
106
|
"eslint-plugin-unicorn": "^45.0.2",
|
|
107
|
-
"eslint-plugin-vue": "^9.
|
|
107
|
+
"eslint-plugin-vue": "^9.9.0",
|
|
108
108
|
"fixturify": "^3.0.0",
|
|
109
109
|
"flru": "^1.0.2",
|
|
110
110
|
"fs-extra": "^11.1.0",
|
|
@@ -116,11 +116,10 @@
|
|
|
116
116
|
"lint-staged": "^13.1.0",
|
|
117
117
|
"locate-character": "^2.0.5",
|
|
118
118
|
"magic-string": "^0.27.0",
|
|
119
|
-
"mermaid": "~9.1.7",
|
|
120
119
|
"mocha": "^10.2.0",
|
|
121
120
|
"nyc": "^15.1.0",
|
|
122
|
-
"pinia": "^2.0.
|
|
123
|
-
"prettier": "^2.8.
|
|
121
|
+
"pinia": "^2.0.29",
|
|
122
|
+
"prettier": "^2.8.3",
|
|
124
123
|
"pretty-bytes": "^6.0.0",
|
|
125
124
|
"pretty-ms": "^8.0.0",
|
|
126
125
|
"requirejs": "^2.3.6",
|
|
@@ -137,7 +136,7 @@
|
|
|
137
136
|
"terser": "^5.16.1",
|
|
138
137
|
"tslib": "^2.4.1",
|
|
139
138
|
"typescript": "^4.9.4",
|
|
140
|
-
"vitepress": "^1.0.0-alpha.
|
|
139
|
+
"vitepress": "^1.0.0-alpha.44",
|
|
141
140
|
"vitepress-plugin-mermaid": "^2.0.8",
|
|
142
141
|
"vue": "^3.2.45",
|
|
143
142
|
"weak-napi": "^2.0.2",
|