rollup 4.53.5 → 4.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +170 -142
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +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 +2 -2
- package/dist/shared/rollup.js +170 -142
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +32 -32
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.54.0
|
|
5
|
+
Sat, 20 Dec 2025 09:28:12 GMT - commit 88f1430c42fe76db421623106546e50627271952
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
8
8
|
|
package/dist/es/getLogFilter.js
CHANGED
package/dist/es/parseAst.js
CHANGED
package/dist/es/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.54.0
|
|
4
|
+
Sat, 20 Dec 2025 09:28:12 GMT - commit 88f1430c42fe76db421623106546e50627271952
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.
|
|
30
|
+
var version = "4.54.0";
|
|
31
31
|
|
|
32
32
|
// src/vlq.ts
|
|
33
33
|
var comma = ",".charCodeAt(0);
|
|
@@ -2001,11 +2001,22 @@ function getNewArray() {
|
|
|
2001
2001
|
const UnknownKey = Symbol('Unknown Key');
|
|
2002
2002
|
const UnknownNonAccessorKey = Symbol('Unknown Non-Accessor Key');
|
|
2003
2003
|
const UnknownInteger = Symbol('Unknown Integer');
|
|
2004
|
+
const UnknownWellKnown = Symbol('Unknown Well-Known');
|
|
2004
2005
|
const SymbolToStringTag = Symbol('Symbol.toStringTag');
|
|
2005
2006
|
const SymbolDispose = Symbol('Symbol.asyncDispose');
|
|
2006
2007
|
const SymbolAsyncDispose = Symbol('Symbol.dispose');
|
|
2007
|
-
const
|
|
2008
|
+
const SymbolHasInstance = Symbol('Symbol.hasInstance');
|
|
2009
|
+
const WELL_KNOWN_SYMBOLS_LIST = [
|
|
2010
|
+
SymbolToStringTag,
|
|
2011
|
+
SymbolDispose,
|
|
2012
|
+
SymbolAsyncDispose,
|
|
2013
|
+
SymbolHasInstance
|
|
2014
|
+
];
|
|
2008
2015
|
const WELL_KNOWN_SYMBOLS = new Set(WELL_KNOWN_SYMBOLS_LIST);
|
|
2016
|
+
const isAnyWellKnown = (v) => WELL_KNOWN_SYMBOLS.has(v) || v === UnknownWellKnown;
|
|
2017
|
+
const TREE_SHAKEABLE_SYMBOLS_LIST = [SymbolHasInstance, SymbolDispose, SymbolAsyncDispose];
|
|
2018
|
+
const TREE_SHAKEABLE_SYMBOLS = new Set(TREE_SHAKEABLE_SYMBOLS_LIST);
|
|
2019
|
+
const isConcreteKey = (v) => typeof v === 'string' || WELL_KNOWN_SYMBOLS.has(v);
|
|
2009
2020
|
const EMPTY_PATH = [];
|
|
2010
2021
|
const UNKNOWN_PATH = [UnknownKey];
|
|
2011
2022
|
// For deoptimizations, this means we are modifying an unknown property but did
|
|
@@ -2015,6 +2026,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
2015
2026
|
// Object.defineProperty
|
|
2016
2027
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
2017
2028
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
2029
|
+
const INSTANCEOF_PATH = [SymbolHasInstance];
|
|
2018
2030
|
const EntitiesKey = Symbol('Entities');
|
|
2019
2031
|
class EntityPathTracker {
|
|
2020
2032
|
constructor() {
|
|
@@ -2087,7 +2099,7 @@ class IncludedFullPathTracker {
|
|
|
2087
2099
|
}
|
|
2088
2100
|
// Including UnknownKey automatically includes all nested paths.
|
|
2089
2101
|
// From above, we know that UnknownKey is not included yet.
|
|
2090
|
-
if (
|
|
2102
|
+
if (!isConcreteKey(pathSegment)) {
|
|
2091
2103
|
// Hopefully, this saves some memory over just setting
|
|
2092
2104
|
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
2093
2105
|
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
@@ -2118,7 +2130,7 @@ class IncludedTopLevelPathTracker {
|
|
|
2118
2130
|
if (!firstPathSegment) {
|
|
2119
2131
|
return included;
|
|
2120
2132
|
}
|
|
2121
|
-
if (
|
|
2133
|
+
if (!isConcreteKey(firstPathSegment)) {
|
|
2122
2134
|
this.includedPaths = UNKNOWN_INCLUDED_TOP_LEVEL_PATH;
|
|
2123
2135
|
return false;
|
|
2124
2136
|
}
|
|
@@ -3341,12 +3353,13 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3341
3353
|
this.immutable = immutable;
|
|
3342
3354
|
this.additionalExpressionsToBeDeoptimized = new Set();
|
|
3343
3355
|
this.allProperties = [];
|
|
3344
|
-
this.
|
|
3345
|
-
this.
|
|
3346
|
-
this.
|
|
3347
|
-
this.
|
|
3348
|
-
this.
|
|
3349
|
-
this.
|
|
3356
|
+
this.alwaysIncludedProperties = new Set();
|
|
3357
|
+
this.deoptimizedPaths = new Map();
|
|
3358
|
+
this.expressionsToBeDeoptimizedByKey = new Map();
|
|
3359
|
+
this.gettersByKey = new Map();
|
|
3360
|
+
this.propertiesAndGettersByKey = new Map();
|
|
3361
|
+
this.propertiesAndSettersByKey = new Map();
|
|
3362
|
+
this.settersByKey = new Map();
|
|
3350
3363
|
this.unknownIntegerProps = [];
|
|
3351
3364
|
this.unmatchableGetters = [];
|
|
3352
3365
|
this.unmatchablePropertiesAndGetters = [];
|
|
@@ -3357,7 +3370,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3357
3370
|
}
|
|
3358
3371
|
else {
|
|
3359
3372
|
this.propertiesAndGettersByKey = this.propertiesAndSettersByKey = properties;
|
|
3360
|
-
for (const propertiesForKey of
|
|
3373
|
+
for (const propertiesForKey of properties.values()) {
|
|
3361
3374
|
this.allProperties.push(...propertiesForKey);
|
|
3362
3375
|
}
|
|
3363
3376
|
}
|
|
@@ -3374,8 +3387,8 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3374
3387
|
return;
|
|
3375
3388
|
}
|
|
3376
3389
|
for (const properties of [
|
|
3377
|
-
...
|
|
3378
|
-
...
|
|
3390
|
+
...this.propertiesAndGettersByKey.values(),
|
|
3391
|
+
...this.settersByKey.values()
|
|
3379
3392
|
]) {
|
|
3380
3393
|
for (const property of properties) {
|
|
3381
3394
|
property.deoptimizePath(UNKNOWN_PATH);
|
|
@@ -3392,7 +3405,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3392
3405
|
// single paths that are deoptimized will not become getters or setters
|
|
3393
3406
|
((type === INTERACTION_CALLED || path.length > 1) &&
|
|
3394
3407
|
(this.hasUnknownDeoptimizedProperty ||
|
|
3395
|
-
(
|
|
3408
|
+
(isConcreteKey(key) && this.deoptimizedPaths.get(key))))) {
|
|
3396
3409
|
deoptimizeInteraction(interaction);
|
|
3397
3410
|
return;
|
|
3398
3411
|
}
|
|
@@ -3405,9 +3418,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3405
3418
|
: type === INTERACTION_ACCESSED
|
|
3406
3419
|
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
3407
3420
|
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
3408
|
-
if (
|
|
3409
|
-
if (propertiesForExactMatchByKey
|
|
3410
|
-
const properties = relevantPropertiesByKey
|
|
3421
|
+
if (isConcreteKey(key)) {
|
|
3422
|
+
if (propertiesForExactMatchByKey.get(key)) {
|
|
3423
|
+
const properties = relevantPropertiesByKey.get(key);
|
|
3411
3424
|
if (properties) {
|
|
3412
3425
|
for (const property of properties) {
|
|
3413
3426
|
property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
@@ -3425,7 +3438,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3425
3438
|
for (const property of relevantUnmatchableProperties) {
|
|
3426
3439
|
property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
3427
3440
|
}
|
|
3428
|
-
if (INTEGER_REG_EXP.test(key)) {
|
|
3441
|
+
if (typeof key === 'string' && INTEGER_REG_EXP.test(key)) {
|
|
3429
3442
|
for (const property of this.unknownIntegerProps) {
|
|
3430
3443
|
property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
3431
3444
|
}
|
|
@@ -3433,7 +3446,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3433
3446
|
}
|
|
3434
3447
|
else {
|
|
3435
3448
|
for (const properties of [
|
|
3436
|
-
...
|
|
3449
|
+
...relevantPropertiesByKey.values(),
|
|
3437
3450
|
relevantUnmatchableProperties
|
|
3438
3451
|
]) {
|
|
3439
3452
|
for (const property of properties) {
|
|
@@ -3460,8 +3473,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3460
3473
|
return;
|
|
3461
3474
|
}
|
|
3462
3475
|
this.hasUnknownDeoptimizedInteger = true;
|
|
3463
|
-
|
|
3464
|
-
|
|
3476
|
+
// Omits symbol keys but that's unimportant here
|
|
3477
|
+
for (const [key, propertiesAndGetters] of this.propertiesAndGettersByKey.entries()) {
|
|
3478
|
+
if (typeof key === 'string' && INTEGER_REG_EXP.test(key)) {
|
|
3465
3479
|
for (const property of propertiesAndGetters) {
|
|
3466
3480
|
property.deoptimizePath(UNKNOWN_PATH);
|
|
3467
3481
|
}
|
|
@@ -3479,14 +3493,14 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3479
3493
|
if (key === UnknownInteger) {
|
|
3480
3494
|
return this.deoptimizeIntegerProperties();
|
|
3481
3495
|
}
|
|
3482
|
-
else if (
|
|
3496
|
+
else if (!isConcreteKey(key)) {
|
|
3483
3497
|
return this.deoptimizeAllProperties(key === UnknownNonAccessorKey);
|
|
3484
3498
|
}
|
|
3485
|
-
if (!this.deoptimizedPaths
|
|
3486
|
-
this.deoptimizedPaths
|
|
3499
|
+
if (!this.deoptimizedPaths.get(key)) {
|
|
3500
|
+
this.deoptimizedPaths.set(key, true);
|
|
3487
3501
|
// we only deoptimizeCache exact matches as in all other cases,
|
|
3488
3502
|
// we do not return a literal value or return expression
|
|
3489
|
-
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimizedByKey
|
|
3503
|
+
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimizedByKey.get(key);
|
|
3490
3504
|
if (expressionsToBeDeoptimized) {
|
|
3491
3505
|
for (const expression of expressionsToBeDeoptimized) {
|
|
3492
3506
|
expression.deoptimizeCache();
|
|
@@ -3495,10 +3509,10 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3495
3509
|
}
|
|
3496
3510
|
}
|
|
3497
3511
|
const subPath = path.length === 1 ? UNKNOWN_PATH : path.slice(1);
|
|
3498
|
-
for (const property of
|
|
3512
|
+
for (const property of isConcreteKey(key)
|
|
3499
3513
|
? [
|
|
3500
|
-
...(this.propertiesAndGettersByKey
|
|
3501
|
-
...(this.settersByKey
|
|
3514
|
+
...(this.propertiesAndGettersByKey.get(key) || this.unmatchablePropertiesAndGetters),
|
|
3515
|
+
...(this.settersByKey.get(key) || this.unmatchableSetters)
|
|
3502
3516
|
]
|
|
3503
3517
|
: this.allProperties) {
|
|
3504
3518
|
property.deoptimizePath(subPath);
|
|
@@ -3560,9 +3574,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3560
3574
|
const [propertiesAndAccessorsByKey, accessorsByKey, unmatchableAccessors] = interaction.type === INTERACTION_ACCESSED
|
|
3561
3575
|
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
3562
3576
|
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
3563
|
-
if (
|
|
3564
|
-
if (propertiesAndAccessorsByKey
|
|
3565
|
-
const accessors = accessorsByKey
|
|
3577
|
+
if (isConcreteKey(key)) {
|
|
3578
|
+
if (propertiesAndAccessorsByKey.get(key)) {
|
|
3579
|
+
const accessors = accessorsByKey.get(key);
|
|
3566
3580
|
if (accessors) {
|
|
3567
3581
|
for (const accessor of accessors) {
|
|
3568
3582
|
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
@@ -3578,7 +3592,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3578
3592
|
}
|
|
3579
3593
|
}
|
|
3580
3594
|
else {
|
|
3581
|
-
for (const accessors of [...
|
|
3595
|
+
for (const accessors of [...accessorsByKey.values(), unmatchableAccessors]) {
|
|
3582
3596
|
for (const accessor of accessors) {
|
|
3583
3597
|
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
3584
3598
|
return true;
|
|
@@ -3593,7 +3607,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3593
3607
|
include(context, includeChildrenRecursively) {
|
|
3594
3608
|
this.included = true;
|
|
3595
3609
|
for (const property of this.allProperties) {
|
|
3596
|
-
if (includeChildrenRecursively ||
|
|
3610
|
+
if (includeChildrenRecursively ||
|
|
3611
|
+
property.shouldBeIncluded(context) ||
|
|
3612
|
+
this.alwaysIncludedProperties.has(property)) {
|
|
3597
3613
|
property.include(context, includeChildrenRecursively);
|
|
3598
3614
|
}
|
|
3599
3615
|
}
|
|
@@ -3601,14 +3617,17 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3601
3617
|
}
|
|
3602
3618
|
includePath(path, context) {
|
|
3603
3619
|
this.included = true;
|
|
3620
|
+
for (const property of this.alwaysIncludedProperties) {
|
|
3621
|
+
property.includePath(UNKNOWN_PATH, context);
|
|
3622
|
+
}
|
|
3604
3623
|
if (path.length === 0)
|
|
3605
3624
|
return;
|
|
3606
3625
|
const [key, ...subPath] = path;
|
|
3607
|
-
const [includedMembers, includedPath] =
|
|
3626
|
+
const [includedMembers, includedPath] = isConcreteKey(key)
|
|
3608
3627
|
? [
|
|
3609
3628
|
new Set([
|
|
3610
|
-
...(this.propertiesAndGettersByKey
|
|
3611
|
-
...(this.propertiesAndSettersByKey
|
|
3629
|
+
...(this.propertiesAndGettersByKey.get(key) || this.unmatchablePropertiesAndGetters),
|
|
3630
|
+
...(this.propertiesAndSettersByKey.get(key) || this.unmatchablePropertiesAndSetters)
|
|
3612
3631
|
]),
|
|
3613
3632
|
subPath
|
|
3614
3633
|
]
|
|
@@ -3619,29 +3638,36 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3619
3638
|
this.prototypeExpression?.includePath(path, context);
|
|
3620
3639
|
}
|
|
3621
3640
|
buildPropertyMaps(properties) {
|
|
3622
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchablePropertiesAndSetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3641
|
+
const { allProperties, alwaysIncludedProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchablePropertiesAndSetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3623
3642
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
3624
3643
|
const { key, kind, property } = properties[index];
|
|
3625
3644
|
allProperties.push(property);
|
|
3626
|
-
if (
|
|
3645
|
+
if (isAnyWellKnown(key) && !TREE_SHAKEABLE_SYMBOLS.has(key)) {
|
|
3646
|
+
// Never treeshake well-known symbols (unless Rollup can optimize them)
|
|
3647
|
+
// They are most likely called implicitly by language semantics, don't get rid of them
|
|
3648
|
+
alwaysIncludedProperties.add(property);
|
|
3649
|
+
if (key === UnknownWellKnown)
|
|
3650
|
+
continue;
|
|
3651
|
+
}
|
|
3652
|
+
if (isConcreteKey(key)) {
|
|
3627
3653
|
if (kind === 'set') {
|
|
3628
|
-
if (!propertiesAndSettersByKey
|
|
3629
|
-
propertiesAndSettersByKey
|
|
3630
|
-
settersByKey
|
|
3654
|
+
if (!propertiesAndSettersByKey.has(key)) {
|
|
3655
|
+
propertiesAndSettersByKey.set(key, [property, ...unmatchablePropertiesAndSetters]);
|
|
3656
|
+
settersByKey.set(key, [property, ...unmatchableSetters]);
|
|
3631
3657
|
}
|
|
3632
3658
|
}
|
|
3633
3659
|
else if (kind === 'get') {
|
|
3634
|
-
if (!propertiesAndGettersByKey
|
|
3635
|
-
propertiesAndGettersByKey
|
|
3636
|
-
gettersByKey
|
|
3660
|
+
if (!propertiesAndGettersByKey.has(key)) {
|
|
3661
|
+
propertiesAndGettersByKey.set(key, [property, ...unmatchablePropertiesAndGetters]);
|
|
3662
|
+
gettersByKey.set(key, [property, ...unmatchableGetters]);
|
|
3637
3663
|
}
|
|
3638
3664
|
}
|
|
3639
3665
|
else {
|
|
3640
|
-
if (!propertiesAndSettersByKey
|
|
3641
|
-
propertiesAndSettersByKey
|
|
3666
|
+
if (!propertiesAndSettersByKey.has(key)) {
|
|
3667
|
+
propertiesAndSettersByKey.set(key, [property, ...unmatchablePropertiesAndSetters]);
|
|
3642
3668
|
}
|
|
3643
|
-
if (!propertiesAndGettersByKey
|
|
3644
|
-
propertiesAndGettersByKey
|
|
3669
|
+
if (!propertiesAndGettersByKey.has(key)) {
|
|
3670
|
+
propertiesAndGettersByKey.set(key, [property, ...unmatchablePropertiesAndGetters]);
|
|
3645
3671
|
}
|
|
3646
3672
|
}
|
|
3647
3673
|
}
|
|
@@ -3662,7 +3688,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3662
3688
|
}
|
|
3663
3689
|
}
|
|
3664
3690
|
deoptimizeCachedEntities() {
|
|
3665
|
-
for (const expressionsToBeDeoptimized of
|
|
3691
|
+
for (const expressionsToBeDeoptimized of this.expressionsToBeDeoptimizedByKey.values()) {
|
|
3666
3692
|
for (const expression of expressionsToBeDeoptimized) {
|
|
3667
3693
|
expression.deoptimizeCache();
|
|
3668
3694
|
}
|
|
@@ -3672,8 +3698,8 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3672
3698
|
}
|
|
3673
3699
|
}
|
|
3674
3700
|
deoptimizeCachedIntegerEntities() {
|
|
3675
|
-
for (const [key, expressionsToBeDeoptimized] of
|
|
3676
|
-
if (INTEGER_REG_EXP.test(key)) {
|
|
3701
|
+
for (const [key, expressionsToBeDeoptimized] of this.expressionsToBeDeoptimizedByKey.entries()) {
|
|
3702
|
+
if (typeof key === 'string' && INTEGER_REG_EXP.test(key)) {
|
|
3677
3703
|
for (const expression of expressionsToBeDeoptimized) {
|
|
3678
3704
|
expression.deoptimizeCache();
|
|
3679
3705
|
}
|
|
@@ -3686,30 +3712,32 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3686
3712
|
getMemberExpression(key) {
|
|
3687
3713
|
if (this.hasLostTrack ||
|
|
3688
3714
|
this.hasUnknownDeoptimizedProperty ||
|
|
3689
|
-
|
|
3690
|
-
(this.hasUnknownDeoptimizedInteger && INTEGER_REG_EXP.test(key)) ||
|
|
3691
|
-
this.deoptimizedPaths
|
|
3715
|
+
!isConcreteKey(key) ||
|
|
3716
|
+
(this.hasUnknownDeoptimizedInteger && typeof key === 'string' && INTEGER_REG_EXP.test(key)) ||
|
|
3717
|
+
this.deoptimizedPaths.get(key)) {
|
|
3692
3718
|
return UNKNOWN_EXPRESSION;
|
|
3693
3719
|
}
|
|
3694
|
-
const properties = this.propertiesAndGettersByKey
|
|
3720
|
+
const properties = this.propertiesAndGettersByKey.get(key);
|
|
3695
3721
|
if (properties?.length === 1) {
|
|
3696
3722
|
return properties[0];
|
|
3697
3723
|
}
|
|
3698
3724
|
if (properties ||
|
|
3699
3725
|
this.unmatchablePropertiesAndGetters.length > 0 ||
|
|
3700
|
-
(this.unknownIntegerProps.length > 0 && INTEGER_REG_EXP.test(key))) {
|
|
3726
|
+
(this.unknownIntegerProps.length > 0 && typeof key === 'string' && INTEGER_REG_EXP.test(key))) {
|
|
3701
3727
|
return UNKNOWN_EXPRESSION;
|
|
3702
3728
|
}
|
|
3703
3729
|
return null;
|
|
3704
3730
|
}
|
|
3705
3731
|
getMemberExpressionAndTrackDeopt(key, origin) {
|
|
3706
|
-
if (
|
|
3732
|
+
if (!isConcreteKey(key)) {
|
|
3707
3733
|
return UNKNOWN_EXPRESSION;
|
|
3708
3734
|
}
|
|
3709
3735
|
const expression = this.getMemberExpression(key);
|
|
3710
3736
|
if (!(expression === UNKNOWN_EXPRESSION || this.immutable)) {
|
|
3711
|
-
|
|
3712
|
-
|
|
3737
|
+
let expressionsToBeDeoptimized = this.expressionsToBeDeoptimizedByKey.get(key);
|
|
3738
|
+
if (!expressionsToBeDeoptimized) {
|
|
3739
|
+
this.expressionsToBeDeoptimizedByKey.set(key, (expressionsToBeDeoptimized = []));
|
|
3740
|
+
}
|
|
3713
3741
|
expressionsToBeDeoptimized.push(origin);
|
|
3714
3742
|
}
|
|
3715
3743
|
return expression;
|
|
@@ -3737,15 +3765,14 @@ const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression e
|
|
|
3737
3765
|
return path.length > 1 || type === INTERACTION_CALLED;
|
|
3738
3766
|
}
|
|
3739
3767
|
})();
|
|
3740
|
-
const OBJECT_PROTOTYPE = new ObjectEntity(
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
}, OBJECT_PROTOTYPE_FALLBACK, true);
|
|
3768
|
+
const OBJECT_PROTOTYPE = new ObjectEntity(new Map([
|
|
3769
|
+
['hasOwnProperty', METHOD_RETURNS_BOOLEAN],
|
|
3770
|
+
['isPrototypeOf', METHOD_RETURNS_BOOLEAN],
|
|
3771
|
+
['propertyIsEnumerable', METHOD_RETURNS_BOOLEAN],
|
|
3772
|
+
['toLocaleString', METHOD_RETURNS_STRING],
|
|
3773
|
+
['toString', METHOD_RETURNS_STRING],
|
|
3774
|
+
['valueOf', METHOD_RETURNS_UNKNOWN]
|
|
3775
|
+
]), OBJECT_PROTOTYPE_FALLBACK, true);
|
|
3749
3776
|
|
|
3750
3777
|
const NEW_ARRAY_PROPERTIES = [
|
|
3751
3778
|
{ key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION },
|
|
@@ -3850,44 +3877,43 @@ const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF = [
|
|
|
3850
3877
|
returnsPrimitive: null
|
|
3851
3878
|
})
|
|
3852
3879
|
];
|
|
3853
|
-
const ARRAY_PROTOTYPE = new ObjectEntity(
|
|
3854
|
-
__proto__: null,
|
|
3880
|
+
const ARRAY_PROTOTYPE = new ObjectEntity(new Map([
|
|
3855
3881
|
// We assume that accessors have effects as we do not track the accessed value afterwards
|
|
3856
|
-
at
|
|
3857
|
-
concat
|
|
3858
|
-
copyWithin
|
|
3859
|
-
entries
|
|
3860
|
-
every
|
|
3861
|
-
fill
|
|
3862
|
-
filter
|
|
3863
|
-
find
|
|
3864
|
-
findIndex
|
|
3865
|
-
findLast
|
|
3866
|
-
findLastIndex
|
|
3867
|
-
flat
|
|
3868
|
-
flatMap
|
|
3869
|
-
forEach
|
|
3870
|
-
includes
|
|
3871
|
-
indexOf
|
|
3872
|
-
join
|
|
3873
|
-
keys
|
|
3874
|
-
lastIndexOf
|
|
3875
|
-
map
|
|
3876
|
-
pop
|
|
3877
|
-
push
|
|
3878
|
-
reduce
|
|
3879
|
-
reduceRight
|
|
3880
|
-
reverse
|
|
3881
|
-
shift
|
|
3882
|
-
slice
|
|
3883
|
-
some
|
|
3884
|
-
sort
|
|
3885
|
-
splice
|
|
3886
|
-
toLocaleString
|
|
3887
|
-
toString
|
|
3888
|
-
unshift
|
|
3889
|
-
values
|
|
3890
|
-
|
|
3882
|
+
['at', METHOD_DEOPTS_SELF_RETURNS_UNKNOWN],
|
|
3883
|
+
['concat', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY],
|
|
3884
|
+
['copyWithin', METHOD_MUTATES_SELF_RETURNS_SELF],
|
|
3885
|
+
['entries', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY],
|
|
3886
|
+
['every', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN],
|
|
3887
|
+
['fill', METHOD_MUTATES_SELF_RETURNS_SELF],
|
|
3888
|
+
['filter', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY],
|
|
3889
|
+
['find', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN],
|
|
3890
|
+
['findIndex', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER],
|
|
3891
|
+
['findLast', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN],
|
|
3892
|
+
['findLastIndex', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER],
|
|
3893
|
+
['flat', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY],
|
|
3894
|
+
['flatMap', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY],
|
|
3895
|
+
['forEach', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN],
|
|
3896
|
+
['includes', METHOD_RETURNS_BOOLEAN],
|
|
3897
|
+
['indexOf', METHOD_RETURNS_NUMBER],
|
|
3898
|
+
['join', METHOD_RETURNS_STRING],
|
|
3899
|
+
['keys', METHOD_RETURNS_UNKNOWN],
|
|
3900
|
+
['lastIndexOf', METHOD_RETURNS_NUMBER],
|
|
3901
|
+
['map', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY],
|
|
3902
|
+
['pop', METHOD_MUTATES_SELF_RETURNS_UNKNOWN],
|
|
3903
|
+
['push', METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER],
|
|
3904
|
+
['reduce', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN],
|
|
3905
|
+
['reduceRight', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN],
|
|
3906
|
+
['reverse', METHOD_MUTATES_SELF_RETURNS_SELF],
|
|
3907
|
+
['shift', METHOD_MUTATES_SELF_RETURNS_UNKNOWN],
|
|
3908
|
+
['slice', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY],
|
|
3909
|
+
['some', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN],
|
|
3910
|
+
['sort', METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF],
|
|
3911
|
+
['splice', METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY],
|
|
3912
|
+
['toLocaleString', METHOD_RETURNS_STRING],
|
|
3913
|
+
['toString', METHOD_RETURNS_STRING],
|
|
3914
|
+
['unshift', METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER],
|
|
3915
|
+
['values', METHOD_DEOPTS_SELF_RETURNS_UNKNOWN]
|
|
3916
|
+
]), OBJECT_PROTOTYPE, true);
|
|
3891
3917
|
|
|
3892
3918
|
class SpreadElement extends NodeBase {
|
|
3893
3919
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -3994,6 +4020,14 @@ const ValueProperties = Symbol('Value Properties');
|
|
|
3994
4020
|
const getUnknownValue = () => UnknownValue;
|
|
3995
4021
|
const returnFalse = () => false;
|
|
3996
4022
|
const returnTrue = () => true;
|
|
4023
|
+
const getWellKnownSymbol = (symbol) => ({
|
|
4024
|
+
__proto__: null,
|
|
4025
|
+
[ValueProperties]: {
|
|
4026
|
+
deoptimizeArgumentsOnCall: doNothing,
|
|
4027
|
+
getLiteralValue: () => symbol,
|
|
4028
|
+
hasEffectsWhenCalled: returnTrue
|
|
4029
|
+
}
|
|
4030
|
+
});
|
|
3997
4031
|
const PURE = {
|
|
3998
4032
|
deoptimizeArgumentsOnCall: doNothing,
|
|
3999
4033
|
getLiteralValue: getUnknownValue,
|
|
@@ -4079,6 +4113,11 @@ const INTL_MEMBER = {
|
|
|
4079
4113
|
[ValueProperties]: PURE,
|
|
4080
4114
|
supportedLocalesOf: PC
|
|
4081
4115
|
};
|
|
4116
|
+
const UNKNOWN_WELL_KNOWN = {
|
|
4117
|
+
deoptimizeArgumentsOnCall: doNothing,
|
|
4118
|
+
getLiteralValue: () => UnknownWellKnown,
|
|
4119
|
+
hasEffectsWhenCalled: returnTrue
|
|
4120
|
+
};
|
|
4082
4121
|
const knownGlobals = {
|
|
4083
4122
|
// Placeholders for global objects to avoid shape mutations
|
|
4084
4123
|
global: O,
|
|
@@ -4274,37 +4313,10 @@ const knownGlobals = {
|
|
|
4274
4313
|
for: PF,
|
|
4275
4314
|
keyFor: PF,
|
|
4276
4315
|
prototype: O,
|
|
4277
|
-
asyncDispose:
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
getLiteralValue() {
|
|
4282
|
-
return SymbolAsyncDispose;
|
|
4283
|
-
},
|
|
4284
|
-
// This might not be needed, but then we need to check a few more cases
|
|
4285
|
-
hasEffectsWhenCalled: returnTrue
|
|
4286
|
-
}
|
|
4287
|
-
},
|
|
4288
|
-
dispose: {
|
|
4289
|
-
__proto__: null,
|
|
4290
|
-
[ValueProperties]: {
|
|
4291
|
-
deoptimizeArgumentsOnCall: doNothing,
|
|
4292
|
-
getLiteralValue() {
|
|
4293
|
-
return SymbolDispose;
|
|
4294
|
-
},
|
|
4295
|
-
hasEffectsWhenCalled: returnTrue
|
|
4296
|
-
}
|
|
4297
|
-
},
|
|
4298
|
-
toStringTag: {
|
|
4299
|
-
__proto__: null,
|
|
4300
|
-
[ValueProperties]: {
|
|
4301
|
-
deoptimizeArgumentsOnCall: doNothing,
|
|
4302
|
-
getLiteralValue() {
|
|
4303
|
-
return SymbolToStringTag;
|
|
4304
|
-
},
|
|
4305
|
-
hasEffectsWhenCalled: returnTrue
|
|
4306
|
-
}
|
|
4307
|
-
}
|
|
4316
|
+
asyncDispose: getWellKnownSymbol(SymbolAsyncDispose),
|
|
4317
|
+
dispose: getWellKnownSymbol(SymbolDispose),
|
|
4318
|
+
hasInstance: getWellKnownSymbol(SymbolHasInstance),
|
|
4319
|
+
toStringTag: getWellKnownSymbol(SymbolToStringTag)
|
|
4308
4320
|
},
|
|
4309
4321
|
SyntaxError: PC,
|
|
4310
4322
|
toLocaleString: O,
|
|
@@ -4978,7 +4990,9 @@ function getGlobalAtPath(path) {
|
|
|
4978
4990
|
}
|
|
4979
4991
|
currentGlobal = currentGlobal[pathSegment];
|
|
4980
4992
|
if (!currentGlobal) {
|
|
4981
|
-
|
|
4993
|
+
// Well-known symbols very often have a complex meaning and are invoked implicitly by the language.
|
|
4994
|
+
// Resolve them to a special value so they can be distinguished and excluded from treeshaking.
|
|
4995
|
+
return path[0] === 'Symbol' && path.length === 2 ? UNKNOWN_WELL_KNOWN : null;
|
|
4982
4996
|
}
|
|
4983
4997
|
}
|
|
4984
4998
|
return currentGlobal[ValueProperties];
|
|
@@ -5924,7 +5938,11 @@ class ClassNode extends NodeBase {
|
|
|
5924
5938
|
if (definition.computed) {
|
|
5925
5939
|
const keyValue = definition.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5926
5940
|
if (typeof keyValue === 'symbol') {
|
|
5927
|
-
properties.push({
|
|
5941
|
+
properties.push({
|
|
5942
|
+
key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey,
|
|
5943
|
+
kind,
|
|
5944
|
+
property: definition
|
|
5945
|
+
});
|
|
5928
5946
|
continue;
|
|
5929
5947
|
}
|
|
5930
5948
|
else {
|
|
@@ -6809,7 +6827,7 @@ class FunctionNode extends FunctionBase {
|
|
|
6809
6827
|
}
|
|
6810
6828
|
createScope(parentScope) {
|
|
6811
6829
|
this.scope = new FunctionScope(parentScope, this);
|
|
6812
|
-
this.constructedEntity = new ObjectEntity(
|
|
6830
|
+
this.constructedEntity = new ObjectEntity(new Map(), OBJECT_PROTOTYPE);
|
|
6813
6831
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
6814
6832
|
// constructed entity.
|
|
6815
6833
|
this.scope.thisVariable.addArgumentForDeoptimization(this.constructedEntity);
|
|
@@ -7544,6 +7562,9 @@ class MemberExpression extends NodeBase {
|
|
|
7544
7562
|
this.includeNode(context);
|
|
7545
7563
|
this.object.include(context, includeChildrenRecursively);
|
|
7546
7564
|
this.property.include(context, includeChildrenRecursively);
|
|
7565
|
+
if (includeChildrenRecursively) {
|
|
7566
|
+
this.variable?.includePath(UNKNOWN_PATH, context);
|
|
7567
|
+
}
|
|
7547
7568
|
}
|
|
7548
7569
|
includeNode(context) {
|
|
7549
7570
|
this.included = true;
|
|
@@ -11959,6 +11980,9 @@ class BinaryExpression extends NodeBase {
|
|
|
11959
11980
|
if (typeof this.getRenderedLiteralValue() === 'symbol') {
|
|
11960
11981
|
this.left.include(context, includeChildrenRecursively, options);
|
|
11961
11982
|
this.right.include(context, includeChildrenRecursively, options);
|
|
11983
|
+
// `instanceof` will attempt to call RHS's `Symbol.hasInstance` if it exists.
|
|
11984
|
+
if (this.operator === 'instanceof')
|
|
11985
|
+
this.right.includePath(INSTANCEOF_PATH, context);
|
|
11962
11986
|
}
|
|
11963
11987
|
}
|
|
11964
11988
|
includeNode(context) {
|
|
@@ -14458,7 +14482,11 @@ class ObjectExpression extends NodeBase {
|
|
|
14458
14482
|
if (property.computed) {
|
|
14459
14483
|
const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
14460
14484
|
if (typeof keyValue === 'symbol') {
|
|
14461
|
-
properties.push({
|
|
14485
|
+
properties.push({
|
|
14486
|
+
key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey,
|
|
14487
|
+
kind: property.kind,
|
|
14488
|
+
property
|
|
14489
|
+
});
|
|
14462
14490
|
continue;
|
|
14463
14491
|
}
|
|
14464
14492
|
else {
|