@rollup/wasm-node 4.15.0 → 4.16.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 +3 -4
- 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 +235 -27
- package/dist/es/shared/parseAst.js +9 -7
- 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 +2 -2
- 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 +10 -6
- package/dist/shared/rollup.js +234 -26
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +1 -1
package/dist/bin/rollup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*
|
|
3
3
|
@license
|
|
4
|
-
Rollup.js v4.
|
|
5
|
-
|
|
4
|
+
Rollup.js v4.16.0
|
|
5
|
+
Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
8
8
|
|
|
@@ -1246,7 +1246,6 @@ yargsParser.detailed = function (args, opts) {
|
|
|
1246
1246
|
yargsParser.camelCase = camelCase;
|
|
1247
1247
|
yargsParser.decamelize = decamelize;
|
|
1248
1248
|
yargsParser.looksLikeNumber = looksLikeNumber;
|
|
1249
|
-
const argParser = yargsParser;
|
|
1250
1249
|
|
|
1251
1250
|
const toZeroIfInfinity = value => Number.isFinite(value) ? value : 0;
|
|
1252
1251
|
|
|
@@ -1731,7 +1730,7 @@ async function getConfigs(command) {
|
|
|
1731
1730
|
return await loadConfigFromCommand(command, false);
|
|
1732
1731
|
}
|
|
1733
1732
|
|
|
1734
|
-
const command =
|
|
1733
|
+
const command = yargsParser(process$1.argv.slice(2), {
|
|
1735
1734
|
alias: rollup.commandAliases,
|
|
1736
1735
|
configuration: { 'camel-case-expansion': false }
|
|
1737
1736
|
});
|
package/dist/es/getLogFilter.js
CHANGED
package/dist/es/parseAst.js
CHANGED
package/dist/es/rollup.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.16.0
|
|
4
|
+
Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import { normalize, getImportPath, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, Program as Program$1, logRedeclarationError, CatchClause as CatchClause$1, logDuplicateArgumentNameError,
|
|
10
|
+
import { normalize, getImportPath, ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, Program as Program$1, logRedeclarationError, CatchClause as CatchClause$1, logDuplicateArgumentNameError, BLANK, logIllegalImportReassignment, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, Property as Property$1, logConstVariableReassignError, ExpressionStatement as ExpressionStatement$1, ArrowFunctionExpression as ArrowFunctionExpression$1, logMissingExport, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logParseError, logModuleParseError, error, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getReadStringFunction, convertString, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, EMPTY_OBJECT, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logInvalidFormatForTopLevelAwait, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logCircularReexport, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logMissingNodeBuiltins, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logUnknownOption, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_TREESHAKE_MODULESIDEEFFECTS, URL_TREESHAKE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_AMD_BASEPATH, logInvalidExportOptionValue, warnDeprecation, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
|
|
12
12
|
import require$$0$1, { win32, posix, isAbsolute, resolve } from 'path';
|
|
13
13
|
import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
|
|
@@ -16,7 +16,7 @@ import { performance } from 'node:perf_hooks';
|
|
|
16
16
|
import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version = "4.
|
|
19
|
+
var version = "4.16.0";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -1937,6 +1937,9 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
1937
1937
|
};
|
|
1938
1938
|
|
|
1939
1939
|
class Variable extends ExpressionEntity {
|
|
1940
|
+
markReassigned() {
|
|
1941
|
+
this.isReassigned = true;
|
|
1942
|
+
}
|
|
1940
1943
|
constructor(name) {
|
|
1941
1944
|
super();
|
|
1942
1945
|
this.name = name;
|
|
@@ -1944,16 +1947,36 @@ class Variable extends ExpressionEntity {
|
|
|
1944
1947
|
this.forbiddenNames = null;
|
|
1945
1948
|
this.initReached = false;
|
|
1946
1949
|
this.isId = false;
|
|
1947
|
-
this.isReassigned = false;
|
|
1948
1950
|
this.kind = null;
|
|
1949
1951
|
this.renderBaseName = null;
|
|
1950
1952
|
this.renderName = null;
|
|
1953
|
+
this.isReassigned = false;
|
|
1954
|
+
this.onlyFunctionCallUsed = true;
|
|
1951
1955
|
}
|
|
1952
1956
|
/**
|
|
1953
1957
|
* Binds identifiers that reference this variable to this variable.
|
|
1954
1958
|
* Necessary to be able to change variable names.
|
|
1955
1959
|
*/
|
|
1956
1960
|
addReference(_identifier) { }
|
|
1961
|
+
/**
|
|
1962
|
+
* Check if the identifier variable is only used as function call
|
|
1963
|
+
* Forward the check to the export default variable if it is only used once
|
|
1964
|
+
* @returns true if the variable is only used as function call
|
|
1965
|
+
*/
|
|
1966
|
+
getOnlyFunctionCallUsed() {
|
|
1967
|
+
return this.onlyFunctionCallUsed;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Collect the places where the identifier variable is used
|
|
1971
|
+
* @param usedPlace Where the variable is used
|
|
1972
|
+
*/
|
|
1973
|
+
addUsedPlace(usedPlace) {
|
|
1974
|
+
const isFunctionCall = usedPlace.parent.type === CallExpression$1 &&
|
|
1975
|
+
usedPlace.parent.callee === usedPlace;
|
|
1976
|
+
if (!isFunctionCall && usedPlace.parent.type !== ExportDefaultDeclaration$1) {
|
|
1977
|
+
this.onlyFunctionCallUsed = false;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1957
1980
|
/**
|
|
1958
1981
|
* Prevent this variable from being renamed to this name to avoid name
|
|
1959
1982
|
* collisions
|
|
@@ -5691,7 +5714,7 @@ class LocalVariable extends Variable {
|
|
|
5691
5714
|
return;
|
|
5692
5715
|
}
|
|
5693
5716
|
if (path.length === 0) {
|
|
5694
|
-
this.
|
|
5717
|
+
this.markReassigned();
|
|
5695
5718
|
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized;
|
|
5696
5719
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
5697
5720
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -5785,7 +5808,7 @@ class LocalVariable extends Variable {
|
|
|
5785
5808
|
if (this.additionalInitializers === null) {
|
|
5786
5809
|
this.additionalInitializers = [this.init];
|
|
5787
5810
|
this.init = UNKNOWN_EXPRESSION;
|
|
5788
|
-
this.
|
|
5811
|
+
this.markReassigned();
|
|
5789
5812
|
}
|
|
5790
5813
|
return this.additionalInitializers;
|
|
5791
5814
|
}
|
|
@@ -5803,6 +5826,8 @@ class ParameterVariable extends LocalVariable {
|
|
|
5803
5826
|
this.deoptimizations = new PathTracker();
|
|
5804
5827
|
this.deoptimizedFields = new Set();
|
|
5805
5828
|
this.entitiesToBeDeoptimized = new Set();
|
|
5829
|
+
this.knownExpressionsToBeDeoptimized = [];
|
|
5830
|
+
this.knownValue = UNKNOWN_EXPRESSION;
|
|
5806
5831
|
}
|
|
5807
5832
|
addEntityToBeDeoptimized(entity) {
|
|
5808
5833
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
@@ -5832,6 +5857,47 @@ class ParameterVariable extends LocalVariable {
|
|
|
5832
5857
|
}
|
|
5833
5858
|
}
|
|
5834
5859
|
}
|
|
5860
|
+
markReassigned() {
|
|
5861
|
+
if (this.isReassigned) {
|
|
5862
|
+
return;
|
|
5863
|
+
}
|
|
5864
|
+
super.markReassigned();
|
|
5865
|
+
for (const expression of this.knownExpressionsToBeDeoptimized) {
|
|
5866
|
+
expression.deoptimizeCache();
|
|
5867
|
+
}
|
|
5868
|
+
this.knownExpressionsToBeDeoptimized = [];
|
|
5869
|
+
}
|
|
5870
|
+
/**
|
|
5871
|
+
* If we are sure about the value of this parameter, we can set it here.
|
|
5872
|
+
* It can be a literal or the only possible value of the parameter.
|
|
5873
|
+
* an undefined value means that the parameter is not known.
|
|
5874
|
+
* @param value The known value of the parameter to be set.
|
|
5875
|
+
*/
|
|
5876
|
+
setKnownValue(value) {
|
|
5877
|
+
if (this.isReassigned) {
|
|
5878
|
+
return;
|
|
5879
|
+
}
|
|
5880
|
+
if (this.knownValue !== value) {
|
|
5881
|
+
for (const expression of this.knownExpressionsToBeDeoptimized) {
|
|
5882
|
+
expression.deoptimizeCache();
|
|
5883
|
+
}
|
|
5884
|
+
this.knownExpressionsToBeDeoptimized = [];
|
|
5885
|
+
}
|
|
5886
|
+
this.knownValue = value;
|
|
5887
|
+
}
|
|
5888
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5889
|
+
if (this.isReassigned) {
|
|
5890
|
+
return UnknownValue;
|
|
5891
|
+
}
|
|
5892
|
+
this.knownExpressionsToBeDeoptimized.push(origin);
|
|
5893
|
+
return recursionTracker.withTrackedEntityAtPath(path, this.knownValue, () => this.knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
5894
|
+
}
|
|
5895
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5896
|
+
// assigned is a bit different, since the value has a new name (the parameter)
|
|
5897
|
+
return interaction.type === INTERACTION_ASSIGNED
|
|
5898
|
+
? super.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
5899
|
+
: this.knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5900
|
+
}
|
|
5835
5901
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
5836
5902
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
5837
5903
|
if (path.length >= 2 ||
|
|
@@ -5856,7 +5922,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
5856
5922
|
}
|
|
5857
5923
|
}
|
|
5858
5924
|
deoptimizePath(path) {
|
|
5859
|
-
if (
|
|
5925
|
+
if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5926
|
+
return;
|
|
5927
|
+
}
|
|
5928
|
+
if (path.length === 0) {
|
|
5929
|
+
this.markReassigned();
|
|
5860
5930
|
return;
|
|
5861
5931
|
}
|
|
5862
5932
|
const key = path[0];
|
|
@@ -7232,11 +7302,11 @@ function getGlobalAtPath(path) {
|
|
|
7232
7302
|
}
|
|
7233
7303
|
|
|
7234
7304
|
class GlobalVariable extends Variable {
|
|
7235
|
-
constructor() {
|
|
7236
|
-
super(
|
|
7305
|
+
constructor(name) {
|
|
7306
|
+
super(name);
|
|
7237
7307
|
// Ensure we use live-bindings for globals as we do not know if they have
|
|
7238
7308
|
// been reassigned
|
|
7239
|
-
this.
|
|
7309
|
+
this.markReassigned();
|
|
7240
7310
|
}
|
|
7241
7311
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7242
7312
|
switch (interaction.type) {
|
|
@@ -7290,6 +7360,7 @@ class Identifier extends NodeBase {
|
|
|
7290
7360
|
constructor() {
|
|
7291
7361
|
super(...arguments);
|
|
7292
7362
|
this.variable = null;
|
|
7363
|
+
this.isReferenceVariable = false;
|
|
7293
7364
|
}
|
|
7294
7365
|
get isTDZAccess() {
|
|
7295
7366
|
if (!isFlagSet(this.flags, 4 /* Flag.tdzAccessDefined */)) {
|
|
@@ -7310,6 +7381,7 @@ class Identifier extends NodeBase {
|
|
|
7310
7381
|
if (!this.variable && is_reference(this, this.parent)) {
|
|
7311
7382
|
this.variable = this.scope.findVariable(this.name);
|
|
7312
7383
|
this.variable.addReference(this);
|
|
7384
|
+
this.isReferenceVariable = true;
|
|
7313
7385
|
}
|
|
7314
7386
|
}
|
|
7315
7387
|
declare(kind, init) {
|
|
@@ -7472,6 +7544,9 @@ class Identifier extends NodeBase {
|
|
|
7472
7544
|
this.variable.consolidateInitializers();
|
|
7473
7545
|
this.scope.context.requestTreeshakingPass();
|
|
7474
7546
|
}
|
|
7547
|
+
if (this.isReferenceVariable) {
|
|
7548
|
+
this.variable.addUsedPlace(this);
|
|
7549
|
+
}
|
|
7475
7550
|
}
|
|
7476
7551
|
getVariableRespectingTDZ() {
|
|
7477
7552
|
if (this.isPossibleTDZ()) {
|
|
@@ -7791,10 +7866,17 @@ class RestElement extends NodeBase {
|
|
|
7791
7866
|
}
|
|
7792
7867
|
}
|
|
7793
7868
|
|
|
7869
|
+
// This handler does nothing.
|
|
7870
|
+
// Since we always re-evaluate argument values in a new tree-shaking pass,
|
|
7871
|
+
// we don't need to get notified if it is deoptimized.
|
|
7872
|
+
const EMPTY_DEOPTIMIZABLE_HANDLER = { deoptimizeCache() { } };
|
|
7794
7873
|
class FunctionBase extends NodeBase {
|
|
7795
7874
|
constructor() {
|
|
7796
7875
|
super(...arguments);
|
|
7876
|
+
this.knownParameterValues = [];
|
|
7877
|
+
this.allArguments = [];
|
|
7797
7878
|
this.objectEntity = null;
|
|
7879
|
+
this.functionParametersOptimized = false;
|
|
7798
7880
|
}
|
|
7799
7881
|
get async() {
|
|
7800
7882
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -7814,6 +7896,87 @@ class FunctionBase extends NodeBase {
|
|
|
7814
7896
|
set generator(value) {
|
|
7815
7897
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
7816
7898
|
}
|
|
7899
|
+
/**
|
|
7900
|
+
* update knownParameterValues when a call is made to this function
|
|
7901
|
+
* @param newArguments arguments of the call
|
|
7902
|
+
*/
|
|
7903
|
+
updateKnownParameterValues(newArguments) {
|
|
7904
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
7905
|
+
// only the "this" argument newArguments[0] can be null
|
|
7906
|
+
// it's possible that some arguments are empty, so the value is undefined
|
|
7907
|
+
const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
7908
|
+
const parameter = this.params[position];
|
|
7909
|
+
// RestElement can be, and can only be, the last parameter
|
|
7910
|
+
if (parameter instanceof RestElement) {
|
|
7911
|
+
return;
|
|
7912
|
+
}
|
|
7913
|
+
const knownParameterValue = this.knownParameterValues[position];
|
|
7914
|
+
if (knownParameterValue === undefined) {
|
|
7915
|
+
this.knownParameterValues[position] = argument;
|
|
7916
|
+
continue;
|
|
7917
|
+
}
|
|
7918
|
+
if (knownParameterValue === UNKNOWN_EXPRESSION ||
|
|
7919
|
+
knownParameterValue === argument ||
|
|
7920
|
+
(knownParameterValue instanceof Identifier &&
|
|
7921
|
+
argument instanceof Identifier &&
|
|
7922
|
+
knownParameterValue.variable === argument.variable)) {
|
|
7923
|
+
continue;
|
|
7924
|
+
}
|
|
7925
|
+
const oldValue = knownParameterValue.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
|
|
7926
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
|
|
7927
|
+
if (oldValue !== newValue || typeof oldValue === 'symbol') {
|
|
7928
|
+
this.knownParameterValues[position] = UNKNOWN_EXPRESSION;
|
|
7929
|
+
} // else both are the same literal, no need to update
|
|
7930
|
+
}
|
|
7931
|
+
}
|
|
7932
|
+
forwardArgumentsForFunctionCalledOnce(newArguments) {
|
|
7933
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
7934
|
+
const parameter = this.params[position];
|
|
7935
|
+
if (parameter instanceof Identifier) {
|
|
7936
|
+
const ParameterVariable = parameter.variable;
|
|
7937
|
+
const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
7938
|
+
ParameterVariable?.setKnownValue(argument);
|
|
7939
|
+
}
|
|
7940
|
+
}
|
|
7941
|
+
}
|
|
7942
|
+
/**
|
|
7943
|
+
* each time tree-shake starts, this method should be called to reoptimize the parameters
|
|
7944
|
+
* a parameter's state will change at most twice:
|
|
7945
|
+
* `undefined` (no call is made) -> an expression -> `UnknownArgument`
|
|
7946
|
+
* we are sure it will converge, and can use state from last iteration
|
|
7947
|
+
*/
|
|
7948
|
+
applyFunctionParameterOptimization() {
|
|
7949
|
+
if (this.allArguments.length === 0) {
|
|
7950
|
+
return;
|
|
7951
|
+
}
|
|
7952
|
+
if (this.allArguments.length === 1) {
|
|
7953
|
+
// we are sure what knownParameterValues will be, so skip it and do setKnownValue
|
|
7954
|
+
this.forwardArgumentsForFunctionCalledOnce(this.allArguments[0]);
|
|
7955
|
+
return;
|
|
7956
|
+
}
|
|
7957
|
+
// reoptimize all arguments, that's why we save them
|
|
7958
|
+
for (const argumentsList of this.allArguments) {
|
|
7959
|
+
this.updateKnownParameterValues(argumentsList);
|
|
7960
|
+
}
|
|
7961
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
7962
|
+
const parameter = this.params[position];
|
|
7963
|
+
// Parameters without default values
|
|
7964
|
+
if (parameter instanceof Identifier) {
|
|
7965
|
+
const parameterVariable = parameter.variable;
|
|
7966
|
+
// Only the RestElement may be undefined
|
|
7967
|
+
const knownParameterValue = this.knownParameterValues[position];
|
|
7968
|
+
parameterVariable?.setKnownValue(knownParameterValue);
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
}
|
|
7972
|
+
deoptimizeFunctionParameters() {
|
|
7973
|
+
for (const parameter of this.params) {
|
|
7974
|
+
if (parameter instanceof Identifier) {
|
|
7975
|
+
const parameterVariable = parameter.variable;
|
|
7976
|
+
parameterVariable?.markReassigned();
|
|
7977
|
+
}
|
|
7978
|
+
}
|
|
7979
|
+
}
|
|
7817
7980
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7818
7981
|
if (interaction.type === INTERACTION_CALLED) {
|
|
7819
7982
|
const { parameters } = this.scope;
|
|
@@ -7838,6 +8001,7 @@ class FunctionBase extends NodeBase {
|
|
|
7838
8001
|
this.addArgumentToBeDeoptimized(argument);
|
|
7839
8002
|
}
|
|
7840
8003
|
}
|
|
8004
|
+
this.allArguments.push(args);
|
|
7841
8005
|
}
|
|
7842
8006
|
else {
|
|
7843
8007
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -7852,6 +8016,7 @@ class FunctionBase extends NodeBase {
|
|
|
7852
8016
|
for (const parameterList of this.scope.parameters) {
|
|
7853
8017
|
for (const parameter of parameterList) {
|
|
7854
8018
|
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
8019
|
+
parameter.markReassigned();
|
|
7855
8020
|
}
|
|
7856
8021
|
}
|
|
7857
8022
|
}
|
|
@@ -7897,7 +8062,30 @@ class FunctionBase extends NodeBase {
|
|
|
7897
8062
|
}
|
|
7898
8063
|
return false;
|
|
7899
8064
|
}
|
|
8065
|
+
/**
|
|
8066
|
+
* If the function (expression or declaration) is only used as function calls
|
|
8067
|
+
*/
|
|
8068
|
+
onlyFunctionCallUsed() {
|
|
8069
|
+
let variable = null;
|
|
8070
|
+
if (this.parent.type === VariableDeclarator$1) {
|
|
8071
|
+
variable = this.parent.id.variable ?? null;
|
|
8072
|
+
}
|
|
8073
|
+
if (this.parent.type === ExportDefaultDeclaration$1) {
|
|
8074
|
+
variable = this.parent.variable;
|
|
8075
|
+
}
|
|
8076
|
+
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
8077
|
+
}
|
|
7900
8078
|
include(context, includeChildrenRecursively) {
|
|
8079
|
+
const isIIFE = this.parent.type === CallExpression$1 &&
|
|
8080
|
+
this.parent.callee === this;
|
|
8081
|
+
const shoulOptimizeFunctionParameters = isIIFE || this.onlyFunctionCallUsed();
|
|
8082
|
+
if (shoulOptimizeFunctionParameters) {
|
|
8083
|
+
this.applyFunctionParameterOptimization();
|
|
8084
|
+
}
|
|
8085
|
+
else if (this.functionParametersOptimized) {
|
|
8086
|
+
this.deoptimizeFunctionParameters();
|
|
8087
|
+
}
|
|
8088
|
+
this.functionParametersOptimized = shoulOptimizeFunctionParameters;
|
|
7901
8089
|
if (!this.deoptimized)
|
|
7902
8090
|
this.applyDeoptimizations();
|
|
7903
8091
|
this.included = true;
|
|
@@ -8647,7 +8835,7 @@ class MemberExpression extends NodeBase {
|
|
|
8647
8835
|
}
|
|
8648
8836
|
deoptimizeCache() {
|
|
8649
8837
|
const { expressionsToBeDeoptimized, object } = this;
|
|
8650
|
-
this.expressionsToBeDeoptimized =
|
|
8838
|
+
this.expressionsToBeDeoptimized = [];
|
|
8651
8839
|
this.propertyKey = UnknownKey;
|
|
8652
8840
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
8653
8841
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -8796,6 +8984,9 @@ class MemberExpression extends NodeBase {
|
|
|
8796
8984
|
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
8797
8985
|
this.scope.context.requestTreeshakingPass();
|
|
8798
8986
|
}
|
|
8987
|
+
if (this.variable) {
|
|
8988
|
+
this.variable.addUsedPlace(this);
|
|
8989
|
+
}
|
|
8799
8990
|
}
|
|
8800
8991
|
applyAssignmentDeoptimization() {
|
|
8801
8992
|
this.assignmentDeoptimized = true;
|
|
@@ -9445,15 +9636,16 @@ class ConditionalExpression extends NodeBase {
|
|
|
9445
9636
|
this.alternate.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9446
9637
|
}
|
|
9447
9638
|
deoptimizeCache() {
|
|
9639
|
+
this.isBranchResolutionAnalysed = false;
|
|
9640
|
+
const { expressionsToBeDeoptimized } = this;
|
|
9641
|
+
this.expressionsToBeDeoptimized = [];
|
|
9642
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
9643
|
+
expression.deoptimizeCache();
|
|
9644
|
+
}
|
|
9448
9645
|
if (this.usedBranch !== null) {
|
|
9449
9646
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
9450
9647
|
this.usedBranch = null;
|
|
9451
9648
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
9452
|
-
const { expressionsToBeDeoptimized } = this;
|
|
9453
|
-
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
9454
|
-
for (const expression of expressionsToBeDeoptimized) {
|
|
9455
|
-
expression.deoptimizeCache();
|
|
9456
|
-
}
|
|
9457
9649
|
}
|
|
9458
9650
|
}
|
|
9459
9651
|
deoptimizePath(path) {
|
|
@@ -9467,10 +9659,10 @@ class ConditionalExpression extends NodeBase {
|
|
|
9467
9659
|
}
|
|
9468
9660
|
}
|
|
9469
9661
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9662
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
9470
9663
|
const usedBranch = this.getUsedBranch();
|
|
9471
9664
|
if (!usedBranch)
|
|
9472
9665
|
return UnknownValue;
|
|
9473
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
9474
9666
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9475
9667
|
}
|
|
9476
9668
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -9669,6 +9861,10 @@ class FunctionDeclaration extends FunctionNode {
|
|
|
9669
9861
|
this.id.variable.isId = true;
|
|
9670
9862
|
}
|
|
9671
9863
|
}
|
|
9864
|
+
onlyFunctionCallUsed() {
|
|
9865
|
+
// call super.onlyFunctionCallUsed for export default anonymous function
|
|
9866
|
+
return this.id?.variable.getOnlyFunctionCallUsed() ?? super.onlyFunctionCallUsed();
|
|
9867
|
+
}
|
|
9672
9868
|
parseNode(esTreeNode) {
|
|
9673
9869
|
if (esTreeNode.id !== null) {
|
|
9674
9870
|
this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
|
|
@@ -9957,7 +10153,7 @@ class IfStatement extends NodeBase {
|
|
|
9957
10153
|
this.testValue = unset;
|
|
9958
10154
|
}
|
|
9959
10155
|
deoptimizeCache() {
|
|
9960
|
-
this.testValue =
|
|
10156
|
+
this.testValue = unset;
|
|
9961
10157
|
}
|
|
9962
10158
|
hasEffects(context) {
|
|
9963
10159
|
if (this.test.hasEffects(context)) {
|
|
@@ -10765,12 +10961,10 @@ class LogicalExpression extends NodeBase {
|
|
|
10765
10961
|
this.right.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10766
10962
|
}
|
|
10767
10963
|
deoptimizeCache() {
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
this.usedBranch = null;
|
|
10771
|
-
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
10964
|
+
this.isBranchResolutionAnalysed = false;
|
|
10965
|
+
if (this.expressionsToBeDeoptimized.length > 0) {
|
|
10772
10966
|
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
10773
|
-
this.expressionsToBeDeoptimized =
|
|
10967
|
+
this.expressionsToBeDeoptimized = [];
|
|
10774
10968
|
for (const expression of expressionsToBeDeoptimized) {
|
|
10775
10969
|
expression.deoptimizeCache();
|
|
10776
10970
|
}
|
|
@@ -10778,6 +10972,11 @@ class LogicalExpression extends NodeBase {
|
|
|
10778
10972
|
// it is rendered
|
|
10779
10973
|
context.requestTreeshakingPass();
|
|
10780
10974
|
}
|
|
10975
|
+
if (this.usedBranch) {
|
|
10976
|
+
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
10977
|
+
this.usedBranch = null;
|
|
10978
|
+
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
10979
|
+
}
|
|
10781
10980
|
}
|
|
10782
10981
|
deoptimizePath(path) {
|
|
10783
10982
|
const usedBranch = this.getUsedBranch();
|
|
@@ -10790,10 +10989,10 @@ class LogicalExpression extends NodeBase {
|
|
|
10790
10989
|
}
|
|
10791
10990
|
}
|
|
10792
10991
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
10992
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
10793
10993
|
const usedBranch = this.getUsedBranch();
|
|
10794
10994
|
if (!usedBranch)
|
|
10795
10995
|
return UnknownValue;
|
|
10796
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
10797
10996
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
10798
10997
|
}
|
|
10799
10998
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -11735,6 +11934,15 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
11735
11934
|
this.name = identifier.name;
|
|
11736
11935
|
}
|
|
11737
11936
|
}
|
|
11937
|
+
addUsedPlace(usedPlace) {
|
|
11938
|
+
const original = this.getOriginalVariable();
|
|
11939
|
+
if (original === this) {
|
|
11940
|
+
super.addUsedPlace(usedPlace);
|
|
11941
|
+
}
|
|
11942
|
+
else {
|
|
11943
|
+
original.addUsedPlace(usedPlace);
|
|
11944
|
+
}
|
|
11945
|
+
}
|
|
11738
11946
|
forbidName(name) {
|
|
11739
11947
|
const original = this.getOriginalVariable();
|
|
11740
11948
|
if (original === this) {
|
|
@@ -12008,7 +12216,7 @@ class UpdateExpression extends NodeBase {
|
|
|
12008
12216
|
this.argument.deoptimizePath(EMPTY_PATH);
|
|
12009
12217
|
if (this.argument instanceof Identifier) {
|
|
12010
12218
|
const variable = this.scope.findVariable(this.argument.name);
|
|
12011
|
-
variable.
|
|
12219
|
+
variable.markReassigned();
|
|
12012
12220
|
}
|
|
12013
12221
|
this.scope.context.requestTreeshakingPass();
|
|
12014
12222
|
}
|
|
@@ -18125,7 +18333,7 @@ function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
|
|
|
18125
18333
|
|
|
18126
18334
|
function flru (max) {
|
|
18127
18335
|
var num, curr, prev;
|
|
18128
|
-
var limit = max
|
|
18336
|
+
var limit = max ;
|
|
18129
18337
|
|
|
18130
18338
|
function keep(key, value) {
|
|
18131
18339
|
if (++num > limit) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.16.0
|
|
4
|
+
Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -14,6 +14,7 @@ const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
|
14
14
|
const BlockStatement = 'BlockStatement';
|
|
15
15
|
const CallExpression = 'CallExpression';
|
|
16
16
|
const CatchClause = 'CatchClause';
|
|
17
|
+
const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
|
|
17
18
|
const ExpressionStatement = 'ExpressionStatement';
|
|
18
19
|
const Identifier = 'Identifier';
|
|
19
20
|
const Literal = 'Literal';
|
|
@@ -23,6 +24,7 @@ const Program = 'Program';
|
|
|
23
24
|
const Property = 'Property';
|
|
24
25
|
const ReturnStatement = 'ReturnStatement';
|
|
25
26
|
const TemplateLiteral = 'TemplateLiteral';
|
|
27
|
+
const VariableDeclarator = 'VariableDeclarator';
|
|
26
28
|
|
|
27
29
|
const BLANK = Object.freeze(Object.create(null));
|
|
28
30
|
const EMPTY_OBJECT = Object.freeze({});
|
|
@@ -548,7 +550,7 @@ function logDeprecation(deprecation, urlSnippet, plugin) {
|
|
|
548
550
|
code: DEPRECATED_FEATURE,
|
|
549
551
|
message: deprecation,
|
|
550
552
|
url: getRollupUrl(urlSnippet),
|
|
551
|
-
...(
|
|
553
|
+
...({})
|
|
552
554
|
};
|
|
553
555
|
}
|
|
554
556
|
function logConstVariableReassignError() {
|
|
@@ -1032,11 +1034,11 @@ function logFailedValidation(message) {
|
|
|
1032
1034
|
};
|
|
1033
1035
|
}
|
|
1034
1036
|
function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
|
|
1035
|
-
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations
|
|
1037
|
+
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations);
|
|
1036
1038
|
}
|
|
1037
1039
|
function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
|
|
1038
|
-
|
|
1039
|
-
const warning = logDeprecation(deprecation, urlSnippet
|
|
1040
|
+
{
|
|
1041
|
+
const warning = logDeprecation(deprecation, urlSnippet);
|
|
1040
1042
|
if (strictDeprecations) {
|
|
1041
1043
|
return error(warning);
|
|
1042
1044
|
}
|
|
@@ -2204,4 +2206,4 @@ const parseAstAsync = async (input, { allowReturnOutsideFunction = false, signal
|
|
|
2204
2206
|
return convertProgram(astBuffer.buffer, getReadStringFunction(astBuffer));
|
|
2205
2207
|
};
|
|
2206
2208
|
|
|
2207
|
-
export { ANNOTATION_KEY, ArrowFunctionExpression, BLANK, BlockStatement, CallExpression, CatchClause, EMPTY_ARRAY, EMPTY_OBJECT, EMPTY_SET, ExpressionStatement, FIXED_STRINGS, INVALID_ANNOTATION_KEY, Identifier, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_INFO, LOGLEVEL_WARN, Literal, Program, Property, ReturnStatement, TemplateLiteral, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_AMD_ID, URL_OUTPUT_DIR, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, URL_OUTPUT_FORMAT, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_SOURCEMAPFILE, URL_PRESERVEENTRYSIGNATURES, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_WATCH, addTrailingSlashIfMissed, augmentCodeLocation, augmentLogMessage, convertAnnotations, convertNode, convertString, error, getAliasName, getImportPath, getReadStringFunction, getRollupError, isAbsolute, isPathFragment, isRelative, isValidUrl, locate, logAddonNotGenerated, logAlreadyClosed, logAmbiguousExternalNamespaces, logAnonymousPluginCache, logAssetNotFinalisedForFileName, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logBadLoader, logCannotAssignModuleToChunk, logCannotCallNamespace, logCannotEmitFromOptionsHook, logChunkInvalid, logChunkNotGeneratedForFileName, logCircularDependency, logCircularReexport, logConflictingSourcemapSources, logConstVariableReassignError, logCyclicCrossChunkReexport, logDuplicateArgumentNameError, logDuplicateExportError, logDuplicatePluginName, logEmptyChunk, logEntryCannotBeExternal, logEval, logExternalModulesCannotBeIncludedInManualChunks, logExternalModulesCannotBeTransformedToModules, logExternalSyntheticExports, logFailedValidation, logFileNameConflict, logFileReferenceIdNotFoundForFilename, logFirstSideEffect, logIllegalIdentifierAsName, logIllegalImportReassignment, logImplicitDependantCannotBeExternal, logImplicitDependantIsNotIncluded, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logIncompatibleExportOptionValue, logInconsistentImportAttributes, logInputHookInOutputPlugin, logInternalIdCannotBeExternal, logInvalidAddonPluginHook, logInvalidAnnotation, logInvalidExportOptionValue, logInvalidFormatForTopLevelAwait, logInvalidFunctionPluginHook, logInvalidLogPosition, logInvalidOption, logInvalidRollupPhaseForChunkEmission, logInvalidSetAssetSourceCall, logInvalidSourcemapForError, logLevelPriority, logMissingEntryExport, logMissingExport, logMissingFileOrDirOption, logMissingGlobalName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logMissingNodeBuiltins, logMixedExport, logModuleLevelDirective, logModuleParseError, logNamespaceConflict, logNoAssetSourceSet, logNoTransformMapOrAstWithoutCode, logOptimizeChunkStatus, logParseError, logPluginError, logRedeclarationError, logShimmedExport, logSourcemapBroken, logSyntheticNamedExportsNeedNamespaceExport, logThisIsUndefined, logUnexpectedNamedImport, logUnexpectedNamespaceReexport, logUnknownOption, logUnresolvedEntry, logUnresolvedImplicitDependant, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logUnusedExternalImports, normalize, parseAst, parseAstAsync, printQuotedStringList, relative, relativeId, warnDeprecation };
|
|
2209
|
+
export { ANNOTATION_KEY, ArrowFunctionExpression, BLANK, BlockStatement, CallExpression, CatchClause, EMPTY_ARRAY, EMPTY_OBJECT, EMPTY_SET, ExportDefaultDeclaration, ExpressionStatement, FIXED_STRINGS, INVALID_ANNOTATION_KEY, Identifier, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_INFO, LOGLEVEL_WARN, Literal, Program, Property, ReturnStatement, TemplateLiteral, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_AMD_ID, URL_OUTPUT_DIR, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, URL_OUTPUT_FORMAT, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_SOURCEMAPFILE, URL_PRESERVEENTRYSIGNATURES, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_WATCH, VariableDeclarator, addTrailingSlashIfMissed, augmentCodeLocation, augmentLogMessage, convertAnnotations, convertNode, convertString, error, getAliasName, getImportPath, getReadStringFunction, getRollupError, isAbsolute, isPathFragment, isRelative, isValidUrl, locate, logAddonNotGenerated, logAlreadyClosed, logAmbiguousExternalNamespaces, logAnonymousPluginCache, logAssetNotFinalisedForFileName, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logBadLoader, logCannotAssignModuleToChunk, logCannotCallNamespace, logCannotEmitFromOptionsHook, logChunkInvalid, logChunkNotGeneratedForFileName, logCircularDependency, logCircularReexport, logConflictingSourcemapSources, logConstVariableReassignError, logCyclicCrossChunkReexport, logDuplicateArgumentNameError, logDuplicateExportError, logDuplicatePluginName, logEmptyChunk, logEntryCannotBeExternal, logEval, logExternalModulesCannotBeIncludedInManualChunks, logExternalModulesCannotBeTransformedToModules, logExternalSyntheticExports, logFailedValidation, logFileNameConflict, logFileReferenceIdNotFoundForFilename, logFirstSideEffect, logIllegalIdentifierAsName, logIllegalImportReassignment, logImplicitDependantCannotBeExternal, logImplicitDependantIsNotIncluded, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logIncompatibleExportOptionValue, logInconsistentImportAttributes, logInputHookInOutputPlugin, logInternalIdCannotBeExternal, logInvalidAddonPluginHook, logInvalidAnnotation, logInvalidExportOptionValue, logInvalidFormatForTopLevelAwait, logInvalidFunctionPluginHook, logInvalidLogPosition, logInvalidOption, logInvalidRollupPhaseForChunkEmission, logInvalidSetAssetSourceCall, logInvalidSourcemapForError, logLevelPriority, logMissingEntryExport, logMissingExport, logMissingFileOrDirOption, logMissingGlobalName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logMissingNodeBuiltins, logMixedExport, logModuleLevelDirective, logModuleParseError, logNamespaceConflict, logNoAssetSourceSet, logNoTransformMapOrAstWithoutCode, logOptimizeChunkStatus, logParseError, logPluginError, logRedeclarationError, logShimmedExport, logSourcemapBroken, logSyntheticNamedExportsNeedNamespaceExport, logThisIsUndefined, logUnexpectedNamedImport, logUnexpectedNamespaceReexport, logUnknownOption, logUnresolvedEntry, logUnresolvedImplicitDependant, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logUnusedExternalImports, normalize, parseAst, parseAstAsync, printQuotedStringList, relative, relativeId, warnDeprecation };
|
package/dist/es/shared/watch.js
CHANGED
package/dist/getLogFilter.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/parseAst.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/parseAst.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.16.0
|
|
4
|
+
Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -438,7 +438,7 @@ function logDeprecation(deprecation, urlSnippet, plugin) {
|
|
|
438
438
|
code: DEPRECATED_FEATURE,
|
|
439
439
|
message: deprecation,
|
|
440
440
|
url: getRollupUrl(urlSnippet),
|
|
441
|
-
...(
|
|
441
|
+
...({})
|
|
442
442
|
};
|
|
443
443
|
}
|
|
444
444
|
function logConstVariableReassignError() {
|
|
@@ -980,11 +980,11 @@ function logFailedValidation(message) {
|
|
|
980
980
|
};
|
|
981
981
|
}
|
|
982
982
|
function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
|
|
983
|
-
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations
|
|
983
|
+
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations);
|
|
984
984
|
}
|
|
985
985
|
function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
|
|
986
|
-
|
|
987
|
-
const warning = logDeprecation(deprecation, urlSnippet
|
|
986
|
+
{
|
|
987
|
+
const warning = logDeprecation(deprecation, urlSnippet);
|
|
988
988
|
if (strictDeprecations) {
|
|
989
989
|
return error(warning);
|
|
990
990
|
}
|
|
@@ -1005,6 +1005,7 @@ const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
|
1005
1005
|
const BlockStatement = 'BlockStatement';
|
|
1006
1006
|
const CallExpression = 'CallExpression';
|
|
1007
1007
|
const CatchClause = 'CatchClause';
|
|
1008
|
+
const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
|
|
1008
1009
|
const ExpressionStatement = 'ExpressionStatement';
|
|
1009
1010
|
const Identifier = 'Identifier';
|
|
1010
1011
|
const Literal = 'Literal';
|
|
@@ -1014,6 +1015,7 @@ const Program = 'Program';
|
|
|
1014
1015
|
const Property = 'Property';
|
|
1015
1016
|
const ReturnStatement = 'ReturnStatement';
|
|
1016
1017
|
const TemplateLiteral = 'TemplateLiteral';
|
|
1018
|
+
const VariableDeclarator = 'VariableDeclarator';
|
|
1017
1019
|
|
|
1018
1020
|
// This file is generated by scripts/generate-string-constants.js.
|
|
1019
1021
|
// Do not edit this file directly.
|
|
@@ -2276,6 +2278,7 @@ exports.CatchClause = CatchClause;
|
|
|
2276
2278
|
exports.EMPTY_ARRAY = EMPTY_ARRAY;
|
|
2277
2279
|
exports.EMPTY_OBJECT = EMPTY_OBJECT;
|
|
2278
2280
|
exports.EMPTY_SET = EMPTY_SET;
|
|
2281
|
+
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
|
|
2279
2282
|
exports.ExpressionStatement = ExpressionStatement;
|
|
2280
2283
|
exports.FIXED_STRINGS = FIXED_STRINGS;
|
|
2281
2284
|
exports.INVALID_ANNOTATION_KEY = INVALID_ANNOTATION_KEY;
|
|
@@ -2311,6 +2314,7 @@ exports.URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = URL_TREATING_MODULE_AS_EXTE
|
|
|
2311
2314
|
exports.URL_TREESHAKE = URL_TREESHAKE;
|
|
2312
2315
|
exports.URL_TREESHAKE_MODULESIDEEFFECTS = URL_TREESHAKE_MODULESIDEEFFECTS;
|
|
2313
2316
|
exports.URL_WATCH = URL_WATCH;
|
|
2317
|
+
exports.VariableDeclarator = VariableDeclarator;
|
|
2314
2318
|
exports.addTrailingSlashIfMissed = addTrailingSlashIfMissed;
|
|
2315
2319
|
exports.augmentCodeLocation = augmentCodeLocation;
|
|
2316
2320
|
exports.augmentLogMessage = augmentLogMessage;
|
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.16.0
|
|
4
|
+
Sun, 21 Apr 2024 04:41:09 GMT - commit 38fe70780cb7e374b47da99e3a3dca6b2a2170d2
|
|
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.16.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -3393,6 +3393,9 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
3393
3393
|
};
|
|
3394
3394
|
|
|
3395
3395
|
class Variable extends ExpressionEntity {
|
|
3396
|
+
markReassigned() {
|
|
3397
|
+
this.isReassigned = true;
|
|
3398
|
+
}
|
|
3396
3399
|
constructor(name) {
|
|
3397
3400
|
super();
|
|
3398
3401
|
this.name = name;
|
|
@@ -3400,16 +3403,36 @@ class Variable extends ExpressionEntity {
|
|
|
3400
3403
|
this.forbiddenNames = null;
|
|
3401
3404
|
this.initReached = false;
|
|
3402
3405
|
this.isId = false;
|
|
3403
|
-
this.isReassigned = false;
|
|
3404
3406
|
this.kind = null;
|
|
3405
3407
|
this.renderBaseName = null;
|
|
3406
3408
|
this.renderName = null;
|
|
3409
|
+
this.isReassigned = false;
|
|
3410
|
+
this.onlyFunctionCallUsed = true;
|
|
3407
3411
|
}
|
|
3408
3412
|
/**
|
|
3409
3413
|
* Binds identifiers that reference this variable to this variable.
|
|
3410
3414
|
* Necessary to be able to change variable names.
|
|
3411
3415
|
*/
|
|
3412
3416
|
addReference(_identifier) { }
|
|
3417
|
+
/**
|
|
3418
|
+
* Check if the identifier variable is only used as function call
|
|
3419
|
+
* Forward the check to the export default variable if it is only used once
|
|
3420
|
+
* @returns true if the variable is only used as function call
|
|
3421
|
+
*/
|
|
3422
|
+
getOnlyFunctionCallUsed() {
|
|
3423
|
+
return this.onlyFunctionCallUsed;
|
|
3424
|
+
}
|
|
3425
|
+
/**
|
|
3426
|
+
* Collect the places where the identifier variable is used
|
|
3427
|
+
* @param usedPlace Where the variable is used
|
|
3428
|
+
*/
|
|
3429
|
+
addUsedPlace(usedPlace) {
|
|
3430
|
+
const isFunctionCall = usedPlace.parent.type === parseAst_js.CallExpression &&
|
|
3431
|
+
usedPlace.parent.callee === usedPlace;
|
|
3432
|
+
if (!isFunctionCall && usedPlace.parent.type !== parseAst_js.ExportDefaultDeclaration) {
|
|
3433
|
+
this.onlyFunctionCallUsed = false;
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3413
3436
|
/**
|
|
3414
3437
|
* Prevent this variable from being renamed to this name to avoid name
|
|
3415
3438
|
* collisions
|
|
@@ -7147,7 +7170,7 @@ class LocalVariable extends Variable {
|
|
|
7147
7170
|
return;
|
|
7148
7171
|
}
|
|
7149
7172
|
if (path.length === 0) {
|
|
7150
|
-
this.
|
|
7173
|
+
this.markReassigned();
|
|
7151
7174
|
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized;
|
|
7152
7175
|
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
7153
7176
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -7241,7 +7264,7 @@ class LocalVariable extends Variable {
|
|
|
7241
7264
|
if (this.additionalInitializers === null) {
|
|
7242
7265
|
this.additionalInitializers = [this.init];
|
|
7243
7266
|
this.init = UNKNOWN_EXPRESSION;
|
|
7244
|
-
this.
|
|
7267
|
+
this.markReassigned();
|
|
7245
7268
|
}
|
|
7246
7269
|
return this.additionalInitializers;
|
|
7247
7270
|
}
|
|
@@ -7259,6 +7282,8 @@ class ParameterVariable extends LocalVariable {
|
|
|
7259
7282
|
this.deoptimizations = new PathTracker();
|
|
7260
7283
|
this.deoptimizedFields = new Set();
|
|
7261
7284
|
this.entitiesToBeDeoptimized = new Set();
|
|
7285
|
+
this.knownExpressionsToBeDeoptimized = [];
|
|
7286
|
+
this.knownValue = UNKNOWN_EXPRESSION;
|
|
7262
7287
|
}
|
|
7263
7288
|
addEntityToBeDeoptimized(entity) {
|
|
7264
7289
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
@@ -7288,6 +7313,47 @@ class ParameterVariable extends LocalVariable {
|
|
|
7288
7313
|
}
|
|
7289
7314
|
}
|
|
7290
7315
|
}
|
|
7316
|
+
markReassigned() {
|
|
7317
|
+
if (this.isReassigned) {
|
|
7318
|
+
return;
|
|
7319
|
+
}
|
|
7320
|
+
super.markReassigned();
|
|
7321
|
+
for (const expression of this.knownExpressionsToBeDeoptimized) {
|
|
7322
|
+
expression.deoptimizeCache();
|
|
7323
|
+
}
|
|
7324
|
+
this.knownExpressionsToBeDeoptimized = [];
|
|
7325
|
+
}
|
|
7326
|
+
/**
|
|
7327
|
+
* If we are sure about the value of this parameter, we can set it here.
|
|
7328
|
+
* It can be a literal or the only possible value of the parameter.
|
|
7329
|
+
* an undefined value means that the parameter is not known.
|
|
7330
|
+
* @param value The known value of the parameter to be set.
|
|
7331
|
+
*/
|
|
7332
|
+
setKnownValue(value) {
|
|
7333
|
+
if (this.isReassigned) {
|
|
7334
|
+
return;
|
|
7335
|
+
}
|
|
7336
|
+
if (this.knownValue !== value) {
|
|
7337
|
+
for (const expression of this.knownExpressionsToBeDeoptimized) {
|
|
7338
|
+
expression.deoptimizeCache();
|
|
7339
|
+
}
|
|
7340
|
+
this.knownExpressionsToBeDeoptimized = [];
|
|
7341
|
+
}
|
|
7342
|
+
this.knownValue = value;
|
|
7343
|
+
}
|
|
7344
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7345
|
+
if (this.isReassigned) {
|
|
7346
|
+
return UnknownValue;
|
|
7347
|
+
}
|
|
7348
|
+
this.knownExpressionsToBeDeoptimized.push(origin);
|
|
7349
|
+
return recursionTracker.withTrackedEntityAtPath(path, this.knownValue, () => this.knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
7350
|
+
}
|
|
7351
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7352
|
+
// assigned is a bit different, since the value has a new name (the parameter)
|
|
7353
|
+
return interaction.type === INTERACTION_ASSIGNED
|
|
7354
|
+
? super.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
7355
|
+
: this.knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7356
|
+
}
|
|
7291
7357
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
7292
7358
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
7293
7359
|
if (path.length >= 2 ||
|
|
@@ -7312,7 +7378,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
7312
7378
|
}
|
|
7313
7379
|
}
|
|
7314
7380
|
deoptimizePath(path) {
|
|
7315
|
-
if (
|
|
7381
|
+
if (this.deoptimizedFields.has(UnknownKey)) {
|
|
7382
|
+
return;
|
|
7383
|
+
}
|
|
7384
|
+
if (path.length === 0) {
|
|
7385
|
+
this.markReassigned();
|
|
7316
7386
|
return;
|
|
7317
7387
|
}
|
|
7318
7388
|
const key = path[0];
|
|
@@ -8674,11 +8744,11 @@ function getGlobalAtPath(path) {
|
|
|
8674
8744
|
}
|
|
8675
8745
|
|
|
8676
8746
|
class GlobalVariable extends Variable {
|
|
8677
|
-
constructor() {
|
|
8678
|
-
super(
|
|
8747
|
+
constructor(name) {
|
|
8748
|
+
super(name);
|
|
8679
8749
|
// Ensure we use live-bindings for globals as we do not know if they have
|
|
8680
8750
|
// been reassigned
|
|
8681
|
-
this.
|
|
8751
|
+
this.markReassigned();
|
|
8682
8752
|
}
|
|
8683
8753
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8684
8754
|
switch (interaction.type) {
|
|
@@ -8732,6 +8802,7 @@ class Identifier extends NodeBase {
|
|
|
8732
8802
|
constructor() {
|
|
8733
8803
|
super(...arguments);
|
|
8734
8804
|
this.variable = null;
|
|
8805
|
+
this.isReferenceVariable = false;
|
|
8735
8806
|
}
|
|
8736
8807
|
get isTDZAccess() {
|
|
8737
8808
|
if (!isFlagSet(this.flags, 4 /* Flag.tdzAccessDefined */)) {
|
|
@@ -8752,6 +8823,7 @@ class Identifier extends NodeBase {
|
|
|
8752
8823
|
if (!this.variable && is_reference(this, this.parent)) {
|
|
8753
8824
|
this.variable = this.scope.findVariable(this.name);
|
|
8754
8825
|
this.variable.addReference(this);
|
|
8826
|
+
this.isReferenceVariable = true;
|
|
8755
8827
|
}
|
|
8756
8828
|
}
|
|
8757
8829
|
declare(kind, init) {
|
|
@@ -8914,6 +8986,9 @@ class Identifier extends NodeBase {
|
|
|
8914
8986
|
this.variable.consolidateInitializers();
|
|
8915
8987
|
this.scope.context.requestTreeshakingPass();
|
|
8916
8988
|
}
|
|
8989
|
+
if (this.isReferenceVariable) {
|
|
8990
|
+
this.variable.addUsedPlace(this);
|
|
8991
|
+
}
|
|
8917
8992
|
}
|
|
8918
8993
|
getVariableRespectingTDZ() {
|
|
8919
8994
|
if (this.isPossibleTDZ()) {
|
|
@@ -9233,10 +9308,17 @@ class RestElement extends NodeBase {
|
|
|
9233
9308
|
}
|
|
9234
9309
|
}
|
|
9235
9310
|
|
|
9311
|
+
// This handler does nothing.
|
|
9312
|
+
// Since we always re-evaluate argument values in a new tree-shaking pass,
|
|
9313
|
+
// we don't need to get notified if it is deoptimized.
|
|
9314
|
+
const EMPTY_DEOPTIMIZABLE_HANDLER = { deoptimizeCache() { } };
|
|
9236
9315
|
class FunctionBase extends NodeBase {
|
|
9237
9316
|
constructor() {
|
|
9238
9317
|
super(...arguments);
|
|
9318
|
+
this.knownParameterValues = [];
|
|
9319
|
+
this.allArguments = [];
|
|
9239
9320
|
this.objectEntity = null;
|
|
9321
|
+
this.functionParametersOptimized = false;
|
|
9240
9322
|
}
|
|
9241
9323
|
get async() {
|
|
9242
9324
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -9256,6 +9338,87 @@ class FunctionBase extends NodeBase {
|
|
|
9256
9338
|
set generator(value) {
|
|
9257
9339
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
9258
9340
|
}
|
|
9341
|
+
/**
|
|
9342
|
+
* update knownParameterValues when a call is made to this function
|
|
9343
|
+
* @param newArguments arguments of the call
|
|
9344
|
+
*/
|
|
9345
|
+
updateKnownParameterValues(newArguments) {
|
|
9346
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
9347
|
+
// only the "this" argument newArguments[0] can be null
|
|
9348
|
+
// it's possible that some arguments are empty, so the value is undefined
|
|
9349
|
+
const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
9350
|
+
const parameter = this.params[position];
|
|
9351
|
+
// RestElement can be, and can only be, the last parameter
|
|
9352
|
+
if (parameter instanceof RestElement) {
|
|
9353
|
+
return;
|
|
9354
|
+
}
|
|
9355
|
+
const knownParameterValue = this.knownParameterValues[position];
|
|
9356
|
+
if (knownParameterValue === undefined) {
|
|
9357
|
+
this.knownParameterValues[position] = argument;
|
|
9358
|
+
continue;
|
|
9359
|
+
}
|
|
9360
|
+
if (knownParameterValue === UNKNOWN_EXPRESSION ||
|
|
9361
|
+
knownParameterValue === argument ||
|
|
9362
|
+
(knownParameterValue instanceof Identifier &&
|
|
9363
|
+
argument instanceof Identifier &&
|
|
9364
|
+
knownParameterValue.variable === argument.variable)) {
|
|
9365
|
+
continue;
|
|
9366
|
+
}
|
|
9367
|
+
const oldValue = knownParameterValue.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
|
|
9368
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, EMPTY_DEOPTIMIZABLE_HANDLER);
|
|
9369
|
+
if (oldValue !== newValue || typeof oldValue === 'symbol') {
|
|
9370
|
+
this.knownParameterValues[position] = UNKNOWN_EXPRESSION;
|
|
9371
|
+
} // else both are the same literal, no need to update
|
|
9372
|
+
}
|
|
9373
|
+
}
|
|
9374
|
+
forwardArgumentsForFunctionCalledOnce(newArguments) {
|
|
9375
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
9376
|
+
const parameter = this.params[position];
|
|
9377
|
+
if (parameter instanceof Identifier) {
|
|
9378
|
+
const ParameterVariable = parameter.variable;
|
|
9379
|
+
const argument = newArguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
9380
|
+
ParameterVariable?.setKnownValue(argument);
|
|
9381
|
+
}
|
|
9382
|
+
}
|
|
9383
|
+
}
|
|
9384
|
+
/**
|
|
9385
|
+
* each time tree-shake starts, this method should be called to reoptimize the parameters
|
|
9386
|
+
* a parameter's state will change at most twice:
|
|
9387
|
+
* `undefined` (no call is made) -> an expression -> `UnknownArgument`
|
|
9388
|
+
* we are sure it will converge, and can use state from last iteration
|
|
9389
|
+
*/
|
|
9390
|
+
applyFunctionParameterOptimization() {
|
|
9391
|
+
if (this.allArguments.length === 0) {
|
|
9392
|
+
return;
|
|
9393
|
+
}
|
|
9394
|
+
if (this.allArguments.length === 1) {
|
|
9395
|
+
// we are sure what knownParameterValues will be, so skip it and do setKnownValue
|
|
9396
|
+
this.forwardArgumentsForFunctionCalledOnce(this.allArguments[0]);
|
|
9397
|
+
return;
|
|
9398
|
+
}
|
|
9399
|
+
// reoptimize all arguments, that's why we save them
|
|
9400
|
+
for (const argumentsList of this.allArguments) {
|
|
9401
|
+
this.updateKnownParameterValues(argumentsList);
|
|
9402
|
+
}
|
|
9403
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
9404
|
+
const parameter = this.params[position];
|
|
9405
|
+
// Parameters without default values
|
|
9406
|
+
if (parameter instanceof Identifier) {
|
|
9407
|
+
const parameterVariable = parameter.variable;
|
|
9408
|
+
// Only the RestElement may be undefined
|
|
9409
|
+
const knownParameterValue = this.knownParameterValues[position];
|
|
9410
|
+
parameterVariable?.setKnownValue(knownParameterValue);
|
|
9411
|
+
}
|
|
9412
|
+
}
|
|
9413
|
+
}
|
|
9414
|
+
deoptimizeFunctionParameters() {
|
|
9415
|
+
for (const parameter of this.params) {
|
|
9416
|
+
if (parameter instanceof Identifier) {
|
|
9417
|
+
const parameterVariable = parameter.variable;
|
|
9418
|
+
parameterVariable?.markReassigned();
|
|
9419
|
+
}
|
|
9420
|
+
}
|
|
9421
|
+
}
|
|
9259
9422
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9260
9423
|
if (interaction.type === INTERACTION_CALLED) {
|
|
9261
9424
|
const { parameters } = this.scope;
|
|
@@ -9280,6 +9443,7 @@ class FunctionBase extends NodeBase {
|
|
|
9280
9443
|
this.addArgumentToBeDeoptimized(argument);
|
|
9281
9444
|
}
|
|
9282
9445
|
}
|
|
9446
|
+
this.allArguments.push(args);
|
|
9283
9447
|
}
|
|
9284
9448
|
else {
|
|
9285
9449
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -9294,6 +9458,7 @@ class FunctionBase extends NodeBase {
|
|
|
9294
9458
|
for (const parameterList of this.scope.parameters) {
|
|
9295
9459
|
for (const parameter of parameterList) {
|
|
9296
9460
|
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
9461
|
+
parameter.markReassigned();
|
|
9297
9462
|
}
|
|
9298
9463
|
}
|
|
9299
9464
|
}
|
|
@@ -9339,7 +9504,30 @@ class FunctionBase extends NodeBase {
|
|
|
9339
9504
|
}
|
|
9340
9505
|
return false;
|
|
9341
9506
|
}
|
|
9507
|
+
/**
|
|
9508
|
+
* If the function (expression or declaration) is only used as function calls
|
|
9509
|
+
*/
|
|
9510
|
+
onlyFunctionCallUsed() {
|
|
9511
|
+
let variable = null;
|
|
9512
|
+
if (this.parent.type === parseAst_js.VariableDeclarator) {
|
|
9513
|
+
variable = this.parent.id.variable ?? null;
|
|
9514
|
+
}
|
|
9515
|
+
if (this.parent.type === parseAst_js.ExportDefaultDeclaration) {
|
|
9516
|
+
variable = this.parent.variable;
|
|
9517
|
+
}
|
|
9518
|
+
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
9519
|
+
}
|
|
9342
9520
|
include(context, includeChildrenRecursively) {
|
|
9521
|
+
const isIIFE = this.parent.type === parseAst_js.CallExpression &&
|
|
9522
|
+
this.parent.callee === this;
|
|
9523
|
+
const shoulOptimizeFunctionParameters = isIIFE || this.onlyFunctionCallUsed();
|
|
9524
|
+
if (shoulOptimizeFunctionParameters) {
|
|
9525
|
+
this.applyFunctionParameterOptimization();
|
|
9526
|
+
}
|
|
9527
|
+
else if (this.functionParametersOptimized) {
|
|
9528
|
+
this.deoptimizeFunctionParameters();
|
|
9529
|
+
}
|
|
9530
|
+
this.functionParametersOptimized = shoulOptimizeFunctionParameters;
|
|
9343
9531
|
if (!this.deoptimized)
|
|
9344
9532
|
this.applyDeoptimizations();
|
|
9345
9533
|
this.included = true;
|
|
@@ -10089,7 +10277,7 @@ class MemberExpression extends NodeBase {
|
|
|
10089
10277
|
}
|
|
10090
10278
|
deoptimizeCache() {
|
|
10091
10279
|
const { expressionsToBeDeoptimized, object } = this;
|
|
10092
|
-
this.expressionsToBeDeoptimized =
|
|
10280
|
+
this.expressionsToBeDeoptimized = [];
|
|
10093
10281
|
this.propertyKey = UnknownKey;
|
|
10094
10282
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
10095
10283
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -10238,6 +10426,9 @@ class MemberExpression extends NodeBase {
|
|
|
10238
10426
|
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
10239
10427
|
this.scope.context.requestTreeshakingPass();
|
|
10240
10428
|
}
|
|
10429
|
+
if (this.variable) {
|
|
10430
|
+
this.variable.addUsedPlace(this);
|
|
10431
|
+
}
|
|
10241
10432
|
}
|
|
10242
10433
|
applyAssignmentDeoptimization() {
|
|
10243
10434
|
this.assignmentDeoptimized = true;
|
|
@@ -10887,15 +11078,16 @@ class ConditionalExpression extends NodeBase {
|
|
|
10887
11078
|
this.alternate.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10888
11079
|
}
|
|
10889
11080
|
deoptimizeCache() {
|
|
11081
|
+
this.isBranchResolutionAnalysed = false;
|
|
11082
|
+
const { expressionsToBeDeoptimized } = this;
|
|
11083
|
+
this.expressionsToBeDeoptimized = [];
|
|
11084
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
11085
|
+
expression.deoptimizeCache();
|
|
11086
|
+
}
|
|
10890
11087
|
if (this.usedBranch !== null) {
|
|
10891
11088
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
10892
11089
|
this.usedBranch = null;
|
|
10893
11090
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
10894
|
-
const { expressionsToBeDeoptimized } = this;
|
|
10895
|
-
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
10896
|
-
for (const expression of expressionsToBeDeoptimized) {
|
|
10897
|
-
expression.deoptimizeCache();
|
|
10898
|
-
}
|
|
10899
11091
|
}
|
|
10900
11092
|
}
|
|
10901
11093
|
deoptimizePath(path) {
|
|
@@ -10909,10 +11101,10 @@ class ConditionalExpression extends NodeBase {
|
|
|
10909
11101
|
}
|
|
10910
11102
|
}
|
|
10911
11103
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11104
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
10912
11105
|
const usedBranch = this.getUsedBranch();
|
|
10913
11106
|
if (!usedBranch)
|
|
10914
11107
|
return UnknownValue;
|
|
10915
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
10916
11108
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
10917
11109
|
}
|
|
10918
11110
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -11111,6 +11303,10 @@ class FunctionDeclaration extends FunctionNode {
|
|
|
11111
11303
|
this.id.variable.isId = true;
|
|
11112
11304
|
}
|
|
11113
11305
|
}
|
|
11306
|
+
onlyFunctionCallUsed() {
|
|
11307
|
+
// call super.onlyFunctionCallUsed for export default anonymous function
|
|
11308
|
+
return this.id?.variable.getOnlyFunctionCallUsed() ?? super.onlyFunctionCallUsed();
|
|
11309
|
+
}
|
|
11114
11310
|
parseNode(esTreeNode) {
|
|
11115
11311
|
if (esTreeNode.id !== null) {
|
|
11116
11312
|
this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
|
|
@@ -11399,7 +11595,7 @@ class IfStatement extends NodeBase {
|
|
|
11399
11595
|
this.testValue = unset;
|
|
11400
11596
|
}
|
|
11401
11597
|
deoptimizeCache() {
|
|
11402
|
-
this.testValue =
|
|
11598
|
+
this.testValue = unset;
|
|
11403
11599
|
}
|
|
11404
11600
|
hasEffects(context) {
|
|
11405
11601
|
if (this.test.hasEffects(context)) {
|
|
@@ -12207,12 +12403,10 @@ class LogicalExpression extends NodeBase {
|
|
|
12207
12403
|
this.right.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
12208
12404
|
}
|
|
12209
12405
|
deoptimizeCache() {
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
this.usedBranch = null;
|
|
12213
|
-
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
12406
|
+
this.isBranchResolutionAnalysed = false;
|
|
12407
|
+
if (this.expressionsToBeDeoptimized.length > 0) {
|
|
12214
12408
|
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
12215
|
-
this.expressionsToBeDeoptimized =
|
|
12409
|
+
this.expressionsToBeDeoptimized = [];
|
|
12216
12410
|
for (const expression of expressionsToBeDeoptimized) {
|
|
12217
12411
|
expression.deoptimizeCache();
|
|
12218
12412
|
}
|
|
@@ -12220,6 +12414,11 @@ class LogicalExpression extends NodeBase {
|
|
|
12220
12414
|
// it is rendered
|
|
12221
12415
|
context.requestTreeshakingPass();
|
|
12222
12416
|
}
|
|
12417
|
+
if (this.usedBranch) {
|
|
12418
|
+
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
12419
|
+
this.usedBranch = null;
|
|
12420
|
+
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
12421
|
+
}
|
|
12223
12422
|
}
|
|
12224
12423
|
deoptimizePath(path) {
|
|
12225
12424
|
const usedBranch = this.getUsedBranch();
|
|
@@ -12232,10 +12431,10 @@ class LogicalExpression extends NodeBase {
|
|
|
12232
12431
|
}
|
|
12233
12432
|
}
|
|
12234
12433
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
12434
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
12235
12435
|
const usedBranch = this.getUsedBranch();
|
|
12236
12436
|
if (!usedBranch)
|
|
12237
12437
|
return UnknownValue;
|
|
12238
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
12239
12438
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
12240
12439
|
}
|
|
12241
12440
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -13177,6 +13376,15 @@ class ExportDefaultVariable extends LocalVariable {
|
|
|
13177
13376
|
this.name = identifier.name;
|
|
13178
13377
|
}
|
|
13179
13378
|
}
|
|
13379
|
+
addUsedPlace(usedPlace) {
|
|
13380
|
+
const original = this.getOriginalVariable();
|
|
13381
|
+
if (original === this) {
|
|
13382
|
+
super.addUsedPlace(usedPlace);
|
|
13383
|
+
}
|
|
13384
|
+
else {
|
|
13385
|
+
original.addUsedPlace(usedPlace);
|
|
13386
|
+
}
|
|
13387
|
+
}
|
|
13180
13388
|
forbidName(name) {
|
|
13181
13389
|
const original = this.getOriginalVariable();
|
|
13182
13390
|
if (original === this) {
|
|
@@ -13450,7 +13658,7 @@ class UpdateExpression extends NodeBase {
|
|
|
13450
13658
|
this.argument.deoptimizePath(EMPTY_PATH);
|
|
13451
13659
|
if (this.argument instanceof Identifier) {
|
|
13452
13660
|
const variable = this.scope.findVariable(this.argument.name);
|
|
13453
|
-
variable.
|
|
13661
|
+
variable.markReassigned();
|
|
13454
13662
|
}
|
|
13455
13663
|
this.scope.context.requestTreeshakingPass();
|
|
13456
13664
|
}
|
|
@@ -19435,7 +19643,7 @@ function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
|
|
|
19435
19643
|
|
|
19436
19644
|
function flru (max) {
|
|
19437
19645
|
var num, curr, prev;
|
|
19438
|
-
var limit = max
|
|
19646
|
+
var limit = max ;
|
|
19439
19647
|
|
|
19440
19648
|
function keep(key, value) {
|
|
19441
19649
|
if (++num > limit) {
|
package/dist/shared/watch-cli.js
CHANGED
package/dist/shared/watch.js
CHANGED