rollup 3.2.4 → 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 +181 -46
- 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 +181 -46
- 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
|
-
|
|
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+/=';
|
|
@@ -1825,6 +1825,7 @@ class Variable extends ExpressionEntity {
|
|
|
1825
1825
|
super();
|
|
1826
1826
|
this.name = name;
|
|
1827
1827
|
this.alwaysRendered = false;
|
|
1828
|
+
this.forbiddenNames = null;
|
|
1828
1829
|
this.initReached = false;
|
|
1829
1830
|
this.isId = false;
|
|
1830
1831
|
this.isReassigned = false;
|
|
@@ -1837,6 +1838,13 @@ class Variable extends ExpressionEntity {
|
|
|
1837
1838
|
* Necessary to be able to change variable names.
|
|
1838
1839
|
*/
|
|
1839
1840
|
addReference(_identifier) { }
|
|
1841
|
+
/**
|
|
1842
|
+
* Prevent this variable from being renamed to this name to avoid name
|
|
1843
|
+
* collisions
|
|
1844
|
+
*/
|
|
1845
|
+
forbidName(name) {
|
|
1846
|
+
(this.forbiddenNames || (this.forbiddenNames = new Set())).add(name);
|
|
1847
|
+
}
|
|
1840
1848
|
getBaseVariableName() {
|
|
1841
1849
|
return this.renderBaseName || this.renderName || this.name;
|
|
1842
1850
|
}
|
|
@@ -6562,10 +6570,10 @@ function toBase64(value) {
|
|
|
6562
6570
|
return outString;
|
|
6563
6571
|
}
|
|
6564
6572
|
|
|
6565
|
-
function getSafeName(baseName, usedNames) {
|
|
6573
|
+
function getSafeName(baseName, usedNames, forbiddenNames) {
|
|
6566
6574
|
let safeName = baseName;
|
|
6567
6575
|
let count = 1;
|
|
6568
|
-
while (usedNames.has(safeName) || RESERVED_NAMES$1.has(safeName)) {
|
|
6576
|
+
while (usedNames.has(safeName) || RESERVED_NAMES$1.has(safeName) || forbiddenNames?.has(safeName)) {
|
|
6569
6577
|
safeName = `${baseName}$${toBase64(count++)}`;
|
|
6570
6578
|
}
|
|
6571
6579
|
usedNames.add(safeName);
|
|
@@ -6658,7 +6666,7 @@ class ChildScope extends Scope$1 {
|
|
|
6658
6666
|
}
|
|
6659
6667
|
for (const [name, variable] of this.variables) {
|
|
6660
6668
|
if (variable.included || variable.alwaysRendered) {
|
|
6661
|
-
variable.setRenderNames(null, getSafeName(name, usedNames));
|
|
6669
|
+
variable.setRenderNames(null, getSafeName(name, usedNames, variable.forbiddenNames));
|
|
6662
6670
|
}
|
|
6663
6671
|
}
|
|
6664
6672
|
for (const scope of this.children) {
|
|
@@ -9634,6 +9642,18 @@ class ClassDeclaration extends ClassNode {
|
|
|
9634
9642
|
}
|
|
9635
9643
|
super.render(code, options);
|
|
9636
9644
|
}
|
|
9645
|
+
applyDeoptimizations() {
|
|
9646
|
+
super.applyDeoptimizations();
|
|
9647
|
+
const { id, scope } = this;
|
|
9648
|
+
if (id) {
|
|
9649
|
+
const { name, variable } = id;
|
|
9650
|
+
for (const accessedVariable of scope.accessedOutsideVariables.values()) {
|
|
9651
|
+
if (accessedVariable !== variable) {
|
|
9652
|
+
accessedVariable.forbidName(name);
|
|
9653
|
+
}
|
|
9654
|
+
}
|
|
9655
|
+
}
|
|
9656
|
+
}
|
|
9637
9657
|
}
|
|
9638
9658
|
|
|
9639
9659
|
class ClassExpression extends ClassNode {
|
|
@@ -12124,16 +12144,21 @@ class VariableDeclarator extends NodeBase {
|
|
|
12124
12144
|
this.id.deoptimizePath(path);
|
|
12125
12145
|
}
|
|
12126
12146
|
hasEffects(context) {
|
|
12147
|
+
if (!this.deoptimized)
|
|
12148
|
+
this.applyDeoptimizations();
|
|
12127
12149
|
const initEffect = this.init?.hasEffects(context);
|
|
12128
12150
|
this.id.markDeclarationReached();
|
|
12129
12151
|
return initEffect || this.id.hasEffects(context);
|
|
12130
12152
|
}
|
|
12131
12153
|
include(context, includeChildrenRecursively) {
|
|
12154
|
+
const { deoptimized, id, init } = this;
|
|
12155
|
+
if (!deoptimized)
|
|
12156
|
+
this.applyDeoptimizations();
|
|
12132
12157
|
this.included = true;
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
if (includeChildrenRecursively ||
|
|
12136
|
-
|
|
12158
|
+
init?.include(context, includeChildrenRecursively);
|
|
12159
|
+
id.markDeclarationReached();
|
|
12160
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12161
|
+
id.include(context, includeChildrenRecursively);
|
|
12137
12162
|
}
|
|
12138
12163
|
}
|
|
12139
12164
|
render(code, options) {
|
|
@@ -12161,7 +12186,18 @@ class VariableDeclarator extends NodeBase {
|
|
|
12161
12186
|
code.appendLeft(end, `${_}=${_}void 0`);
|
|
12162
12187
|
}
|
|
12163
12188
|
}
|
|
12164
|
-
applyDeoptimizations() {
|
|
12189
|
+
applyDeoptimizations() {
|
|
12190
|
+
this.deoptimized = true;
|
|
12191
|
+
const { id, init } = this;
|
|
12192
|
+
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12193
|
+
const { name, variable } = id;
|
|
12194
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
12195
|
+
if (accessedVariable !== variable) {
|
|
12196
|
+
accessedVariable.forbidName(name);
|
|
12197
|
+
}
|
|
12198
|
+
}
|
|
12199
|
+
}
|
|
12200
|
+
}
|
|
12165
12201
|
}
|
|
12166
12202
|
|
|
12167
12203
|
class WhileStatement extends NodeBase {
|
|
@@ -13840,11 +13876,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
13840
13876
|
}
|
|
13841
13877
|
else if (importedNames.length > 0) {
|
|
13842
13878
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
13843
|
-
.map(specifier =>
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
: `${specifier.imported} as ${specifier.local}`;
|
|
13847
|
-
})
|
|
13879
|
+
.map(specifier => specifier.imported === specifier.local
|
|
13880
|
+
? specifier.imported
|
|
13881
|
+
: `${specifier.imported} as ${specifier.local}`)
|
|
13848
13882
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13849
13883
|
}
|
|
13850
13884
|
}
|
|
@@ -13877,11 +13911,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
13877
13911
|
}
|
|
13878
13912
|
if (namedReexports.length > 0) {
|
|
13879
13913
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
13880
|
-
.map(specifier =>
|
|
13881
|
-
|
|
13882
|
-
|
|
13883
|
-
: `${specifier.imported} as ${specifier.reexported}`;
|
|
13884
|
-
})
|
|
13914
|
+
.map(specifier => specifier.imported === specifier.reexported
|
|
13915
|
+
? specifier.imported
|
|
13916
|
+
: `${specifier.imported} as ${specifier.reexported}`)
|
|
13885
13917
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
13886
13918
|
}
|
|
13887
13919
|
}
|
|
@@ -14296,7 +14328,7 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14296
14328
|
// This is needed for namespace reexports
|
|
14297
14329
|
for (const dependency of dependenciesToBeDeconflicted.dependencies) {
|
|
14298
14330
|
if (preserveModules || dependency instanceof ExternalChunk) {
|
|
14299
|
-
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
|
|
14331
|
+
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames, null);
|
|
14300
14332
|
}
|
|
14301
14333
|
}
|
|
14302
14334
|
for (const variable of imports) {
|
|
@@ -14310,29 +14342,29 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14310
14342
|
else if (module instanceof ExternalModule && name === 'default') {
|
|
14311
14343
|
variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
|
|
14312
14344
|
? module.suggestedVariableName + '__default'
|
|
14313
|
-
: module.suggestedVariableName, usedNames));
|
|
14345
|
+
: module.suggestedVariableName, usedNames, variable.forbiddenNames));
|
|
14314
14346
|
}
|
|
14315
14347
|
else {
|
|
14316
|
-
variable.setRenderNames(null, getSafeName(name, usedNames));
|
|
14348
|
+
variable.setRenderNames(null, getSafeName(name, usedNames, variable.forbiddenNames));
|
|
14317
14349
|
}
|
|
14318
14350
|
}
|
|
14319
14351
|
for (const variable of syntheticExports) {
|
|
14320
|
-
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14352
|
+
variable.setRenderNames(null, getSafeName(variable.name, usedNames, variable.forbiddenNames));
|
|
14321
14353
|
}
|
|
14322
14354
|
}
|
|
14323
14355
|
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
|
|
14324
14356
|
for (const chunk of dependencies) {
|
|
14325
|
-
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
|
|
14357
|
+
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames, null);
|
|
14326
14358
|
}
|
|
14327
14359
|
for (const chunk of deconflictedNamespace) {
|
|
14328
|
-
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
|
|
14360
|
+
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames, null);
|
|
14329
14361
|
}
|
|
14330
14362
|
for (const externalModule of deconflictedDefault) {
|
|
14331
14363
|
externalModule.defaultVariableName =
|
|
14332
14364
|
deconflictedNamespace.has(externalModule) &&
|
|
14333
14365
|
canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)
|
|
14334
14366
|
? externalModule.namespaceVariableName
|
|
14335
|
-
: getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames);
|
|
14367
|
+
: getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames, null);
|
|
14336
14368
|
}
|
|
14337
14369
|
for (const variable of imports) {
|
|
14338
14370
|
const module = variable.module;
|
|
@@ -14382,12 +14414,12 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
|
|
|
14382
14414
|
// this will only happen for exports in some formats
|
|
14383
14415
|
!(variable.renderBaseName ||
|
|
14384
14416
|
(variable instanceof ExportDefaultVariable && variable.getOriginalVariable() !== variable))) {
|
|
14385
|
-
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14417
|
+
variable.setRenderNames(null, getSafeName(variable.name, usedNames, variable.forbiddenNames));
|
|
14386
14418
|
}
|
|
14387
14419
|
}
|
|
14388
14420
|
if (includedNamespaces.has(module)) {
|
|
14389
14421
|
const namespace = module.namespace;
|
|
14390
|
-
namespace.setRenderNames(null, getSafeName(namespace.name, usedNames));
|
|
14422
|
+
namespace.setRenderNames(null, getSafeName(namespace.name, usedNames, namespace.forbiddenNames));
|
|
14391
14423
|
}
|
|
14392
14424
|
}
|
|
14393
14425
|
}
|
|
@@ -15599,14 +15631,23 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
15599
15631
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
15600
15632
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
15601
15633
|
|
|
15602
|
-
|
|
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) {
|
|
15603
15646
|
const chunkDefinitions = [];
|
|
15604
15647
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
15605
15648
|
const manualChunkModulesByAlias = Object.create(null);
|
|
15606
15649
|
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
15607
|
-
|
|
15608
|
-
manualChunkModulesByAlias[alias] || []);
|
|
15609
|
-
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
15650
|
+
addStaticDependenciesToManualChunk(entry, (manualChunkModulesByAlias[alias] || (manualChunkModulesByAlias[alias] = [])), modulesInManualChunks);
|
|
15610
15651
|
}
|
|
15611
15652
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
15612
15653
|
chunkDefinitions.push({ alias, modules });
|
|
@@ -15657,7 +15698,7 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
|
|
|
15657
15698
|
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
15658
15699
|
}
|
|
15659
15700
|
}
|
|
15660
|
-
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
|
|
15701
|
+
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
|
|
15661
15702
|
return chunkDefinitions;
|
|
15662
15703
|
}
|
|
15663
15704
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -15714,12 +15755,60 @@ function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEnt
|
|
|
15714
15755
|
}
|
|
15715
15756
|
return dynamicallyDependentEntryPointsByDynamicEntry;
|
|
15716
15757
|
}
|
|
15717
|
-
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) {
|
|
15718
15807
|
const chunkModules = Object.create(null);
|
|
15719
15808
|
for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) {
|
|
15720
15809
|
let chunkSignature = '';
|
|
15721
15810
|
for (const entry of allEntryPoints) {
|
|
15722
|
-
chunkSignature += assignedEntryPoints.has(entry) ?
|
|
15811
|
+
chunkSignature += assignedEntryPoints.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
15723
15812
|
}
|
|
15724
15813
|
const chunk = chunkModules[chunkSignature];
|
|
15725
15814
|
if (chunk) {
|
|
@@ -15729,10 +15818,56 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
|
15729
15818
|
chunkModules[chunkSignature] = [module];
|
|
15730
15819
|
}
|
|
15731
15820
|
}
|
|
15732
|
-
return
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
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;
|
|
15736
15871
|
}
|
|
15737
15872
|
|
|
15738
15873
|
// ported from https://github.com/substack/node-commondir
|
|
@@ -16336,7 +16471,7 @@ class Bundle {
|
|
|
16336
16471
|
this.pluginDriver.finaliseAssets();
|
|
16337
16472
|
}
|
|
16338
16473
|
async generateChunks(bundle, getHashPlaceholder) {
|
|
16339
|
-
const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16474
|
+
const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16340
16475
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
16341
16476
|
? await this.addManualChunks(manualChunks)
|
|
16342
16477
|
: this.assignManualChunks(manualChunks);
|
|
@@ -16350,7 +16485,7 @@ class Bundle {
|
|
|
16350
16485
|
? [{ alias: null, modules: includedModules }]
|
|
16351
16486
|
: preserveModules
|
|
16352
16487
|
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
16353
|
-
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
|
|
16488
|
+
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
|
|
16354
16489
|
sortByExecutionOrder(modules);
|
|
16355
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);
|
|
16356
16491
|
chunks.push(chunk);
|
|
@@ -22022,9 +22157,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
22022
22157
|
}
|
|
22023
22158
|
replaceContext = (pluginContext, plugin) => ({
|
|
22024
22159
|
...pluginContext,
|
|
22025
|
-
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
|
|
22026
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
22027
|
-
}
|
|
22160
|
+
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
|
|
22028
22161
|
});
|
|
22029
22162
|
}
|
|
22030
22163
|
return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
@@ -24117,6 +24250,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
24117
24250
|
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
24118
24251
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
24119
24252
|
esModule: config.esModule ?? 'if-default-prop',
|
|
24253
|
+
experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
|
|
24120
24254
|
exports: getExports(config, unsetOptions),
|
|
24121
24255
|
extend: config.extend || false,
|
|
24122
24256
|
externalImportAssertions: config.externalImportAssertions ?? true,
|
|
@@ -24807,6 +24941,7 @@ async function mergeOutputOptions(config, overrides, warn) {
|
|
|
24807
24941
|
dynamicImportInCjs: getOption('dynamicImportInCjs'),
|
|
24808
24942
|
entryFileNames: getOption('entryFileNames'),
|
|
24809
24943
|
esModule: getOption('esModule'),
|
|
24944
|
+
experimentalMinChunkSize: getOption('experimentalMinChunkSize'),
|
|
24810
24945
|
exports: getOption('exports'),
|
|
24811
24946
|
extend: getOption('extend'),
|
|
24812
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
|
-
|
|
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'),
|
|
@@ -2964,6 +2965,7 @@ class Variable extends ExpressionEntity {
|
|
|
2964
2965
|
super();
|
|
2965
2966
|
this.name = name;
|
|
2966
2967
|
this.alwaysRendered = false;
|
|
2968
|
+
this.forbiddenNames = null;
|
|
2967
2969
|
this.initReached = false;
|
|
2968
2970
|
this.isId = false;
|
|
2969
2971
|
this.isReassigned = false;
|
|
@@ -2976,6 +2978,13 @@ class Variable extends ExpressionEntity {
|
|
|
2976
2978
|
* Necessary to be able to change variable names.
|
|
2977
2979
|
*/
|
|
2978
2980
|
addReference(_identifier) { }
|
|
2981
|
+
/**
|
|
2982
|
+
* Prevent this variable from being renamed to this name to avoid name
|
|
2983
|
+
* collisions
|
|
2984
|
+
*/
|
|
2985
|
+
forbidName(name) {
|
|
2986
|
+
(this.forbiddenNames || (this.forbiddenNames = new Set())).add(name);
|
|
2987
|
+
}
|
|
2979
2988
|
getBaseVariableName() {
|
|
2980
2989
|
return this.renderBaseName || this.renderName || this.name;
|
|
2981
2990
|
}
|
|
@@ -7073,10 +7082,10 @@ function toBase64(value) {
|
|
|
7073
7082
|
return outString;
|
|
7074
7083
|
}
|
|
7075
7084
|
|
|
7076
|
-
function getSafeName(baseName, usedNames) {
|
|
7085
|
+
function getSafeName(baseName, usedNames, forbiddenNames) {
|
|
7077
7086
|
let safeName = baseName;
|
|
7078
7087
|
let count = 1;
|
|
7079
|
-
while (usedNames.has(safeName) || RESERVED_NAMES$1.has(safeName)) {
|
|
7088
|
+
while (usedNames.has(safeName) || RESERVED_NAMES$1.has(safeName) || forbiddenNames?.has(safeName)) {
|
|
7080
7089
|
safeName = `${baseName}$${toBase64(count++)}`;
|
|
7081
7090
|
}
|
|
7082
7091
|
usedNames.add(safeName);
|
|
@@ -7169,7 +7178,7 @@ class ChildScope extends Scope$1 {
|
|
|
7169
7178
|
}
|
|
7170
7179
|
for (const [name, variable] of this.variables) {
|
|
7171
7180
|
if (variable.included || variable.alwaysRendered) {
|
|
7172
|
-
variable.setRenderNames(null, getSafeName(name, usedNames));
|
|
7181
|
+
variable.setRenderNames(null, getSafeName(name, usedNames, variable.forbiddenNames));
|
|
7173
7182
|
}
|
|
7174
7183
|
}
|
|
7175
7184
|
for (const scope of this.children) {
|
|
@@ -10145,6 +10154,18 @@ class ClassDeclaration extends ClassNode {
|
|
|
10145
10154
|
}
|
|
10146
10155
|
super.render(code, options);
|
|
10147
10156
|
}
|
|
10157
|
+
applyDeoptimizations() {
|
|
10158
|
+
super.applyDeoptimizations();
|
|
10159
|
+
const { id, scope } = this;
|
|
10160
|
+
if (id) {
|
|
10161
|
+
const { name, variable } = id;
|
|
10162
|
+
for (const accessedVariable of scope.accessedOutsideVariables.values()) {
|
|
10163
|
+
if (accessedVariable !== variable) {
|
|
10164
|
+
accessedVariable.forbidName(name);
|
|
10165
|
+
}
|
|
10166
|
+
}
|
|
10167
|
+
}
|
|
10168
|
+
}
|
|
10148
10169
|
}
|
|
10149
10170
|
|
|
10150
10171
|
class ClassExpression extends ClassNode {
|
|
@@ -12635,16 +12656,21 @@ class VariableDeclarator extends NodeBase {
|
|
|
12635
12656
|
this.id.deoptimizePath(path);
|
|
12636
12657
|
}
|
|
12637
12658
|
hasEffects(context) {
|
|
12659
|
+
if (!this.deoptimized)
|
|
12660
|
+
this.applyDeoptimizations();
|
|
12638
12661
|
const initEffect = this.init?.hasEffects(context);
|
|
12639
12662
|
this.id.markDeclarationReached();
|
|
12640
12663
|
return initEffect || this.id.hasEffects(context);
|
|
12641
12664
|
}
|
|
12642
12665
|
include(context, includeChildrenRecursively) {
|
|
12666
|
+
const { deoptimized, id, init } = this;
|
|
12667
|
+
if (!deoptimized)
|
|
12668
|
+
this.applyDeoptimizations();
|
|
12643
12669
|
this.included = true;
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
if (includeChildrenRecursively ||
|
|
12647
|
-
|
|
12670
|
+
init?.include(context, includeChildrenRecursively);
|
|
12671
|
+
id.markDeclarationReached();
|
|
12672
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12673
|
+
id.include(context, includeChildrenRecursively);
|
|
12648
12674
|
}
|
|
12649
12675
|
}
|
|
12650
12676
|
render(code, options) {
|
|
@@ -12672,7 +12698,18 @@ class VariableDeclarator extends NodeBase {
|
|
|
12672
12698
|
code.appendLeft(end, `${_}=${_}void 0`);
|
|
12673
12699
|
}
|
|
12674
12700
|
}
|
|
12675
|
-
applyDeoptimizations() {
|
|
12701
|
+
applyDeoptimizations() {
|
|
12702
|
+
this.deoptimized = true;
|
|
12703
|
+
const { id, init } = this;
|
|
12704
|
+
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12705
|
+
const { name, variable } = id;
|
|
12706
|
+
for (const accessedVariable of init.scope.accessedOutsideVariables.values()) {
|
|
12707
|
+
if (accessedVariable !== variable) {
|
|
12708
|
+
accessedVariable.forbidName(name);
|
|
12709
|
+
}
|
|
12710
|
+
}
|
|
12711
|
+
}
|
|
12712
|
+
}
|
|
12676
12713
|
}
|
|
12677
12714
|
|
|
12678
12715
|
class WhileStatement extends NodeBase {
|
|
@@ -14351,11 +14388,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14351
14388
|
}
|
|
14352
14389
|
else if (importedNames.length > 0) {
|
|
14353
14390
|
importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
|
|
14354
|
-
.map(specifier =>
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
: `${specifier.imported} as ${specifier.local}`;
|
|
14358
|
-
})
|
|
14391
|
+
.map(specifier => specifier.imported === specifier.local
|
|
14392
|
+
? specifier.imported
|
|
14393
|
+
: `${specifier.imported} as ${specifier.local}`)
|
|
14359
14394
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14360
14395
|
}
|
|
14361
14396
|
}
|
|
@@ -14388,11 +14423,9 @@ function getImportBlock(dependencies, { _ }) {
|
|
|
14388
14423
|
}
|
|
14389
14424
|
if (namedReexports.length > 0) {
|
|
14390
14425
|
importBlock.push(`export${_}{${_}${namedReexports
|
|
14391
|
-
.map(specifier =>
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
: `${specifier.imported} as ${specifier.reexported}`;
|
|
14395
|
-
})
|
|
14426
|
+
.map(specifier => specifier.imported === specifier.reexported
|
|
14427
|
+
? specifier.imported
|
|
14428
|
+
: `${specifier.imported} as ${specifier.reexported}`)
|
|
14396
14429
|
.join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
|
|
14397
14430
|
}
|
|
14398
14431
|
}
|
|
@@ -14807,7 +14840,7 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14807
14840
|
// This is needed for namespace reexports
|
|
14808
14841
|
for (const dependency of dependenciesToBeDeconflicted.dependencies) {
|
|
14809
14842
|
if (preserveModules || dependency instanceof ExternalChunk) {
|
|
14810
|
-
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames);
|
|
14843
|
+
dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames, null);
|
|
14811
14844
|
}
|
|
14812
14845
|
}
|
|
14813
14846
|
for (const variable of imports) {
|
|
@@ -14821,29 +14854,29 @@ function deconflictImportsEsmOrSystem(usedNames, imports, dependenciesToBeDeconf
|
|
|
14821
14854
|
else if (module instanceof ExternalModule && name === 'default') {
|
|
14822
14855
|
variable.setRenderNames(null, getSafeName([...module.exportedVariables].some(([exportedVariable, exportedName]) => exportedName === '*' && exportedVariable.included)
|
|
14823
14856
|
? module.suggestedVariableName + '__default'
|
|
14824
|
-
: module.suggestedVariableName, usedNames));
|
|
14857
|
+
: module.suggestedVariableName, usedNames, variable.forbiddenNames));
|
|
14825
14858
|
}
|
|
14826
14859
|
else {
|
|
14827
|
-
variable.setRenderNames(null, getSafeName(name, usedNames));
|
|
14860
|
+
variable.setRenderNames(null, getSafeName(name, usedNames, variable.forbiddenNames));
|
|
14828
14861
|
}
|
|
14829
14862
|
}
|
|
14830
14863
|
for (const variable of syntheticExports) {
|
|
14831
|
-
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14864
|
+
variable.setRenderNames(null, getSafeName(variable.name, usedNames, variable.forbiddenNames));
|
|
14832
14865
|
}
|
|
14833
14866
|
}
|
|
14834
14867
|
function deconflictImportsOther(usedNames, imports, { deconflictedDefault, deconflictedNamespace, dependencies }, interop, preserveModules, externalLiveBindings, chunkByModule, externalChunkByModule) {
|
|
14835
14868
|
for (const chunk of dependencies) {
|
|
14836
|
-
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames);
|
|
14869
|
+
chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames, null);
|
|
14837
14870
|
}
|
|
14838
14871
|
for (const chunk of deconflictedNamespace) {
|
|
14839
|
-
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames);
|
|
14872
|
+
chunk.namespaceVariableName = getSafeName(`${chunk.suggestedVariableName}__namespace`, usedNames, null);
|
|
14840
14873
|
}
|
|
14841
14874
|
for (const externalModule of deconflictedDefault) {
|
|
14842
14875
|
externalModule.defaultVariableName =
|
|
14843
14876
|
deconflictedNamespace.has(externalModule) &&
|
|
14844
14877
|
canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)
|
|
14845
14878
|
? externalModule.namespaceVariableName
|
|
14846
|
-
: getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames);
|
|
14879
|
+
: getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames, null);
|
|
14847
14880
|
}
|
|
14848
14881
|
for (const variable of imports) {
|
|
14849
14882
|
const module = variable.module;
|
|
@@ -14893,12 +14926,12 @@ function deconflictTopLevelVariables(usedNames, modules, includedNamespaces) {
|
|
|
14893
14926
|
// this will only happen for exports in some formats
|
|
14894
14927
|
!(variable.renderBaseName ||
|
|
14895
14928
|
(variable instanceof ExportDefaultVariable && variable.getOriginalVariable() !== variable))) {
|
|
14896
|
-
variable.setRenderNames(null, getSafeName(variable.name, usedNames));
|
|
14929
|
+
variable.setRenderNames(null, getSafeName(variable.name, usedNames, variable.forbiddenNames));
|
|
14897
14930
|
}
|
|
14898
14931
|
}
|
|
14899
14932
|
if (includedNamespaces.has(module)) {
|
|
14900
14933
|
const namespace = module.namespace;
|
|
14901
|
-
namespace.setRenderNames(null, getSafeName(namespace.name, usedNames));
|
|
14934
|
+
namespace.setRenderNames(null, getSafeName(namespace.name, usedNames, namespace.forbiddenNames));
|
|
14902
14935
|
}
|
|
14903
14936
|
}
|
|
14904
14937
|
}
|
|
@@ -16110,14 +16143,23 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
|
|
|
16110
16143
|
const QUERY_HASH_REGEX = /[#?]/;
|
|
16111
16144
|
const resolveFileName = (dependency) => dependency.getFileName();
|
|
16112
16145
|
|
|
16113
|
-
|
|
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) {
|
|
16114
16158
|
const chunkDefinitions = [];
|
|
16115
16159
|
const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
|
|
16116
16160
|
const manualChunkModulesByAlias = Object.create(null);
|
|
16117
16161
|
for (const [entry, alias] of manualChunkAliasByEntry) {
|
|
16118
|
-
|
|
16119
|
-
manualChunkModulesByAlias[alias] || []);
|
|
16120
|
-
addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
|
|
16162
|
+
addStaticDependenciesToManualChunk(entry, (manualChunkModulesByAlias[alias] || (manualChunkModulesByAlias[alias] = [])), modulesInManualChunks);
|
|
16121
16163
|
}
|
|
16122
16164
|
for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
|
|
16123
16165
|
chunkDefinitions.push({ alias, modules });
|
|
@@ -16168,7 +16210,7 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
|
|
|
16168
16210
|
assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
|
|
16169
16211
|
}
|
|
16170
16212
|
}
|
|
16171
|
-
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
|
|
16213
|
+
chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
|
|
16172
16214
|
return chunkDefinitions;
|
|
16173
16215
|
}
|
|
16174
16216
|
function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
|
|
@@ -16225,12 +16267,60 @@ function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEnt
|
|
|
16225
16267
|
}
|
|
16226
16268
|
return dynamicallyDependentEntryPointsByDynamicEntry;
|
|
16227
16269
|
}
|
|
16228
|
-
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) {
|
|
16229
16319
|
const chunkModules = Object.create(null);
|
|
16230
16320
|
for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) {
|
|
16231
16321
|
let chunkSignature = '';
|
|
16232
16322
|
for (const entry of allEntryPoints) {
|
|
16233
|
-
chunkSignature += assignedEntryPoints.has(entry) ?
|
|
16323
|
+
chunkSignature += assignedEntryPoints.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
|
|
16234
16324
|
}
|
|
16235
16325
|
const chunk = chunkModules[chunkSignature];
|
|
16236
16326
|
if (chunk) {
|
|
@@ -16240,10 +16330,56 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule) {
|
|
|
16240
16330
|
chunkModules[chunkSignature] = [module];
|
|
16241
16331
|
}
|
|
16242
16332
|
}
|
|
16243
|
-
return
|
|
16244
|
-
|
|
16245
|
-
|
|
16246
|
-
|
|
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;
|
|
16247
16383
|
}
|
|
16248
16384
|
|
|
16249
16385
|
// ported from https://github.com/substack/node-commondir
|
|
@@ -16847,7 +16983,7 @@ class Bundle {
|
|
|
16847
16983
|
this.pluginDriver.finaliseAssets();
|
|
16848
16984
|
}
|
|
16849
16985
|
async generateChunks(bundle, getHashPlaceholder) {
|
|
16850
|
-
const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16986
|
+
const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
|
|
16851
16987
|
const manualChunkAliasByEntry = typeof manualChunks === 'object'
|
|
16852
16988
|
? await this.addManualChunks(manualChunks)
|
|
16853
16989
|
: this.assignManualChunks(manualChunks);
|
|
@@ -16861,7 +16997,7 @@ class Bundle {
|
|
|
16861
16997
|
? [{ alias: null, modules: includedModules }]
|
|
16862
16998
|
: preserveModules
|
|
16863
16999
|
? includedModules.map(module => ({ alias: null, modules: [module] }))
|
|
16864
|
-
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
|
|
17000
|
+
: getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
|
|
16865
17001
|
sortByExecutionOrder(modules);
|
|
16866
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);
|
|
16867
17003
|
chunks.push(chunk);
|
|
@@ -22533,9 +22669,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
|
|
|
22533
22669
|
}
|
|
22534
22670
|
replaceContext = (pluginContext, plugin) => ({
|
|
22535
22671
|
...pluginContext,
|
|
22536
|
-
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
|
|
22537
|
-
return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
|
|
22538
|
-
}
|
|
22672
|
+
resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
|
|
22539
22673
|
});
|
|
22540
22674
|
}
|
|
22541
22675
|
return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
|
|
@@ -24534,6 +24668,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
24534
24668
|
dynamicImportInCjs: config.dynamicImportInCjs ?? true,
|
|
24535
24669
|
entryFileNames: getEntryFileNames(config, unsetOptions),
|
|
24536
24670
|
esModule: config.esModule ?? 'if-default-prop',
|
|
24671
|
+
experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
|
|
24537
24672
|
exports: getExports(config, unsetOptions),
|
|
24538
24673
|
extend: config.extend || false,
|
|
24539
24674
|
externalImportAssertions: config.externalImportAssertions ?? true,
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED