rollup 3.6.0-1 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +123 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +133 -333
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +2 -0
- 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 +133 -334
- 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.6.0
|
|
4
|
-
Mon, 05 Dec 2022
|
|
3
|
+
Rollup.js v3.6.0
|
|
4
|
+
Mon, 05 Dec 2022 11:26:13 GMT - commit de6675b4404a53f664769ba56bfdfdc56bf68531
|
|
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.6.0
|
|
34
|
+
var version$1 = "3.6.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -2828,7 +2828,7 @@ function formatAssertions(assertions, { getObject }) {
|
|
|
2828
2828
|
|
|
2829
2829
|
function getOrCreate(map, key, init) {
|
|
2830
2830
|
const existing = map.get(key);
|
|
2831
|
-
if (existing
|
|
2831
|
+
if (existing) {
|
|
2832
2832
|
return existing;
|
|
2833
2833
|
}
|
|
2834
2834
|
const value = init();
|
|
@@ -3142,6 +3142,8 @@ class ExternalModule {
|
|
|
3142
3142
|
get dynamicImporters() {
|
|
3143
3143
|
return dynamicImporters.sort();
|
|
3144
3144
|
},
|
|
3145
|
+
exportedBindings: null,
|
|
3146
|
+
exports: null,
|
|
3145
3147
|
hasDefaultExport: null,
|
|
3146
3148
|
get hasModuleSideEffects() {
|
|
3147
3149
|
warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', true, options);
|
|
@@ -11768,12 +11770,7 @@ class PrivateIdentifier extends NodeBase {
|
|
|
11768
11770
|
class Program extends NodeBase {
|
|
11769
11771
|
constructor() {
|
|
11770
11772
|
super(...arguments);
|
|
11771
|
-
this.hasCachedEffect =
|
|
11772
|
-
}
|
|
11773
|
-
hasCachedEffects() {
|
|
11774
|
-
return this.hasCachedEffect === null
|
|
11775
|
-
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
|
|
11776
|
-
: this.hasCachedEffect;
|
|
11773
|
+
this.hasCachedEffect = false;
|
|
11777
11774
|
}
|
|
11778
11775
|
hasEffects(context) {
|
|
11779
11776
|
// We are caching here to later more efficiently identify side-effect-free modules
|
|
@@ -13335,7 +13332,7 @@ class Module {
|
|
|
13335
13332
|
this.preserveSignature = this.options.preserveEntrySignatures;
|
|
13336
13333
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13337
13334
|
const module = this;
|
|
13338
|
-
const { dynamicImports, dynamicImporters, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAssertions } = this;
|
|
13335
|
+
const { dynamicImports, dynamicImporters, exportAllSources, exports, implicitlyLoadedAfter, implicitlyLoadedBefore, importers, reexportDescriptions, sourcesWithAssertions } = this;
|
|
13339
13336
|
this.info = {
|
|
13340
13337
|
assertions,
|
|
13341
13338
|
ast: null,
|
|
@@ -13353,6 +13350,23 @@ class Module {
|
|
|
13353
13350
|
get dynamicImporters() {
|
|
13354
13351
|
return dynamicImporters.sort();
|
|
13355
13352
|
},
|
|
13353
|
+
get exportedBindings() {
|
|
13354
|
+
const exportBindings = { '.': [...exports.keys()] };
|
|
13355
|
+
for (const [name, { source }] of reexportDescriptions) {
|
|
13356
|
+
(exportBindings[source] ?? (exportBindings[source] = [])).push(name);
|
|
13357
|
+
}
|
|
13358
|
+
for (const source of exportAllSources) {
|
|
13359
|
+
(exportBindings[source] ?? (exportBindings[source] = [])).push('*');
|
|
13360
|
+
}
|
|
13361
|
+
return exportBindings;
|
|
13362
|
+
},
|
|
13363
|
+
get exports() {
|
|
13364
|
+
return [
|
|
13365
|
+
...exports.keys(),
|
|
13366
|
+
...reexportDescriptions.keys(),
|
|
13367
|
+
...[...exportAllSources].map(() => '*')
|
|
13368
|
+
];
|
|
13369
|
+
},
|
|
13356
13370
|
get hasDefaultExport() {
|
|
13357
13371
|
// This information is only valid after parsing
|
|
13358
13372
|
if (!module.ast) {
|
|
@@ -13616,7 +13630,8 @@ class Module {
|
|
|
13616
13630
|
return [null];
|
|
13617
13631
|
}
|
|
13618
13632
|
hasEffects() {
|
|
13619
|
-
return this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13633
|
+
return (this.info.moduleSideEffects === 'no-treeshake' ||
|
|
13634
|
+
(this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
|
|
13620
13635
|
}
|
|
13621
13636
|
include() {
|
|
13622
13637
|
const context = createInclusionContext();
|
|
@@ -16215,138 +16230,18 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
16215
16230
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
16216
16231
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
16217
16232
|
|
|
16218
|
-
const BYTE_UNITS = [
|
|
16219
|
-
'B',
|
|
16220
|
-
'kB',
|
|
16221
|
-
'MB',
|
|
16222
|
-
'GB',
|
|
16223
|
-
'TB',
|
|
16224
|
-
'PB',
|
|
16225
|
-
'EB',
|
|
16226
|
-
'ZB',
|
|
16227
|
-
'YB',
|
|
16228
|
-
];
|
|
16229
|
-
|
|
16230
|
-
const BIBYTE_UNITS = [
|
|
16231
|
-
'B',
|
|
16232
|
-
'kiB',
|
|
16233
|
-
'MiB',
|
|
16234
|
-
'GiB',
|
|
16235
|
-
'TiB',
|
|
16236
|
-
'PiB',
|
|
16237
|
-
'EiB',
|
|
16238
|
-
'ZiB',
|
|
16239
|
-
'YiB',
|
|
16240
|
-
];
|
|
16241
|
-
|
|
16242
|
-
const BIT_UNITS = [
|
|
16243
|
-
'b',
|
|
16244
|
-
'kbit',
|
|
16245
|
-
'Mbit',
|
|
16246
|
-
'Gbit',
|
|
16247
|
-
'Tbit',
|
|
16248
|
-
'Pbit',
|
|
16249
|
-
'Ebit',
|
|
16250
|
-
'Zbit',
|
|
16251
|
-
'Ybit',
|
|
16252
|
-
];
|
|
16253
|
-
|
|
16254
|
-
const BIBIT_UNITS = [
|
|
16255
|
-
'b',
|
|
16256
|
-
'kibit',
|
|
16257
|
-
'Mibit',
|
|
16258
|
-
'Gibit',
|
|
16259
|
-
'Tibit',
|
|
16260
|
-
'Pibit',
|
|
16261
|
-
'Eibit',
|
|
16262
|
-
'Zibit',
|
|
16263
|
-
'Yibit',
|
|
16264
|
-
];
|
|
16265
|
-
|
|
16266
|
-
/*
|
|
16267
|
-
Formats the given number using `Number#toLocaleString`.
|
|
16268
|
-
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
16269
|
-
- If locale is true, the system default locale is used for translation.
|
|
16270
|
-
- If no value for locale is specified, the number is returned unmodified.
|
|
16271
|
-
*/
|
|
16272
|
-
const toLocaleString = (number, locale, options) => {
|
|
16273
|
-
let result = number;
|
|
16274
|
-
if (typeof locale === 'string' || Array.isArray(locale)) {
|
|
16275
|
-
result = number.toLocaleString(locale, options);
|
|
16276
|
-
} else if (locale === true || options !== undefined) {
|
|
16277
|
-
result = number.toLocaleString(undefined, options);
|
|
16278
|
-
}
|
|
16279
|
-
|
|
16280
|
-
return result;
|
|
16281
|
-
};
|
|
16282
|
-
|
|
16283
|
-
function prettyBytes(number, options) {
|
|
16284
|
-
if (!Number.isFinite(number)) {
|
|
16285
|
-
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
16286
|
-
}
|
|
16287
|
-
|
|
16288
|
-
options = {
|
|
16289
|
-
bits: false,
|
|
16290
|
-
binary: false,
|
|
16291
|
-
...options,
|
|
16292
|
-
};
|
|
16293
|
-
|
|
16294
|
-
const UNITS = options.bits
|
|
16295
|
-
? (options.binary ? BIBIT_UNITS : BIT_UNITS)
|
|
16296
|
-
: (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
|
|
16297
|
-
|
|
16298
|
-
if (options.signed && number === 0) {
|
|
16299
|
-
return ` 0 ${UNITS[0]}`;
|
|
16300
|
-
}
|
|
16301
|
-
|
|
16302
|
-
const isNegative = number < 0;
|
|
16303
|
-
const prefix = isNegative ? '-' : (options.signed ? '+' : '');
|
|
16304
|
-
|
|
16305
|
-
if (isNegative) {
|
|
16306
|
-
number = -number;
|
|
16307
|
-
}
|
|
16308
|
-
|
|
16309
|
-
let localeOptions;
|
|
16310
|
-
|
|
16311
|
-
if (options.minimumFractionDigits !== undefined) {
|
|
16312
|
-
localeOptions = {minimumFractionDigits: options.minimumFractionDigits};
|
|
16313
|
-
}
|
|
16314
|
-
|
|
16315
|
-
if (options.maximumFractionDigits !== undefined) {
|
|
16316
|
-
localeOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};
|
|
16317
|
-
}
|
|
16318
|
-
|
|
16319
|
-
if (number < 1) {
|
|
16320
|
-
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
16321
|
-
return prefix + numberString + ' ' + UNITS[0];
|
|
16322
|
-
}
|
|
16323
|
-
|
|
16324
|
-
const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
|
|
16325
|
-
number /= (options.binary ? 1024 : 1000) ** exponent;
|
|
16326
|
-
|
|
16327
|
-
if (!localeOptions) {
|
|
16328
|
-
number = number.toPrecision(3);
|
|
16329
|
-
}
|
|
16330
|
-
|
|
16331
|
-
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
16332
|
-
|
|
16333
|
-
const unit = UNITS[exponent];
|
|
16334
|
-
|
|
16335
|
-
return prefix + numberString + ' ' + unit;
|
|
16336
|
-
}
|
|
16337
|
-
|
|
16338
16233
|
/**
|
|
16339
16234
|
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
16340
16235
|
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
16341
16236
|
* there is a chance that the iterators will not be fully exhausted.
|
|
16342
16237
|
*/
|
|
16343
|
-
function* concatLazy(iterables) {
|
|
16238
|
+
function* concatLazy(...iterables) {
|
|
16344
16239
|
for (const iterable of iterables) {
|
|
16345
16240
|
yield* iterable;
|
|
16346
16241
|
}
|
|
16347
16242
|
}
|
|
16348
16243
|
|
|
16349
|
-
function getChunkAssignments(
|
|
16244
|
+
function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
|
|
16350
16245
|
const chunkDefinitions = [];
|
|
16351
16246
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
16352
16247
|
const manualChunkModulesByAlias = Object.create(null);
|
|
@@ -16356,19 +16251,53 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
|
|
|
16356
16251
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
16357
16252
|
chunkDefinitions.push({ alias, modules });
|
|
16358
16253
|
}
|
|
16359
|
-
const alreadyLoadedModulesByDynamicEntry = getAlreadyLoadedModulesByDynamicEntry(entries);
|
|
16360
16254
|
const assignedEntryPointsByModule = new Map();
|
|
16361
|
-
|
|
16255
|
+
const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
|
|
16256
|
+
const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
|
|
16257
|
+
const staticEntries = new Set(entryModules);
|
|
16258
|
+
function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
|
|
16259
|
+
const modulesToHandle = new Set([entry]);
|
|
16260
|
+
for (const module of modulesToHandle) {
|
|
16261
|
+
const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
|
|
16262
|
+
if (dynamicDependentEntryPoints &&
|
|
16263
|
+
areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
|
|
16264
|
+
continue;
|
|
16265
|
+
}
|
|
16266
|
+
else {
|
|
16267
|
+
assignedEntryPoints.add(entry);
|
|
16268
|
+
}
|
|
16269
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16270
|
+
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
16271
|
+
modulesToHandle.add(dependency);
|
|
16272
|
+
}
|
|
16273
|
+
}
|
|
16274
|
+
}
|
|
16275
|
+
}
|
|
16276
|
+
function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
|
|
16277
|
+
const entriesToCheck = new Set(entryPoints);
|
|
16278
|
+
for (const entry of entriesToCheck) {
|
|
16279
|
+
if (!containedIn.has(entry)) {
|
|
16280
|
+
if (staticEntries.has(entry))
|
|
16281
|
+
return false;
|
|
16282
|
+
const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
|
|
16283
|
+
for (const dependentEntry of dynamicallyDependentEntryPoints) {
|
|
16284
|
+
entriesToCheck.add(dependentEntry);
|
|
16285
|
+
}
|
|
16286
|
+
}
|
|
16287
|
+
}
|
|
16288
|
+
return true;
|
|
16289
|
+
}
|
|
16290
|
+
for (const entry of entryModules) {
|
|
16362
16291
|
if (!modulesInManualChunks.has(entry)) {
|
|
16363
|
-
assignEntryToStaticDependencies(entry,
|
|
16292
|
+
assignEntryToStaticDependencies(entry, null);
|
|
16364
16293
|
}
|
|
16365
16294
|
}
|
|
16366
|
-
for (const entry of
|
|
16295
|
+
for (const entry of dynamicEntryModules) {
|
|
16367
16296
|
if (!modulesInManualChunks.has(entry)) {
|
|
16368
|
-
assignEntryToStaticDependencies(entry,
|
|
16297
|
+
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
16369
16298
|
}
|
|
16370
16299
|
}
|
|
16371
|
-
chunkDefinitions.push(...createChunks([...
|
|
16300
|
+
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
|
|
16372
16301
|
return chunkDefinitions;
|
|
16373
16302
|
}
|
|
16374
16303
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -16383,87 +16312,47 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
|
|
|
16383
16312
|
}
|
|
16384
16313
|
}
|
|
16385
16314
|
}
|
|
16386
|
-
function
|
|
16387
|
-
const
|
|
16315
|
+
function analyzeModuleGraph(entryModules) {
|
|
16316
|
+
const dynamicEntryModules = new Set();
|
|
16388
16317
|
const dependentEntryPointsByModule = new Map();
|
|
16389
|
-
const dynamicImportsByEntry = new Map();
|
|
16390
|
-
const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
|
|
16391
16318
|
const entriesToHandle = new Set(entryModules);
|
|
16392
16319
|
for (const currentEntry of entriesToHandle) {
|
|
16393
16320
|
const modulesToHandle = new Set([currentEntry]);
|
|
16394
|
-
const dynamicImports = new Set();
|
|
16395
|
-
dynamicImportsByEntry.set(currentEntry, dynamicImports);
|
|
16396
16321
|
for (const module of modulesToHandle) {
|
|
16397
16322
|
getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry);
|
|
16398
16323
|
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16399
16324
|
if (!(dependency instanceof ExternalModule)) {
|
|
16400
16325
|
modulesToHandle.add(dependency);
|
|
16401
|
-
allModules.add(dependency);
|
|
16402
16326
|
}
|
|
16403
16327
|
}
|
|
16404
16328
|
for (const { resolution } of module.dynamicImports) {
|
|
16405
16329
|
if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
|
|
16406
|
-
|
|
16407
|
-
getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, resolution, () => new Set()).add(currentEntry);
|
|
16330
|
+
dynamicEntryModules.add(resolution);
|
|
16408
16331
|
entriesToHandle.add(resolution);
|
|
16409
|
-
allModules.add(resolution);
|
|
16410
16332
|
}
|
|
16411
16333
|
}
|
|
16412
16334
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
16413
|
-
|
|
16414
|
-
getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dependency, () => new Set()).add(currentEntry);
|
|
16335
|
+
dynamicEntryModules.add(dependency);
|
|
16415
16336
|
entriesToHandle.add(dependency);
|
|
16416
|
-
allModules.add(dependency);
|
|
16417
|
-
}
|
|
16418
|
-
}
|
|
16419
|
-
}
|
|
16420
|
-
return buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry);
|
|
16421
|
-
}
|
|
16422
|
-
function buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry) {
|
|
16423
|
-
const alreadyLoadedModulesByDynamicEntry = new Map();
|
|
16424
|
-
for (const dynamicEntry of dynamicallyDependentEntryPointsByDynamicEntry.keys()) {
|
|
16425
|
-
alreadyLoadedModulesByDynamicEntry.set(dynamicEntry, new Set());
|
|
16426
|
-
}
|
|
16427
|
-
for (const module of allModules) {
|
|
16428
|
-
const dependentEntryPoints = dependentEntryPointsByModule.get(module);
|
|
16429
|
-
for (const entry of dependentEntryPoints) {
|
|
16430
|
-
const dynamicEntriesToHandle = [...dynamicImportsByEntry.get(entry)];
|
|
16431
|
-
nextDynamicEntry: for (const dynamicEntry of dynamicEntriesToHandle) {
|
|
16432
|
-
const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
|
|
16433
|
-
if (alreadyLoadedModules.has(module)) {
|
|
16434
|
-
continue;
|
|
16435
|
-
}
|
|
16436
|
-
for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
|
|
16437
|
-
if (!(dependentEntryPoints.has(siblingDependentEntry) ||
|
|
16438
|
-
alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
|
|
16439
|
-
continue nextDynamicEntry;
|
|
16440
|
-
}
|
|
16441
|
-
}
|
|
16442
|
-
alreadyLoadedModules.add(module);
|
|
16443
|
-
dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
|
|
16444
16337
|
}
|
|
16445
16338
|
}
|
|
16446
16339
|
}
|
|
16447
|
-
return
|
|
16340
|
+
return { dependentEntryPointsByModule, dynamicEntryModules };
|
|
16448
16341
|
}
|
|
16449
|
-
function
|
|
16450
|
-
const
|
|
16451
|
-
for (const
|
|
16452
|
-
const
|
|
16453
|
-
|
|
16454
|
-
|
|
16455
|
-
|
|
16456
|
-
|
|
16457
|
-
|
|
16458
|
-
|
|
16459
|
-
assignedEntryPoints.add(entry);
|
|
16460
|
-
}
|
|
16461
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16462
|
-
if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
|
|
16463
|
-
modulesToHandle.add(dependency);
|
|
16342
|
+
function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules) {
|
|
16343
|
+
const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
|
|
16344
|
+
for (const dynamicEntry of dynamicEntryModules) {
|
|
16345
|
+
const dynamicDependentEntryPoints = getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dynamicEntry, () => new Set());
|
|
16346
|
+
for (const importer of [
|
|
16347
|
+
...dynamicEntry.includedDynamicImporters,
|
|
16348
|
+
...dynamicEntry.implicitlyLoadedAfter
|
|
16349
|
+
]) {
|
|
16350
|
+
for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
|
|
16351
|
+
dynamicDependentEntryPoints.add(entryPoint);
|
|
16464
16352
|
}
|
|
16465
16353
|
}
|
|
16466
16354
|
}
|
|
16355
|
+
return dynamicallyDependentEntryPointsByDynamicEntry;
|
|
16467
16356
|
}
|
|
16468
16357
|
function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
|
|
16469
16358
|
const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
|
|
@@ -16472,49 +16361,43 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize)
|
|
|
16472
16361
|
alias: null,
|
|
16473
16362
|
modules
|
|
16474
16363
|
}))
|
|
16475
|
-
: getOptimizedChunks(chunkModulesBySignature, minChunkSize)
|
|
16476
|
-
alias: null,
|
|
16477
|
-
modules
|
|
16478
|
-
}));
|
|
16364
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
16479
16365
|
}
|
|
16480
|
-
/**
|
|
16481
|
-
* This function tries to get rid of small chunks by merging them with other
|
|
16482
|
-
* chunks. In order to merge chunks, one must obey the following rule:
|
|
16483
|
-
* - When merging several chunks, at most one of the chunks can have side
|
|
16484
|
-
* effects
|
|
16485
|
-
* - When one of the chunks has side effects, the entry points depending on that
|
|
16486
|
-
* chunk need to be a super set of the entry points depending on the other
|
|
16487
|
-
* chunks
|
|
16488
|
-
* - Pure chunks can always be merged
|
|
16489
|
-
* - We use the entry point dependence signature to calculate "chunk distance",
|
|
16490
|
-
* i.e. how likely it is that two chunks are loaded together
|
|
16491
|
-
*/
|
|
16492
16366
|
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16493
16367
|
timeStart('optimize chunks', 3);
|
|
16494
|
-
const
|
|
16495
|
-
|
|
16496
|
-
|
|
16497
|
-
|
|
16498
|
-
|
|
16499
|
-
|
|
16500
|
-
|
|
16501
|
-
|
|
16502
|
-
|
|
16503
|
-
|
|
16504
|
-
|
|
16505
|
-
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
|
|
16368
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
16369
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
16370
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
16371
|
+
let closestChunk = null;
|
|
16372
|
+
let closestChunkDistance = Infinity;
|
|
16373
|
+
const { signature, size, modules } = sourceChunk;
|
|
16374
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
16375
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
16376
|
+
if (distance === 1) {
|
|
16377
|
+
closestChunk = targetChunk;
|
|
16378
|
+
break;
|
|
16379
|
+
}
|
|
16380
|
+
else if (distance < closestChunkDistance) {
|
|
16381
|
+
closestChunk = targetChunk;
|
|
16382
|
+
closestChunkDistance = distance;
|
|
16383
|
+
}
|
|
16384
|
+
}
|
|
16385
|
+
if (closestChunk) {
|
|
16386
|
+
closestChunk.modules.push(...modules);
|
|
16387
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
16388
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16389
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
16390
|
+
chunksToBeMerged.delete(closestChunk);
|
|
16391
|
+
unmergeableChunks.push(closestChunk);
|
|
16392
|
+
}
|
|
16393
|
+
}
|
|
16394
|
+
}
|
|
16395
|
+
else {
|
|
16396
|
+
unmergeableChunks.push(sourceChunk);
|
|
16397
|
+
}
|
|
16398
|
+
}
|
|
16509
16399
|
timeEnd('optimize chunks', 3);
|
|
16510
|
-
|
|
16511
|
-
...chunkPartition.small.sideEffect,
|
|
16512
|
-
...chunkPartition.small.pure,
|
|
16513
|
-
...chunkPartition.big.sideEffect,
|
|
16514
|
-
...chunkPartition.big.pure
|
|
16515
|
-
];
|
|
16516
|
-
console.log(`${result.length} chunks remaining.`);
|
|
16517
|
-
return result;
|
|
16400
|
+
return unmergeableChunks;
|
|
16518
16401
|
}
|
|
16519
16402
|
const CHAR_DEPENDENT = 'X';
|
|
16520
16403
|
const CHAR_INDEPENDENT = '_';
|
|
@@ -16536,111 +16419,28 @@ function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints)
|
|
|
16536
16419
|
}
|
|
16537
16420
|
return chunkModules;
|
|
16538
16421
|
}
|
|
16539
|
-
function
|
|
16540
|
-
const
|
|
16541
|
-
const
|
|
16542
|
-
const
|
|
16543
|
-
const bigSideEffectChunks = [];
|
|
16422
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
16423
|
+
const chunksToBeMerged = new Set();
|
|
16424
|
+
const unmergeableChunks = [];
|
|
16425
|
+
const alias = null;
|
|
16544
16426
|
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16545
16427
|
let size = 0;
|
|
16546
|
-
|
|
16547
|
-
|
|
16548
|
-
|
|
16549
|
-
|
|
16550
|
-
pure && (pure = !module.hasEffects());
|
|
16551
|
-
size += module.magicString.toString().length;
|
|
16552
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16553
|
-
if (!(dependency instanceof ExternalModule)) {
|
|
16554
|
-
dependencies.add(dependency);
|
|
16555
|
-
transitiveDependencies.add(dependency);
|
|
16428
|
+
checkModules: {
|
|
16429
|
+
for (const module of modules) {
|
|
16430
|
+
if (module.hasEffects()) {
|
|
16431
|
+
break checkModules;
|
|
16556
16432
|
}
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
16561
|
-
if (!(dependency instanceof ExternalModule)) {
|
|
16562
|
-
transitiveDependencies.add(dependency);
|
|
16563
|
-
}
|
|
16564
|
-
}
|
|
16565
|
-
}
|
|
16566
|
-
(size < minChunkSize
|
|
16567
|
-
? pure
|
|
16568
|
-
? smallPureChunks
|
|
16569
|
-
: smallSideEffectChunks
|
|
16570
|
-
: pure
|
|
16571
|
-
? bigPureChunks
|
|
16572
|
-
: bigSideEffectChunks).push({ dependencies, modules, pure, signature, size, transitiveDependencies });
|
|
16573
|
-
}
|
|
16574
|
-
for (const chunks of [
|
|
16575
|
-
bigPureChunks,
|
|
16576
|
-
bigSideEffectChunks,
|
|
16577
|
-
smallPureChunks,
|
|
16578
|
-
smallSideEffectChunks
|
|
16579
|
-
]) {
|
|
16580
|
-
chunks.sort(compareChunks);
|
|
16581
|
-
}
|
|
16582
|
-
return {
|
|
16583
|
-
big: { pure: new Set(bigPureChunks), sideEffect: new Set(bigSideEffectChunks) },
|
|
16584
|
-
small: { pure: new Set(smallPureChunks), sideEffect: new Set(smallSideEffectChunks) }
|
|
16585
|
-
};
|
|
16586
|
-
}
|
|
16587
|
-
function compareChunks({ size: sizeA }, { size: sizeB }) {
|
|
16588
|
-
return sizeA - sizeB;
|
|
16589
|
-
}
|
|
16590
|
-
function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartition) {
|
|
16591
|
-
for (const mergedChunk of chunksToBeMerged) {
|
|
16592
|
-
let closestChunk = null;
|
|
16593
|
-
let closestChunkDistance = Infinity;
|
|
16594
|
-
const { signature, modules, pure, size } = mergedChunk;
|
|
16595
|
-
for (const targetChunk of concatLazy(targetChunks)) {
|
|
16596
|
-
if (mergedChunk === targetChunk)
|
|
16597
|
-
continue;
|
|
16598
|
-
const distance = pure
|
|
16599
|
-
? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
|
|
16600
|
-
: getSignatureDistance(targetChunk.signature, signature, true);
|
|
16601
|
-
if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
|
|
16602
|
-
if (distance === 1) {
|
|
16603
|
-
closestChunk = targetChunk;
|
|
16604
|
-
break;
|
|
16433
|
+
size += module.magicString.toString().length;
|
|
16434
|
+
if (size > minChunkSize) {
|
|
16435
|
+
break checkModules;
|
|
16605
16436
|
}
|
|
16606
|
-
closestChunk = targetChunk;
|
|
16607
|
-
closestChunkDistance = distance;
|
|
16608
|
-
}
|
|
16609
|
-
}
|
|
16610
|
-
if (closestChunk) {
|
|
16611
|
-
chunksToBeMerged.delete(mergedChunk);
|
|
16612
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
|
|
16613
|
-
closestChunk.modules.push(...modules);
|
|
16614
|
-
closestChunk.size += size;
|
|
16615
|
-
closestChunk.pure && (closestChunk.pure = pure);
|
|
16616
|
-
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16617
|
-
const { dependencies, transitiveDependencies } = closestChunk;
|
|
16618
|
-
for (const dependency of mergedChunk.dependencies) {
|
|
16619
|
-
dependencies.add(dependency);
|
|
16620
16437
|
}
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
}
|
|
16624
|
-
getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
|
|
16438
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
16439
|
+
continue;
|
|
16625
16440
|
}
|
|
16441
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
16626
16442
|
}
|
|
16627
|
-
}
|
|
16628
|
-
// If a module is a transitive but not a direct dependency of the other chunk,
|
|
16629
|
-
// merging is prohibited as that would create a new cyclic dependency.
|
|
16630
|
-
function isValidMerge(mergedChunk, targetChunk) {
|
|
16631
|
-
for (const module of mergedChunk.modules) {
|
|
16632
|
-
if (targetChunk.transitiveDependencies.has(module) && !targetChunk.dependencies.has(module))
|
|
16633
|
-
return false;
|
|
16634
|
-
}
|
|
16635
|
-
for (const module of targetChunk.modules) {
|
|
16636
|
-
if (mergedChunk.transitiveDependencies.has(module) && !mergedChunk.dependencies.has(module))
|
|
16637
|
-
return false;
|
|
16638
|
-
}
|
|
16639
|
-
return true;
|
|
16640
|
-
}
|
|
16641
|
-
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
16642
|
-
const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
16643
|
-
return chunk.pure ? subPartition.pure : subPartition.sideEffect;
|
|
16443
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
16644
16444
|
}
|
|
16645
16445
|
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16646
16446
|
let distance = 0;
|
|
@@ -25474,7 +25274,6 @@ exports.loadFsEvents = loadFsEvents;
|
|
|
25474
25274
|
exports.mergeOptions = mergeOptions;
|
|
25475
25275
|
exports.normalizePluginOption = normalizePluginOption;
|
|
25476
25276
|
exports.picomatch = picomatch$1;
|
|
25477
|
-
exports.prettyBytes = prettyBytes;
|
|
25478
25277
|
exports.printQuotedStringList = printQuotedStringList;
|
|
25479
25278
|
exports.relativeId = relativeId;
|
|
25480
25279
|
exports.rollup = rollup;
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED