rollup 3.2.5 → 3.3.0-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/README.md +1 -1
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +128 -29
- 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 +128 -29
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
|
|
|
118
118
|
|
|
119
119
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/rollup#sponsor)]
|
|
120
120
|
|
|
121
|
-
<a href="https://opencollective.com/rollup/sponsor/0/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/1/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/2/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/3/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/3/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/4/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/4/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/5/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/5/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/6/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/7/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/8/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/9/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/9/avatar.svg"></a>
|
|
121
|
+
<a href="https://opencollective.com/rollup/sponsor/0/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/1/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/2/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/3/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/3/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/4/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/4/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/5/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/5/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/6/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/7/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/8/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/9/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/9/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/10/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/10/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/11/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/11/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/12/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/12/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/13/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/13/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/14/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/14/avatar.svg"></a>
|
|
122
122
|
|
|
123
123
|
## License
|
|
124
124
|
|
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
|
-
Tue,
|
|
3
|
+
Rollup.js v3.3.0-0
|
|
4
|
+
Tue, 08 Nov 2022 05:35:30 GMT - commit f696b4c205bee65f18b34761ec9d0be88be90ca1
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { promises } from 'node:fs';
|
|
|
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.3.0-0";
|
|
20
20
|
|
|
21
21
|
var charToInteger = {};
|
|
22
22
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -13876,11 +13876,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
13876
13876
|
}
|
|
13877
13877
|
else if (importedNames.length > 0) {
|
|
13878
13878
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
13879
|
-
.map(specifier =>
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
: `${specifier.imported} as ${specifier.local}`;
|
|
13883
|
-
})
|
|
13879
|
+
.map(specifier => specifier.imported === specifier.local
|
|
13880
|
+
? specifier.imported
|
|
13881
|
+
: `${specifier.imported} as ${specifier.local}`)
|
|
13884
13882
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13885
13883
|
}
|
|
13886
13884
|
}
|
|
@@ -13913,11 +13911,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
13913
13911
|
}
|
|
13914
13912
|
if (namedReexports.length > 0) {
|
|
13915
13913
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
13916
|
-
.map(specifier =>
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
: `${specifier.imported} as ${specifier.reexported}`;
|
|
13920
|
-
})
|
|
13914
|
+
.map(specifier => specifier.imported === specifier.reexported
|
|
13915
|
+
? specifier.imported
|
|
13916
|
+
: `${specifier.imported} as ${specifier.reexported}`)
|
|
13921
13917
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13922
13918
|
}
|
|
13923
13919
|
}
|
|
@@ -15635,14 +15631,23 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
15635
15631
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
15636
15632
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
15637
15633
|
|
|
15638
|
-
|
|
15634
|
+
/**
|
|
15635
|
+
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
15636
|
+
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
15637
|
+
* there is a chance that the iterators will not be fully exhausted.
|
|
15638
|
+
*/
|
|
15639
|
+
function* concatLazy(...iterables) {
|
|
15640
|
+
for (const iterable of iterables) {
|
|
15641
|
+
yield* iterable;
|
|
15642
|
+
}
|
|
15643
|
+
}
|
|
15644
|
+
|
|
15645
|
+
function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
|
|
15639
15646
|
const chunkDefinitions = [];
|
|
15640
15647
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
15641
15648
|
const manualChunkModulesByAlias = Object.create(null);
|
|
15642
15649
|
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
15643
|
-
|
|
15644
|
-
manualChunkModulesByAlias[alias] || []);
|
|
15645
|
-
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
15650
|
+
addStaticDependenciesToManualChunk(entry, (manualChunkModulesByAlias[alias] || (manualChunkModulesByAlias[alias] = [])), modulesInManualChunks);
|
|
15646
15651
|
}
|
|
15647
15652
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
15648
15653
|
chunkDefinitions.push({ alias, modules });
|
|
@@ -15693,7 +15698,7 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
|
|
|
15693
15698
|
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
15694
15699
|
}
|
|
15695
15700
|
}
|
|
15696
|
-
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
|
|
15701
|
+
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
|
|
15697
15702
|
return chunkDefinitions;
|
|
15698
15703
|
}
|
|
15699
15704
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -15750,12 +15755,60 @@ function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEnt
|
|
|
15750
15755
|
}
|
|
15751
15756
|
return dynamicallyDependentEntryPointsByDynamicEntry;
|
|
15752
15757
|
}
|
|
15753
|
-
function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
15758
|
+
function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
|
|
15759
|
+
const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
|
|
15760
|
+
return minChunkSize === 0
|
|
15761
|
+
? Object.values(chunkModulesBySignature).map(modules => ({
|
|
15762
|
+
alias: null,
|
|
15763
|
+
modules
|
|
15764
|
+
}))
|
|
15765
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
15766
|
+
}
|
|
15767
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
15768
|
+
timeStart('optimize chunks', 3);
|
|
15769
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
15770
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
15771
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
15772
|
+
let closestChunk = null;
|
|
15773
|
+
let closestChunkDistance = Infinity;
|
|
15774
|
+
const { signature, size, modules } = sourceChunk;
|
|
15775
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
15776
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
15777
|
+
if (distance === 1) {
|
|
15778
|
+
closestChunk = targetChunk;
|
|
15779
|
+
break;
|
|
15780
|
+
}
|
|
15781
|
+
else if (distance < closestChunkDistance) {
|
|
15782
|
+
closestChunk = targetChunk;
|
|
15783
|
+
closestChunkDistance = distance;
|
|
15784
|
+
}
|
|
15785
|
+
}
|
|
15786
|
+
if (closestChunk) {
|
|
15787
|
+
closestChunk.modules.push(...modules);
|
|
15788
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
15789
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
15790
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
15791
|
+
chunksToBeMerged.delete(closestChunk);
|
|
15792
|
+
unmergeableChunks.push(closestChunk);
|
|
15793
|
+
}
|
|
15794
|
+
}
|
|
15795
|
+
}
|
|
15796
|
+
else {
|
|
15797
|
+
unmergeableChunks.push(sourceChunk);
|
|
15798
|
+
}
|
|
15799
|
+
}
|
|
15800
|
+
timeEnd('optimize chunks', 3);
|
|
15801
|
+
return unmergeableChunks;
|
|
15802
|
+
}
|
|
15803
|
+
const CHAR_DEPENDENT = 'X';
|
|
15804
|
+
const CHAR_INDEPENDENT = '_';
|
|
15805
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
15806
|
+
function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints) {
|
|
15754
15807
|
const chunkModules = Object.create(null);
|
|
15755
15808
|
for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) {
|
|
15756
15809
|
let chunkSignature = '';
|
|
15757
15810
|
for (const entry of allEntryPoints) {
|
|
15758
|
-
chunkSignature += assignedEntryPoints.has(entry) ?
|
|
15811
|
+
chunkSignature += assignedEntryPoints.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
15759
15812
|
}
|
|
15760
15813
|
const chunk = chunkModules[chunkSignature];
|
|
15761
15814
|
if (chunk) {
|
|
@@ -15765,10 +15818,56 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
|
15765
15818
|
chunkModules[chunkSignature] = [module];
|
|
15766
15819
|
}
|
|
15767
15820
|
}
|
|
15768
|
-
return
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15821
|
+
return chunkModules;
|
|
15822
|
+
}
|
|
15823
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
15824
|
+
const chunksToBeMerged = new Set();
|
|
15825
|
+
const unmergeableChunks = [];
|
|
15826
|
+
const alias = null;
|
|
15827
|
+
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
15828
|
+
let size = 0;
|
|
15829
|
+
checkModules: {
|
|
15830
|
+
for (const module of modules) {
|
|
15831
|
+
if (module.hasEffects()) {
|
|
15832
|
+
break checkModules;
|
|
15833
|
+
}
|
|
15834
|
+
size += module.magicString.toString().length;
|
|
15835
|
+
if (size > minChunkSize) {
|
|
15836
|
+
break checkModules;
|
|
15837
|
+
}
|
|
15838
|
+
}
|
|
15839
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
15840
|
+
continue;
|
|
15841
|
+
}
|
|
15842
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
15843
|
+
}
|
|
15844
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
15845
|
+
}
|
|
15846
|
+
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
15847
|
+
let distance = 0;
|
|
15848
|
+
const { length } = sourceSignature;
|
|
15849
|
+
for (let index = 0; index < length; index++) {
|
|
15850
|
+
const sourceValue = sourceSignature.charCodeAt(index);
|
|
15851
|
+
if (sourceValue !== targetSignature.charCodeAt(index)) {
|
|
15852
|
+
if (enforceSubset && sourceValue === CHAR_CODE_DEPENDENT) {
|
|
15853
|
+
return Infinity;
|
|
15854
|
+
}
|
|
15855
|
+
distance++;
|
|
15856
|
+
}
|
|
15857
|
+
}
|
|
15858
|
+
return distance;
|
|
15859
|
+
}
|
|
15860
|
+
function mergeSignatures(sourceSignature, targetSignature) {
|
|
15861
|
+
let signature = '';
|
|
15862
|
+
const { length } = sourceSignature;
|
|
15863
|
+
for (let index = 0; index < length; index++) {
|
|
15864
|
+
signature +=
|
|
15865
|
+
sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
|
|
15866
|
+
targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
|
|
15867
|
+
? CHAR_DEPENDENT
|
|
15868
|
+
: CHAR_INDEPENDENT;
|
|
15869
|
+
}
|
|
15870
|
+
return signature;
|
|
15772
15871
|
}
|
|
15773
15872
|
|
|
15774
15873
|
// ported from https://github.com/substack/node-commondir
|
|
@@ -16372,7 +16471,7 @@ class Bundle {
|
|
|
16372
16471
|
this.pluginDriver.finaliseAssets();
|
|
16373
16472
|
}
|
|
16374
16473
|
async generateChunks(bundle, getHashPlaceholder) {
|
|
16375
|
-
const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16474
|
+
const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16376
16475
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
16377
16476
|
? await this.addManualChunks(manualChunks)
|
|
16378
16477
|
: this.assignManualChunks(manualChunks);
|
|
@@ -16386,7 +16485,7 @@ class Bundle {
|
|
|
16386
16485
|
? [{ alias: null, modules: includedModules }]
|
|
16387
16486
|
: preserveModules
|
|
16388
16487
|
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
16389
|
-
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
|
|
16488
|
+
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
|
|
16390
16489
|
sortByExecutionOrder(modules);
|
|
16391
16490
|
const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
|
|
16392
16491
|
chunks.push(chunk);
|
|
@@ -22058,9 +22157,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
22058
22157
|
}
|
|
22059
22158
|
replaceContext = (pluginContext, plugin) => ({
|
|
22060
22159
|
...pluginContext,
|
|
22061
|
-
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
|
|
22062
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
22063
|
-
}
|
|
22160
|
+
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
|
|
22064
22161
|
});
|
|
22065
22162
|
}
|
|
22066
22163
|
return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
@@ -24153,6 +24250,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
24153
24250
|
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
24154
24251
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
24155
24252
|
esModule: config.esModule ?? 'if-default-prop',
|
|
24253
|
+
experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
|
|
24156
24254
|
exports: getExports(config, unsetOptions),
|
|
24157
24255
|
extend: config.extend || false,
|
|
24158
24256
|
externalImportAssertions: config.externalImportAssertions ?? true,
|
|
@@ -24843,6 +24941,7 @@ async function mergeOutputOptions(config, overrides, warn) {
|
|
|
24843
24941
|
dynamicImportInCjs: getOption('dynamicImportInCjs'),
|
|
24844
24942
|
entryFileNames: getOption('entryFileNames'),
|
|
24845
24943
|
esModule: getOption('esModule'),
|
|
24944
|
+
experimentalMinChunkSize: getOption('experimentalMinChunkSize'),
|
|
24846
24945
|
exports: getOption('exports'),
|
|
24847
24946
|
extend: getOption('extend'),
|
|
24848
24947
|
externalImportAssertions: getOption('externalImportAssertions'),
|
package/dist/es/shared/watch.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/rollup.d.ts
CHANGED
|
@@ -639,6 +639,7 @@ export interface OutputOptions {
|
|
|
639
639
|
dynamicImportInCjs?: boolean;
|
|
640
640
|
entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
|
|
641
641
|
esModule?: boolean | 'if-default-prop';
|
|
642
|
+
experimentalMinChunkSize?: number;
|
|
642
643
|
exports?: 'default' | 'named' | 'none' | 'auto';
|
|
643
644
|
extend?: boolean;
|
|
644
645
|
externalImportAssertions?: boolean;
|
|
@@ -691,6 +692,7 @@ export interface NormalizedOutputOptions {
|
|
|
691
692
|
dynamicImportInCjs: boolean;
|
|
692
693
|
entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
|
|
693
694
|
esModule: boolean | 'if-default-prop';
|
|
695
|
+
experimentalMinChunkSize: number;
|
|
694
696
|
exports: 'default' | 'named' | 'none' | 'auto';
|
|
695
697
|
extend: boolean;
|
|
696
698
|
externalImportAssertions: boolean;
|
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
|
-
Tue,
|
|
3
|
+
Rollup.js v3.3.0-0
|
|
4
|
+
Tue, 08 Nov 2022 05:35:30 GMT - commit f696b4c205bee65f18b34761ec9d0be88be90ca1
|
|
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.3.0-0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -1016,6 +1016,7 @@ async function mergeOutputOptions(config, overrides, warn) {
|
|
|
1016
1016
|
dynamicImportInCjs: getOption('dynamicImportInCjs'),
|
|
1017
1017
|
entryFileNames: getOption('entryFileNames'),
|
|
1018
1018
|
esModule: getOption('esModule'),
|
|
1019
|
+
experimentalMinChunkSize: getOption('experimentalMinChunkSize'),
|
|
1019
1020
|
exports: getOption('exports'),
|
|
1020
1021
|
extend: getOption('extend'),
|
|
1021
1022
|
externalImportAssertions: getOption('externalImportAssertions'),
|
|
@@ -14387,11 +14388,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14387
14388
|
}
|
|
14388
14389
|
else if (importedNames.length > 0) {
|
|
14389
14390
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
14390
|
-
.map(specifier =>
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
: `${specifier.imported} as ${specifier.local}`;
|
|
14394
|
-
})
|
|
14391
|
+
.map(specifier => specifier.imported === specifier.local
|
|
14392
|
+
? specifier.imported
|
|
14393
|
+
: `${specifier.imported} as ${specifier.local}`)
|
|
14395
14394
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14396
14395
|
}
|
|
14397
14396
|
}
|
|
@@ -14424,11 +14423,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14424
14423
|
}
|
|
14425
14424
|
if (namedReexports.length > 0) {
|
|
14426
14425
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
14427
|
-
.map(specifier =>
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
: `${specifier.imported} as ${specifier.reexported}`;
|
|
14431
|
-
})
|
|
14426
|
+
.map(specifier => specifier.imported === specifier.reexported
|
|
14427
|
+
? specifier.imported
|
|
14428
|
+
: `${specifier.imported} as ${specifier.reexported}`)
|
|
14432
14429
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14433
14430
|
}
|
|
14434
14431
|
}
|
|
@@ -16146,14 +16143,23 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
16146
16143
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
16147
16144
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
16148
16145
|
|
|
16149
|
-
|
|
16146
|
+
/**
|
|
16147
|
+
* Concatenate a number of iterables to a new iterable without fully evaluating
|
|
16148
|
+
* their iterators. Useful when e.g. working with large sets or lists and when
|
|
16149
|
+
* there is a chance that the iterators will not be fully exhausted.
|
|
16150
|
+
*/
|
|
16151
|
+
function* concatLazy(...iterables) {
|
|
16152
|
+
for (const iterable of iterables) {
|
|
16153
|
+
yield* iterable;
|
|
16154
|
+
}
|
|
16155
|
+
}
|
|
16156
|
+
|
|
16157
|
+
function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
|
|
16150
16158
|
const chunkDefinitions = [];
|
|
16151
16159
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
16152
16160
|
const manualChunkModulesByAlias = Object.create(null);
|
|
16153
16161
|
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
16154
|
-
|
|
16155
|
-
manualChunkModulesByAlias[alias] || []);
|
|
16156
|
-
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
16162
|
+
addStaticDependenciesToManualChunk(entry, (manualChunkModulesByAlias[alias] || (manualChunkModulesByAlias[alias] = [])), modulesInManualChunks);
|
|
16157
16163
|
}
|
|
16158
16164
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
16159
16165
|
chunkDefinitions.push({ alias, modules });
|
|
@@ -16204,7 +16210,7 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
|
|
|
16204
16210
|
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
16205
16211
|
}
|
|
16206
16212
|
}
|
|
16207
|
-
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
|
|
16213
|
+
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
|
|
16208
16214
|
return chunkDefinitions;
|
|
16209
16215
|
}
|
|
16210
16216
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -16261,12 +16267,60 @@ function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEnt
|
|
|
16261
16267
|
}
|
|
16262
16268
|
return dynamicallyDependentEntryPointsByDynamicEntry;
|
|
16263
16269
|
}
|
|
16264
|
-
function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
16270
|
+
function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
|
|
16271
|
+
const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
|
|
16272
|
+
return minChunkSize === 0
|
|
16273
|
+
? Object.values(chunkModulesBySignature).map(modules => ({
|
|
16274
|
+
alias: null,
|
|
16275
|
+
modules
|
|
16276
|
+
}))
|
|
16277
|
+
: getOptimizedChunks(chunkModulesBySignature, minChunkSize);
|
|
16278
|
+
}
|
|
16279
|
+
function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
|
|
16280
|
+
timeStart('optimize chunks', 3);
|
|
16281
|
+
const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
|
|
16282
|
+
for (const sourceChunk of chunksToBeMerged) {
|
|
16283
|
+
chunksToBeMerged.delete(sourceChunk);
|
|
16284
|
+
let closestChunk = null;
|
|
16285
|
+
let closestChunkDistance = Infinity;
|
|
16286
|
+
const { signature, size, modules } = sourceChunk;
|
|
16287
|
+
for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
|
|
16288
|
+
const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
|
|
16289
|
+
if (distance === 1) {
|
|
16290
|
+
closestChunk = targetChunk;
|
|
16291
|
+
break;
|
|
16292
|
+
}
|
|
16293
|
+
else if (distance < closestChunkDistance) {
|
|
16294
|
+
closestChunk = targetChunk;
|
|
16295
|
+
closestChunkDistance = distance;
|
|
16296
|
+
}
|
|
16297
|
+
}
|
|
16298
|
+
if (closestChunk) {
|
|
16299
|
+
closestChunk.modules.push(...modules);
|
|
16300
|
+
if (chunksToBeMerged.has(closestChunk)) {
|
|
16301
|
+
closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
|
|
16302
|
+
if ((closestChunk.size += size) > minChunkSize) {
|
|
16303
|
+
chunksToBeMerged.delete(closestChunk);
|
|
16304
|
+
unmergeableChunks.push(closestChunk);
|
|
16305
|
+
}
|
|
16306
|
+
}
|
|
16307
|
+
}
|
|
16308
|
+
else {
|
|
16309
|
+
unmergeableChunks.push(sourceChunk);
|
|
16310
|
+
}
|
|
16311
|
+
}
|
|
16312
|
+
timeEnd('optimize chunks', 3);
|
|
16313
|
+
return unmergeableChunks;
|
|
16314
|
+
}
|
|
16315
|
+
const CHAR_DEPENDENT = 'X';
|
|
16316
|
+
const CHAR_INDEPENDENT = '_';
|
|
16317
|
+
const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
|
|
16318
|
+
function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints) {
|
|
16265
16319
|
const chunkModules = Object.create(null);
|
|
16266
16320
|
for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) {
|
|
16267
16321
|
let chunkSignature = '';
|
|
16268
16322
|
for (const entry of allEntryPoints) {
|
|
16269
|
-
chunkSignature += assignedEntryPoints.has(entry) ?
|
|
16323
|
+
chunkSignature += assignedEntryPoints.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
16270
16324
|
}
|
|
16271
16325
|
const chunk = chunkModules[chunkSignature];
|
|
16272
16326
|
if (chunk) {
|
|
@@ -16276,10 +16330,56 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
|
16276
16330
|
chunkModules[chunkSignature] = [module];
|
|
16277
16331
|
}
|
|
16278
16332
|
}
|
|
16279
|
-
return
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16333
|
+
return chunkModules;
|
|
16334
|
+
}
|
|
16335
|
+
function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
|
|
16336
|
+
const chunksToBeMerged = new Set();
|
|
16337
|
+
const unmergeableChunks = [];
|
|
16338
|
+
const alias = null;
|
|
16339
|
+
for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
|
|
16340
|
+
let size = 0;
|
|
16341
|
+
checkModules: {
|
|
16342
|
+
for (const module of modules) {
|
|
16343
|
+
if (module.hasEffects()) {
|
|
16344
|
+
break checkModules;
|
|
16345
|
+
}
|
|
16346
|
+
size += module.magicString.toString().length;
|
|
16347
|
+
if (size > minChunkSize) {
|
|
16348
|
+
break checkModules;
|
|
16349
|
+
}
|
|
16350
|
+
}
|
|
16351
|
+
chunksToBeMerged.add({ alias, modules, signature, size });
|
|
16352
|
+
continue;
|
|
16353
|
+
}
|
|
16354
|
+
unmergeableChunks.push({ alias, modules, signature, size: null });
|
|
16355
|
+
}
|
|
16356
|
+
return { chunksToBeMerged, unmergeableChunks };
|
|
16357
|
+
}
|
|
16358
|
+
function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
|
|
16359
|
+
let distance = 0;
|
|
16360
|
+
const { length } = sourceSignature;
|
|
16361
|
+
for (let index = 0; index < length; index++) {
|
|
16362
|
+
const sourceValue = sourceSignature.charCodeAt(index);
|
|
16363
|
+
if (sourceValue !== targetSignature.charCodeAt(index)) {
|
|
16364
|
+
if (enforceSubset && sourceValue === CHAR_CODE_DEPENDENT) {
|
|
16365
|
+
return Infinity;
|
|
16366
|
+
}
|
|
16367
|
+
distance++;
|
|
16368
|
+
}
|
|
16369
|
+
}
|
|
16370
|
+
return distance;
|
|
16371
|
+
}
|
|
16372
|
+
function mergeSignatures(sourceSignature, targetSignature) {
|
|
16373
|
+
let signature = '';
|
|
16374
|
+
const { length } = sourceSignature;
|
|
16375
|
+
for (let index = 0; index < length; index++) {
|
|
16376
|
+
signature +=
|
|
16377
|
+
sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
|
|
16378
|
+
targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
|
|
16379
|
+
? CHAR_DEPENDENT
|
|
16380
|
+
: CHAR_INDEPENDENT;
|
|
16381
|
+
}
|
|
16382
|
+
return signature;
|
|
16283
16383
|
}
|
|
16284
16384
|
|
|
16285
16385
|
// ported from https://github.com/substack/node-commondir
|
|
@@ -16883,7 +16983,7 @@ class Bundle {
|
|
|
16883
16983
|
this.pluginDriver.finaliseAssets();
|
|
16884
16984
|
}
|
|
16885
16985
|
async generateChunks(bundle, getHashPlaceholder) {
|
|
16886
|
-
const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16986
|
+
const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16887
16987
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
16888
16988
|
? await this.addManualChunks(manualChunks)
|
|
16889
16989
|
: this.assignManualChunks(manualChunks);
|
|
@@ -16897,7 +16997,7 @@ class Bundle {
|
|
|
16897
16997
|
? [{ alias: null, modules: includedModules }]
|
|
16898
16998
|
: preserveModules
|
|
16899
16999
|
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
16900
|
-
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
|
|
17000
|
+
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
|
|
16901
17001
|
sortByExecutionOrder(modules);
|
|
16902
17002
|
const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
|
|
16903
17003
|
chunks.push(chunk);
|
|
@@ -22569,9 +22669,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
22569
22669
|
}
|
|
22570
22670
|
replaceContext = (pluginContext, plugin) => ({
|
|
22571
22671
|
...pluginContext,
|
|
22572
|
-
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
|
|
22573
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
22574
|
-
}
|
|
22672
|
+
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
|
|
22575
22673
|
});
|
|
22576
22674
|
}
|
|
22577
22675
|
return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
@@ -24570,6 +24668,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
24570
24668
|
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
24571
24669
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
24572
24670
|
esModule: config.esModule ?? 'if-default-prop',
|
|
24671
|
+
experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
|
|
24573
24672
|
exports: getExports(config, unsetOptions),
|
|
24574
24673
|
extend: config.extend || false,
|
|
24575
24674
|
externalImportAssertions: config.externalImportAssertions ?? true,
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED