rollup 4.7.0 → 4.9.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/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +196 -165
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +76 -8
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +196 -165
- package/dist/shared/watch-cli.js +4 -4
- package/dist/shared/watch.js +2 -2
- package/package.json +14 -14
- package/dist/shared/watch-proxy.js +0 -88
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.9.0
|
|
4
|
+
Wed, 13 Dec 2023 09:23:48 GMT - commit c5337ef28a71c796e768a9f0edb3d7259a93f1aa
|
|
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 = "4.
|
|
34
|
+
var version = "4.9.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -3506,6 +3506,20 @@ function makeLegal(value) {
|
|
|
3506
3506
|
value = `_${value}`;
|
|
3507
3507
|
return value || '_';
|
|
3508
3508
|
}
|
|
3509
|
+
const VALID_IDENTIFIER_REGEXP = /^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u;
|
|
3510
|
+
const NUMBER_REGEXP = /^\d+$/;
|
|
3511
|
+
function stringifyObjectKeyIfNeeded(key) {
|
|
3512
|
+
if (VALID_IDENTIFIER_REGEXP.test(key) || NUMBER_REGEXP.test(key)) {
|
|
3513
|
+
return key;
|
|
3514
|
+
}
|
|
3515
|
+
return JSON.stringify(key);
|
|
3516
|
+
}
|
|
3517
|
+
function stringifyIdentifierIfNeeded(key) {
|
|
3518
|
+
if (VALID_IDENTIFIER_REGEXP.test(key)) {
|
|
3519
|
+
return key;
|
|
3520
|
+
}
|
|
3521
|
+
return JSON.stringify(key);
|
|
3522
|
+
}
|
|
3509
3523
|
|
|
3510
3524
|
class ExternalModule {
|
|
3511
3525
|
constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath, attributes) {
|
|
@@ -9281,7 +9295,7 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
|
|
|
9281
9295
|
if (exportedVariables.length === 1 &&
|
|
9282
9296
|
exportNamesByVariable.get(exportedVariables[0]).length === 1) {
|
|
9283
9297
|
const variable = exportedVariables[0];
|
|
9284
|
-
return `exports(
|
|
9298
|
+
return `exports(${JSON.stringify(exportNamesByVariable.get(variable)[0])},${_}${variable.getName(getPropertyAccess)}${modifier})`;
|
|
9285
9299
|
}
|
|
9286
9300
|
else {
|
|
9287
9301
|
const fields = [];
|
|
@@ -9293,8 +9307,9 @@ function getSystemExportStatement(exportedVariables, { exportNamesByVariable, sn
|
|
|
9293
9307
|
return `exports(${getObject(fields, { lineBreakIndent: null })})`;
|
|
9294
9308
|
}
|
|
9295
9309
|
}
|
|
9310
|
+
// This is only invoked if there is exactly one export name
|
|
9296
9311
|
function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
|
|
9297
|
-
code.prependRight(expressionStart, `exports(
|
|
9312
|
+
code.prependRight(expressionStart, `exports(${JSON.stringify(exportNamesByVariable.get(exportedVariable)[0])},${_}`);
|
|
9298
9313
|
code.appendLeft(expressionEnd, ')');
|
|
9299
9314
|
}
|
|
9300
9315
|
function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
|
|
@@ -13614,7 +13629,7 @@ class NamespaceVariable extends Variable {
|
|
|
13614
13629
|
if (this.referencedEarly || variable.isReassigned || variable === this) {
|
|
13615
13630
|
return [
|
|
13616
13631
|
null,
|
|
13617
|
-
`get ${name}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
|
|
13632
|
+
`get ${stringifyObjectKeyIfNeeded(name)}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
|
|
13618
13633
|
];
|
|
13619
13634
|
}
|
|
13620
13635
|
return [name, variable.getName(getPropertyAccess)];
|
|
@@ -14645,7 +14660,7 @@ class Module {
|
|
|
14645
14660
|
this.addSource(source, node);
|
|
14646
14661
|
if (node.exported) {
|
|
14647
14662
|
// export * as name from './other'
|
|
14648
|
-
const name = node.exported.name;
|
|
14663
|
+
const name = node.exported instanceof Literal ? node.exported.value : node.exported.name;
|
|
14649
14664
|
this.assertUniqueExportName(name, node.exported.start);
|
|
14650
14665
|
this.reexportDescriptions.set(name, {
|
|
14651
14666
|
localName: '*',
|
|
@@ -14977,7 +14992,7 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
14977
14992
|
name: null
|
|
14978
14993
|
});
|
|
14979
14994
|
exportBlock +=
|
|
14980
|
-
`Object.defineProperty(exports,${_}
|
|
14995
|
+
`Object.defineProperty(exports,${_}${JSON.stringify(specifier.reexported)},${_}{${n}` +
|
|
14981
14996
|
`${t}enumerable:${_}true,${n}` +
|
|
14982
14997
|
`${t}get:${_}${left}${importName}${right}${n}});`;
|
|
14983
14998
|
}
|
|
@@ -15355,7 +15370,7 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
15355
15370
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
15356
15371
|
.map(specifier => specifier.imported === specifier.local
|
|
15357
15372
|
? specifier.imported
|
|
15358
|
-
: `${specifier.imported} as ${specifier.local}`)
|
|
15373
|
+
: `${stringifyIdentifierIfNeeded(specifier.imported)} as ${specifier.local}`)
|
|
15359
15374
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
15360
15375
|
}
|
|
15361
15376
|
}
|
|
@@ -15383,14 +15398,16 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
15383
15398
|
importBlock.push(`import${_}*${_}as ${name} from${_}${pathWithAssertion}`);
|
|
15384
15399
|
}
|
|
15385
15400
|
for (const specifier of namespaceReexports) {
|
|
15386
|
-
importBlock.push(`export${_}{${_}${name === specifier.reexported
|
|
15401
|
+
importBlock.push(`export${_}{${_}${name === specifier.reexported
|
|
15402
|
+
? name
|
|
15403
|
+
: `${name} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`} };`);
|
|
15387
15404
|
}
|
|
15388
15405
|
}
|
|
15389
15406
|
if (namedReexports.length > 0) {
|
|
15390
15407
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
15391
15408
|
.map(specifier => specifier.imported === specifier.reexported
|
|
15392
|
-
? specifier.imported
|
|
15393
|
-
: `${specifier.imported} as ${specifier.reexported}`)
|
|
15409
|
+
? stringifyIdentifierIfNeeded(specifier.imported)
|
|
15410
|
+
: `${stringifyIdentifierIfNeeded(specifier.imported)} as ${stringifyIdentifierIfNeeded(specifier.reexported)}`)
|
|
15394
15411
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
15395
15412
|
}
|
|
15396
15413
|
}
|
|
@@ -15406,7 +15423,7 @@ function getExportBlock(exports, { _, cnst }) {
|
|
|
15406
15423
|
}
|
|
15407
15424
|
exportDeclaration.push(specifier.exported === specifier.local
|
|
15408
15425
|
? specifier.local
|
|
15409
|
-
: `${specifier.local} as ${specifier.exported}`);
|
|
15426
|
+
: `${specifier.local} as ${stringifyIdentifierIfNeeded(specifier.exported)}`);
|
|
15410
15427
|
}
|
|
15411
15428
|
if (exportDeclaration.length > 0) {
|
|
15412
15429
|
exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
|
|
@@ -15822,7 +15839,7 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
15822
15839
|
: module.suggestedVariableName, usedNames, variable.forbiddenNames));
|
|
15823
15840
|
}
|
|
15824
15841
|
else {
|
|
15825
|
-
variable.setRenderNames(null, getSafeName(name, usedNames, variable.forbiddenNames));
|
|
15842
|
+
variable.setRenderNames(null, getSafeName(makeLegal(name), usedNames, variable.forbiddenNames));
|
|
15826
15843
|
}
|
|
15827
15844
|
}
|
|
15828
15845
|
for (const variable of syntheticExports) {
|
|
@@ -17233,11 +17250,15 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log
|
|
|
17233
17250
|
const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
|
|
17234
17251
|
const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
|
|
17235
17252
|
// Each chunk is identified by its position in this array
|
|
17236
|
-
const
|
|
17237
|
-
|
|
17238
|
-
//
|
|
17239
|
-
|
|
17240
|
-
|
|
17253
|
+
const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
|
|
17254
|
+
const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
|
|
17255
|
+
// Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
|
|
17256
|
+
// If we no longer want this, we should make a copy here.
|
|
17257
|
+
const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
|
|
17258
|
+
// This mutates the dependentEntries in chunkAtoms
|
|
17259
|
+
removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
|
|
17260
|
+
const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
|
|
17261
|
+
chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
|
|
17241
17262
|
alias: null,
|
|
17242
17263
|
modules
|
|
17243
17264
|
})));
|
|
@@ -17346,7 +17367,7 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
|
|
|
17346
17367
|
}
|
|
17347
17368
|
return dynamicallyDependentEntriesByDynamicEntry;
|
|
17348
17369
|
}
|
|
17349
|
-
function
|
|
17370
|
+
function getChunksWithSameDependentEntries(modulesWithDependentEntries) {
|
|
17350
17371
|
const chunkModules = Object.create(null);
|
|
17351
17372
|
for (const { dependentEntries, modules } of modulesWithDependentEntries) {
|
|
17352
17373
|
let chunkSignature = 0n;
|
|
@@ -17367,55 +17388,152 @@ function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManu
|
|
|
17367
17388
|
}
|
|
17368
17389
|
}
|
|
17369
17390
|
}
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
* first argument. It will also consume its second argument, so if
|
|
17373
|
-
* dynamicallyDependentEntriesByDynamicEntry is ever needed after this, we
|
|
17374
|
-
* should make a copy.
|
|
17375
|
-
*/
|
|
17376
|
-
function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
|
|
17377
|
-
// The indices correspond to the indices in allEntries. The chunks correspond
|
|
17391
|
+
function getStaticDependencyAtomsByEntry(allEntries, chunkAtoms) {
|
|
17392
|
+
// The indices correspond to the indices in allEntries. The atoms correspond
|
|
17378
17393
|
// to bits in the bigint values where chunk 0 is the lowest bit.
|
|
17379
|
-
const
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
for (const { dependentEntries } of chunks) {
|
|
17394
|
+
const staticDependencyAtomsByEntry = allEntries.map(() => 0n);
|
|
17395
|
+
// This toggles the bits for each atom that is a dependency of an entry
|
|
17396
|
+
let atomMask = 1n;
|
|
17397
|
+
for (const { dependentEntries } of chunkAtoms) {
|
|
17384
17398
|
for (const entryIndex of dependentEntries) {
|
|
17385
|
-
|
|
17386
|
-
}
|
|
17387
|
-
|
|
17388
|
-
}
|
|
17389
|
-
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17393
|
-
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17397
|
-
|
|
17398
|
-
|
|
17399
|
-
|
|
17400
|
-
|
|
17401
|
-
|
|
17399
|
+
staticDependencyAtomsByEntry[entryIndex] |= atomMask;
|
|
17400
|
+
}
|
|
17401
|
+
atomMask <<= 1n;
|
|
17402
|
+
}
|
|
17403
|
+
return staticDependencyAtomsByEntry;
|
|
17404
|
+
}
|
|
17405
|
+
// Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
|
|
17406
|
+
function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
|
|
17407
|
+
// Dynamic entries have all atoms as already loaded initially because we then
|
|
17408
|
+
// intersect with the static dependency atoms of all dynamic importers.
|
|
17409
|
+
// Static entries cannot have already loaded atoms.
|
|
17410
|
+
const alreadyLoadedAtomsByEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
|
|
17411
|
+
for (const [dynamicEntryIndex, dynamicallyDependentEntries] of dynamicallyDependentEntriesByDynamicEntry) {
|
|
17412
|
+
// We delete here so that they can be added again if necessary to be handled
|
|
17413
|
+
// again by the loop
|
|
17414
|
+
dynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
|
|
17415
|
+
const knownLoadedAtoms = alreadyLoadedAtomsByEntry[dynamicEntryIndex];
|
|
17416
|
+
let updatedLoadedAtoms = knownLoadedAtoms;
|
|
17417
|
+
for (const entryIndex of dynamicallyDependentEntries) {
|
|
17418
|
+
updatedLoadedAtoms &=
|
|
17419
|
+
staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
|
|
17420
|
+
}
|
|
17421
|
+
// If the knownLoadedAtoms changed, all dependent dynamic entries need to be
|
|
17422
|
+
// updated again
|
|
17423
|
+
if (updatedLoadedAtoms !== knownLoadedAtoms) {
|
|
17424
|
+
alreadyLoadedAtomsByEntry[dynamicEntryIndex] = updatedLoadedAtoms;
|
|
17402
17425
|
for (const dynamicImport of dynamicImportsByEntry[dynamicEntryIndex]) {
|
|
17403
|
-
|
|
17426
|
+
// If this adds an entry that was deleted before, it will be handled
|
|
17427
|
+
// again. This is the reason why we delete every entry from this map
|
|
17428
|
+
// that we processed.
|
|
17429
|
+
getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
|
|
17404
17430
|
}
|
|
17405
17431
|
}
|
|
17406
17432
|
}
|
|
17433
|
+
return alreadyLoadedAtomsByEntry;
|
|
17434
|
+
}
|
|
17435
|
+
/**
|
|
17436
|
+
* This removes all unnecessary dynamic entries from the dependentEntries in its
|
|
17437
|
+
* first argument if a chunk is already loaded without that entry.
|
|
17438
|
+
*/
|
|
17439
|
+
function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
|
|
17407
17440
|
// Remove entries from dependent entries if a chunk is already loaded without
|
|
17408
17441
|
// that entry.
|
|
17409
|
-
chunkMask = 1n;
|
|
17410
|
-
for (const { dependentEntries } of
|
|
17442
|
+
let chunkMask = 1n;
|
|
17443
|
+
for (const { dependentEntries } of chunkAtoms) {
|
|
17411
17444
|
for (const entryIndex of dependentEntries) {
|
|
17412
|
-
if ((
|
|
17445
|
+
if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
|
|
17413
17446
|
dependentEntries.delete(entryIndex);
|
|
17414
17447
|
}
|
|
17415
17448
|
}
|
|
17416
17449
|
chunkMask <<= 1n;
|
|
17417
17450
|
}
|
|
17418
17451
|
}
|
|
17452
|
+
function getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize) {
|
|
17453
|
+
const chunksBySignature = Object.create(null);
|
|
17454
|
+
const chunkByModule = new Map();
|
|
17455
|
+
const sizeByAtom = [];
|
|
17456
|
+
let sideEffectAtoms = 0n;
|
|
17457
|
+
let atomMask = 1n;
|
|
17458
|
+
for (const { dependentEntries, modules } of chunkAtoms) {
|
|
17459
|
+
let chunkSignature = 0n;
|
|
17460
|
+
let correlatedAtoms = -1n;
|
|
17461
|
+
for (const entryIndex of dependentEntries) {
|
|
17462
|
+
chunkSignature |= 1n << BigInt(entryIndex);
|
|
17463
|
+
// Correlated atoms are the atoms that are guaranteed to be loaded as
|
|
17464
|
+
// well when a given atom is loaded. It is the intersection of the already
|
|
17465
|
+
// loaded modules of each chunk merged with its static dependencies.
|
|
17466
|
+
correlatedAtoms &=
|
|
17467
|
+
staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
|
|
17468
|
+
}
|
|
17469
|
+
const chunk = (chunksBySignature[String(chunkSignature)] ||= {
|
|
17470
|
+
containedAtoms: 0n,
|
|
17471
|
+
correlatedAtoms,
|
|
17472
|
+
dependencies: new Set(),
|
|
17473
|
+
dependentChunks: new Set(),
|
|
17474
|
+
dependentEntries: new Set(dependentEntries),
|
|
17475
|
+
modules: [],
|
|
17476
|
+
pure: true,
|
|
17477
|
+
size: 0
|
|
17478
|
+
});
|
|
17479
|
+
let atomSize = 0;
|
|
17480
|
+
let pure = true;
|
|
17481
|
+
for (const module of modules) {
|
|
17482
|
+
chunkByModule.set(module, chunk);
|
|
17483
|
+
// Unfortunately, we cannot take tree-shaking into account here because
|
|
17484
|
+
// rendering did not happen yet, but we can detect empty modules
|
|
17485
|
+
if (module.isIncluded()) {
|
|
17486
|
+
pure &&= !module.hasEffects();
|
|
17487
|
+
// we use a trivial size for the default minChunkSize to improve
|
|
17488
|
+
// performance
|
|
17489
|
+
atomSize += minChunkSize > 1 ? module.estimateSize() : 1;
|
|
17490
|
+
}
|
|
17491
|
+
}
|
|
17492
|
+
if (!pure) {
|
|
17493
|
+
sideEffectAtoms |= atomMask;
|
|
17494
|
+
}
|
|
17495
|
+
sizeByAtom.push(atomSize);
|
|
17496
|
+
chunk.containedAtoms |= atomMask;
|
|
17497
|
+
chunk.modules.push(...modules);
|
|
17498
|
+
chunk.pure &&= pure;
|
|
17499
|
+
chunk.size += atomSize;
|
|
17500
|
+
atomMask <<= 1n;
|
|
17501
|
+
}
|
|
17502
|
+
const chunks = Object.values(chunksBySignature);
|
|
17503
|
+
sideEffectAtoms |= addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, atomMask);
|
|
17504
|
+
return { chunks, sideEffectAtoms, sizeByAtom };
|
|
17505
|
+
}
|
|
17506
|
+
function addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, nextAvailableAtomMask) {
|
|
17507
|
+
const signatureByExternalModule = new Map();
|
|
17508
|
+
let externalSideEffectAtoms = 0n;
|
|
17509
|
+
for (const chunk of chunks) {
|
|
17510
|
+
const { dependencies, modules } = chunk;
|
|
17511
|
+
for (const module of modules) {
|
|
17512
|
+
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
17513
|
+
if (dependency instanceof ExternalModule) {
|
|
17514
|
+
if (dependency.info.moduleSideEffects) {
|
|
17515
|
+
const signature = getOrCreate(signatureByExternalModule, dependency, () => {
|
|
17516
|
+
const signature = nextAvailableAtomMask;
|
|
17517
|
+
nextAvailableAtomMask <<= 1n;
|
|
17518
|
+
externalSideEffectAtoms |= signature;
|
|
17519
|
+
return signature;
|
|
17520
|
+
});
|
|
17521
|
+
chunk.containedAtoms |= signature;
|
|
17522
|
+
chunk.correlatedAtoms |= signature;
|
|
17523
|
+
}
|
|
17524
|
+
}
|
|
17525
|
+
else {
|
|
17526
|
+
const dependencyChunk = chunkByModule.get(dependency);
|
|
17527
|
+
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
17528
|
+
dependencies.add(dependencyChunk);
|
|
17529
|
+
dependencyChunk.dependentChunks.add(chunk);
|
|
17530
|
+
}
|
|
17531
|
+
}
|
|
17532
|
+
}
|
|
17533
|
+
}
|
|
17534
|
+
}
|
|
17535
|
+
return externalSideEffectAtoms;
|
|
17536
|
+
}
|
|
17419
17537
|
/**
|
|
17420
17538
|
* This function tries to get rid of small chunks by merging them with other
|
|
17421
17539
|
* chunks.
|
|
@@ -17492,77 +17610,44 @@ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesBy
|
|
|
17492
17610
|
* following the rule (a), starting with the smallest chunks to look for
|
|
17493
17611
|
* possible merge targets.
|
|
17494
17612
|
*/
|
|
17495
|
-
function getOptimizedChunks(
|
|
17613
|
+
function getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log) {
|
|
17496
17614
|
timeStart('optimize chunks', 3);
|
|
17497
|
-
const chunkPartition = getPartitionedChunks(
|
|
17615
|
+
const chunkPartition = getPartitionedChunks(chunks, minChunkSize);
|
|
17498
17616
|
if (!chunkPartition) {
|
|
17499
17617
|
timeEnd('optimize chunks', 3);
|
|
17500
|
-
return
|
|
17618
|
+
return chunks; // the actual modules
|
|
17501
17619
|
}
|
|
17502
17620
|
minChunkSize > 1 &&
|
|
17503
|
-
log('info', parseAst_js.logOptimizeChunkStatus(
|
|
17504
|
-
mergeChunks(chunkPartition, minChunkSize);
|
|
17621
|
+
log('info', parseAst_js.logOptimizeChunkStatus(chunks.length, chunkPartition.small.size, 'Initially'));
|
|
17622
|
+
mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom);
|
|
17505
17623
|
minChunkSize > 1 &&
|
|
17506
17624
|
log('info', parseAst_js.logOptimizeChunkStatus(chunkPartition.small.size + chunkPartition.big.size, chunkPartition.small.size, 'After merging chunks'));
|
|
17507
17625
|
timeEnd('optimize chunks', 3);
|
|
17508
17626
|
return [...chunkPartition.small, ...chunkPartition.big];
|
|
17509
17627
|
}
|
|
17510
|
-
function getPartitionedChunks(
|
|
17628
|
+
function getPartitionedChunks(chunks, minChunkSize) {
|
|
17511
17629
|
const smallChunks = [];
|
|
17512
17630
|
const bigChunks = [];
|
|
17513
|
-
const
|
|
17514
|
-
|
|
17515
|
-
let sideEffectAtoms = 0n;
|
|
17516
|
-
let containedAtoms = 1n;
|
|
17517
|
-
for (const { dependentEntries, modules } of initialChunks) {
|
|
17518
|
-
const chunkDescription = {
|
|
17519
|
-
containedAtoms,
|
|
17520
|
-
correlatedAtoms: 0n,
|
|
17521
|
-
dependencies: new Set(),
|
|
17522
|
-
dependentChunks: new Set(),
|
|
17523
|
-
dependentEntries,
|
|
17524
|
-
modules,
|
|
17525
|
-
pure: true,
|
|
17526
|
-
size: 0
|
|
17527
|
-
};
|
|
17528
|
-
let size = 0;
|
|
17529
|
-
let pure = true;
|
|
17530
|
-
for (const module of modules) {
|
|
17531
|
-
chunkByModule.set(module, chunkDescription);
|
|
17532
|
-
// Unfortunately, we cannot take tree-shaking into account here because
|
|
17533
|
-
// rendering did not happen yet, but we can detect empty modules
|
|
17534
|
-
if (module.isIncluded()) {
|
|
17535
|
-
pure &&= !module.hasEffects();
|
|
17536
|
-
// we use a trivial size for the default minChunkSize to improve
|
|
17537
|
-
// performance
|
|
17538
|
-
size += minChunkSize > 1 ? module.estimateSize() : 1;
|
|
17539
|
-
}
|
|
17540
|
-
}
|
|
17541
|
-
chunkDescription.pure = pure;
|
|
17542
|
-
chunkDescription.size = size;
|
|
17543
|
-
sizeByAtom.push(size);
|
|
17544
|
-
if (!pure) {
|
|
17545
|
-
sideEffectAtoms |= containedAtoms;
|
|
17546
|
-
}
|
|
17547
|
-
(size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
|
|
17548
|
-
containedAtoms <<= 1n;
|
|
17631
|
+
for (const chunk of chunks) {
|
|
17632
|
+
(chunk.size < minChunkSize ? smallChunks : bigChunks).push(chunk);
|
|
17549
17633
|
}
|
|
17550
|
-
// If there are no small chunks, we will not optimize
|
|
17551
17634
|
if (smallChunks.length === 0) {
|
|
17552
17635
|
return null;
|
|
17553
17636
|
}
|
|
17554
|
-
|
|
17637
|
+
smallChunks.sort(compareChunkSize);
|
|
17638
|
+
bigChunks.sort(compareChunkSize);
|
|
17555
17639
|
return {
|
|
17556
17640
|
big: new Set(bigChunks),
|
|
17557
|
-
sideEffectAtoms,
|
|
17558
|
-
sizeByAtom,
|
|
17559
17641
|
small: new Set(smallChunks)
|
|
17560
17642
|
};
|
|
17561
17643
|
}
|
|
17562
|
-
function
|
|
17644
|
+
function compareChunkSize({ size: sizeA }, { size: sizeB }) {
|
|
17645
|
+
return sizeA - sizeB;
|
|
17646
|
+
}
|
|
17647
|
+
function mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom) {
|
|
17563
17648
|
const { small } = chunkPartition;
|
|
17564
17649
|
for (const mergedChunk of small) {
|
|
17565
|
-
const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition,
|
|
17650
|
+
const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition, sideEffectAtoms, sizeByAtom,
|
|
17566
17651
|
// In the default case, we do not accept size increases
|
|
17567
17652
|
minChunkSize <= 1 ? 1 : Infinity);
|
|
17568
17653
|
if (bestTargetChunk) {
|
|
@@ -17594,57 +17679,7 @@ function mergeChunks(chunkPartition, minChunkSize) {
|
|
|
17594
17679
|
}
|
|
17595
17680
|
}
|
|
17596
17681
|
}
|
|
17597
|
-
function
|
|
17598
|
-
const signatureByExternalModule = new Map();
|
|
17599
|
-
let sideEffectAtoms = 0n;
|
|
17600
|
-
const atomsByEntry = [];
|
|
17601
|
-
for (let index = 0; index < numberOfEntries; index++) {
|
|
17602
|
-
atomsByEntry.push(0n);
|
|
17603
|
-
}
|
|
17604
|
-
for (const chunks of chunkLists) {
|
|
17605
|
-
chunks.sort(compareChunkSize);
|
|
17606
|
-
for (const chunk of chunks) {
|
|
17607
|
-
const { dependencies, dependentEntries, modules } = chunk;
|
|
17608
|
-
for (const module of modules) {
|
|
17609
|
-
for (const dependency of module.getDependenciesToBeIncluded()) {
|
|
17610
|
-
if (dependency instanceof ExternalModule) {
|
|
17611
|
-
if (dependency.info.moduleSideEffects) {
|
|
17612
|
-
chunk.containedAtoms |= getOrCreate(signatureByExternalModule, dependency, () => {
|
|
17613
|
-
const signature = nextAtomSignature;
|
|
17614
|
-
nextAtomSignature <<= 1n;
|
|
17615
|
-
sideEffectAtoms |= signature;
|
|
17616
|
-
return signature;
|
|
17617
|
-
});
|
|
17618
|
-
}
|
|
17619
|
-
}
|
|
17620
|
-
else {
|
|
17621
|
-
const dependencyChunk = chunkByModule.get(dependency);
|
|
17622
|
-
if (dependencyChunk && dependencyChunk !== chunk) {
|
|
17623
|
-
dependencies.add(dependencyChunk);
|
|
17624
|
-
dependencyChunk.dependentChunks.add(chunk);
|
|
17625
|
-
}
|
|
17626
|
-
}
|
|
17627
|
-
}
|
|
17628
|
-
}
|
|
17629
|
-
const { containedAtoms } = chunk;
|
|
17630
|
-
for (const entryIndex of dependentEntries) {
|
|
17631
|
-
atomsByEntry[entryIndex] |= containedAtoms;
|
|
17632
|
-
}
|
|
17633
|
-
}
|
|
17634
|
-
}
|
|
17635
|
-
for (const chunks of chunkLists) {
|
|
17636
|
-
for (const chunk of chunks) {
|
|
17637
|
-
const { dependentEntries } = chunk;
|
|
17638
|
-
// Correlated atoms are the intersection of all entry atoms
|
|
17639
|
-
chunk.correlatedAtoms = -1n;
|
|
17640
|
-
for (const entryIndex of dependentEntries) {
|
|
17641
|
-
chunk.correlatedAtoms &= atomsByEntry[entryIndex];
|
|
17642
|
-
}
|
|
17643
|
-
}
|
|
17644
|
-
}
|
|
17645
|
-
return sideEffectAtoms;
|
|
17646
|
-
}
|
|
17647
|
-
function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, small }, smallestAdditionalSize) {
|
|
17682
|
+
function findBestMergeTarget(mergedChunk, { big, small }, sideEffectAtoms, sizeByAtom, smallestAdditionalSize) {
|
|
17648
17683
|
let bestTargetChunk = null;
|
|
17649
17684
|
// In the default case, we do not accept size increases
|
|
17650
17685
|
for (const targetChunk of concatLazy([small, big])) {
|
|
@@ -17660,12 +17695,6 @@ function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, sm
|
|
|
17660
17695
|
}
|
|
17661
17696
|
return bestTargetChunk;
|
|
17662
17697
|
}
|
|
17663
|
-
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
17664
|
-
return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
17665
|
-
}
|
|
17666
|
-
function compareChunkSize({ size: sizeA }, { size: sizeB }) {
|
|
17667
|
-
return sizeA - sizeB;
|
|
17668
|
-
}
|
|
17669
17698
|
/**
|
|
17670
17699
|
* Determine the additional unused code size that would be added by merging the
|
|
17671
17700
|
* two chunks. This is not an exact measurement but rather an upper bound. If
|
|
@@ -17723,6 +17752,9 @@ function getAtomsSizeIfBelowLimit(atoms, currentAdditionalSize, sizeByAtom) {
|
|
|
17723
17752
|
}
|
|
17724
17753
|
return size;
|
|
17725
17754
|
}
|
|
17755
|
+
function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
|
|
17756
|
+
return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
|
|
17757
|
+
}
|
|
17726
17758
|
|
|
17727
17759
|
// ported from https://github.com/substack/node-commondir
|
|
17728
17760
|
function commondir(files) {
|
|
@@ -17832,8 +17864,8 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
|
|
|
17832
17864
|
: `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`
|
|
17833
17865
|
];
|
|
17834
17866
|
const isValidPropertyName = reservedNamesAsProps
|
|
17835
|
-
? (name) =>
|
|
17836
|
-
: (name) => !RESERVED_NAMES$1.has(name) &&
|
|
17867
|
+
? (name) => VALID_IDENTIFIER_REGEXP.test(name)
|
|
17868
|
+
: (name) => !RESERVED_NAMES$1.has(name) && VALID_IDENTIFIER_REGEXP.test(name);
|
|
17837
17869
|
return {
|
|
17838
17870
|
_,
|
|
17839
17871
|
cnst,
|
|
@@ -17854,10 +17886,10 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
|
|
|
17854
17886
|
.map(([key, value]) => {
|
|
17855
17887
|
if (key === null)
|
|
17856
17888
|
return `${prefix}${value}`;
|
|
17857
|
-
const
|
|
17858
|
-
return key === value && objectShorthand &&
|
|
17889
|
+
const keyInObject = stringifyObjectKeyIfNeeded(key);
|
|
17890
|
+
return key === value && objectShorthand && key === keyInObject
|
|
17859
17891
|
? prefix + key
|
|
17860
|
-
: `${prefix}${
|
|
17892
|
+
: `${prefix}${keyInObject}:${_}${value}`;
|
|
17861
17893
|
})
|
|
17862
17894
|
.join(`,`)}${fields.length === 0 ? '' : lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}`;
|
|
17863
17895
|
},
|
|
@@ -17867,7 +17899,6 @@ function getGenerateCodeSnippets({ compact, generatedCode: { arrowFunctions, con
|
|
|
17867
17899
|
};
|
|
17868
17900
|
}
|
|
17869
17901
|
const wrapIfNeeded = (code, needsParens) => needsParens ? `(${code})` : code;
|
|
17870
|
-
const validPropertyName = /^(?!\d)[\w$]+$/;
|
|
17871
17902
|
|
|
17872
17903
|
class Source {
|
|
17873
17904
|
constructor(filename, content) {
|
package/dist/shared/watch-cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.9.0
|
|
4
|
+
Wed, 13 Dec 2023 09:23:48 GMT - commit c5337ef28a71c796e768a9f0edb3d7259a93f1aa
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ const rollup = require('./rollup.js');
|
|
|
19
19
|
const parseAst_js = require('./parseAst.js');
|
|
20
20
|
const loadConfigFile_js = require('./loadConfigFile.js');
|
|
21
21
|
const node_child_process = require('node:child_process');
|
|
22
|
-
const
|
|
22
|
+
const rollup_js = require('../rollup.js');
|
|
23
23
|
require('fs');
|
|
24
24
|
require('util');
|
|
25
25
|
require('stream');
|
|
@@ -485,7 +485,7 @@ async function watch(command) {
|
|
|
485
485
|
await start(options, warnings);
|
|
486
486
|
}
|
|
487
487
|
async function start(configs, warnings) {
|
|
488
|
-
watcher =
|
|
488
|
+
watcher = rollup_js.watch(configs);
|
|
489
489
|
watcher.on('event', event => {
|
|
490
490
|
switch (event.code) {
|
|
491
491
|
case 'ERROR': {
|
package/dist/shared/watch.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "Next-generation ES module bundler",
|
|
5
5
|
"main": "dist/rollup.js",
|
|
6
6
|
"module": "dist/es/rollup.js",
|
|
@@ -101,19 +101,19 @@
|
|
|
101
101
|
"homepage": "https://rollupjs.org/",
|
|
102
102
|
"optionalDependencies": {
|
|
103
103
|
"fsevents": "~2.3.2",
|
|
104
|
-
"@rollup/rollup-darwin-arm64": "4.
|
|
105
|
-
"@rollup/rollup-android-arm64": "4.
|
|
106
|
-
"@rollup/rollup-win32-arm64-msvc": "4.
|
|
107
|
-
"@rollup/rollup-linux-arm64-gnu": "4.
|
|
108
|
-
"@rollup/rollup-linux-arm64-musl": "4.
|
|
109
|
-
"@rollup/rollup-android-arm-eabi": "4.
|
|
110
|
-
"@rollup/rollup-linux-arm-gnueabihf": "4.
|
|
111
|
-
"@rollup/rollup-win32-ia32-msvc": "4.
|
|
112
|
-
"@rollup/rollup-linux-riscv64-gnu": "4.
|
|
113
|
-
"@rollup/rollup-darwin-x64": "4.
|
|
114
|
-
"@rollup/rollup-win32-x64-msvc": "4.
|
|
115
|
-
"@rollup/rollup-linux-x64-gnu": "4.
|
|
116
|
-
"@rollup/rollup-linux-x64-musl": "4.
|
|
104
|
+
"@rollup/rollup-darwin-arm64": "4.9.0",
|
|
105
|
+
"@rollup/rollup-android-arm64": "4.9.0",
|
|
106
|
+
"@rollup/rollup-win32-arm64-msvc": "4.9.0",
|
|
107
|
+
"@rollup/rollup-linux-arm64-gnu": "4.9.0",
|
|
108
|
+
"@rollup/rollup-linux-arm64-musl": "4.9.0",
|
|
109
|
+
"@rollup/rollup-android-arm-eabi": "4.9.0",
|
|
110
|
+
"@rollup/rollup-linux-arm-gnueabihf": "4.9.0",
|
|
111
|
+
"@rollup/rollup-win32-ia32-msvc": "4.9.0",
|
|
112
|
+
"@rollup/rollup-linux-riscv64-gnu": "4.9.0",
|
|
113
|
+
"@rollup/rollup-darwin-x64": "4.9.0",
|
|
114
|
+
"@rollup/rollup-win32-x64-msvc": "4.9.0",
|
|
115
|
+
"@rollup/rollup-linux-x64-gnu": "4.9.0",
|
|
116
|
+
"@rollup/rollup-linux-x64-musl": "4.9.0"
|
|
117
117
|
},
|
|
118
118
|
"devDependenciesComments": {
|
|
119
119
|
"@rollup/plugin-typescript": "It appears that 11.1.3 breaks sourcemaps"
|