@rollup/wasm-node 5.0.0-0 → 5.0.0-1
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 -3
- 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 +893 -689
- package/dist/es/shared/parseAst.js +113 -29
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/native.js +19 -3
- package/dist/parseAst.js +2 -2
- package/dist/rollup.android-arm-eabi.node +0 -0
- package/dist/rollup.android-arm64.node +0 -0
- package/dist/rollup.darwin-arm64.node +0 -0
- package/dist/rollup.darwin-x64.node +0 -0
- package/dist/rollup.freebsd-arm64.node +0 -0
- package/dist/rollup.freebsd-x64.node +0 -0
- package/dist/rollup.js +2 -2
- package/dist/rollup.linux-arm-gnueabihf.node +0 -0
- package/dist/rollup.linux-arm-musleabihf.node +0 -0
- package/dist/rollup.linux-arm64-gnu.node +0 -0
- package/dist/rollup.linux-arm64-musl.node +0 -0
- package/dist/rollup.linux-loong64-gnu.node +0 -0
- package/dist/rollup.linux-loong64-musl.node +0 -0
- package/dist/rollup.linux-ppc64-gnu.node +0 -0
- package/dist/rollup.linux-ppc64-musl.node +0 -0
- package/dist/rollup.linux-riscv64-gnu.node +0 -0
- package/dist/rollup.linux-riscv64-musl.node +0 -0
- package/dist/rollup.linux-s390x-gnu.node +0 -0
- package/dist/rollup.linux-x64-gnu.node +0 -0
- package/dist/rollup.linux-x64-musl.node +0 -0
- package/dist/rollup.openbsd-x64.node +0 -0
- package/dist/rollup.openharmony-arm64.node +0 -0
- package/dist/rollup.win32-arm64-msvc.node +0 -0
- package/dist/rollup.win32-ia32-msvc.node +0 -0
- package/dist/rollup.win32-x64-gnu.node +0 -0
- package/dist/rollup.win32-x64-msvc.node +0 -0
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/node-entry.js +2 -2
- package/dist/shared/parseAst.js +119 -35
- package/dist/shared/rollup.js +892 -688
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm.js +2 -18
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +16 -16
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v5.0.0-
|
|
4
|
-
|
|
3
|
+
Rollup.js v5.0.0-1
|
|
4
|
+
Sun, 18 Oct 2026 06:06:25 GMT - commit ed75a6895d5bc62fdbff91b9d48e22e6e281e3bc
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
|
|
|
42
42
|
|
|
43
43
|
const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
|
|
44
44
|
|
|
45
|
-
var version = "5.0.0-
|
|
45
|
+
var version = "5.0.0-1";
|
|
46
46
|
const package_ = {
|
|
47
47
|
version: version};
|
|
48
48
|
|
|
@@ -5474,7 +5474,7 @@ var MagicString = class MagicString {
|
|
|
5474
5474
|
while (chunk !== last) {
|
|
5475
5475
|
if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
|
|
5476
5476
|
chunk = chunk.next;
|
|
5477
|
-
chunk.edit("", false);
|
|
5477
|
+
chunk.edit("", false, !overwrite);
|
|
5478
5478
|
}
|
|
5479
5479
|
first.edit(content, storeName, !overwrite);
|
|
5480
5480
|
} else {
|
|
@@ -5828,8 +5828,8 @@ var MagicString = class MagicString {
|
|
|
5828
5828
|
if (this._hasRemovedContent(match.index, match.index + match[0].length)) return false;
|
|
5829
5829
|
const replacement = getReplacement(match, this.original);
|
|
5830
5830
|
if (replacement === match[0]) return true;
|
|
5831
|
-
if (match[0].length === 0) this.appendRight(match.index, replacement);
|
|
5832
|
-
else this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
5831
|
+
if (match[0].length === 0) this.appendRight(match.index - this.offset, replacement);
|
|
5832
|
+
else this.overwrite(match.index - this.offset, match.index + match[0].length - this.offset, replacement);
|
|
5833
5833
|
return true;
|
|
5834
5834
|
};
|
|
5835
5835
|
if (searchValue.global) {
|
|
@@ -5856,8 +5856,8 @@ var MagicString = class MagicString {
|
|
|
5856
5856
|
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
5857
5857
|
else replacement = expandReplacement(replacement, string, index, original, [], void 0);
|
|
5858
5858
|
if (string !== replacement) {
|
|
5859
|
-
if (string.length === 0) this.appendRight(index, replacement);
|
|
5860
|
-
else this.overwrite(index, index + string.length, replacement);
|
|
5859
|
+
if (string.length === 0) this.appendRight(index - this.offset, replacement);
|
|
5860
|
+
else this.overwrite(index - this.offset, index + string.length - this.offset, replacement);
|
|
5861
5861
|
}
|
|
5862
5862
|
break;
|
|
5863
5863
|
}
|
|
@@ -5878,7 +5878,7 @@ var MagicString = class MagicString {
|
|
|
5878
5878
|
for (let index = 0; index <= original.length; index += 1) {
|
|
5879
5879
|
if (this._hasRemovedContent(index, index)) continue;
|
|
5880
5880
|
const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
|
|
5881
|
-
if (_replacement !== "") this.appendRight(index, _replacement);
|
|
5881
|
+
if (_replacement !== "") this.appendRight(index - this.offset, _replacement);
|
|
5882
5882
|
}
|
|
5883
5883
|
return this;
|
|
5884
5884
|
}
|
|
@@ -5886,7 +5886,7 @@ var MagicString = class MagicString {
|
|
|
5886
5886
|
if (this._hasRemovedContent(index, index + stringLength)) continue;
|
|
5887
5887
|
const previous = original.slice(index, index + stringLength);
|
|
5888
5888
|
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
|
|
5889
|
-
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
5889
|
+
if (previous !== _replacement) this.overwrite(index - this.offset, index + stringLength - this.offset, _replacement);
|
|
5890
5890
|
}
|
|
5891
5891
|
return this;
|
|
5892
5892
|
}
|
|
@@ -6758,228 +6758,343 @@ function getSafeName(baseName, usedNames, forbiddenNames) {
|
|
|
6758
6758
|
return safeName;
|
|
6759
6759
|
}
|
|
6760
6760
|
|
|
6761
|
-
//
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6761
|
+
// This file is generated by scripts/generate-child-node-keys.ts.
|
|
6762
|
+
// Do not edit this file directly.
|
|
6763
|
+
const childNodeKeys = {
|
|
6764
|
+
ArrayExpression: ['elements'],
|
|
6765
|
+
ArrayPattern: ['elements'],
|
|
6766
|
+
ArrowFunctionExpression: ['params', 'body'],
|
|
6767
|
+
AssignmentExpression: ['left', 'right'],
|
|
6768
|
+
AssignmentPattern: ['left', 'right'],
|
|
6769
|
+
AwaitExpression: ['argument'],
|
|
6770
|
+
BinaryExpression: ['left', 'right'],
|
|
6771
|
+
BlockStatement: ['body'],
|
|
6772
|
+
BreakStatement: ['label'],
|
|
6773
|
+
CallExpression: ['callee', 'arguments'],
|
|
6774
|
+
CatchClause: ['param', 'body'],
|
|
6775
|
+
ChainExpression: ['expression'],
|
|
6776
|
+
ClassBody: ['body'],
|
|
6777
|
+
ClassDeclaration: ['decorators', 'id', 'superClass', 'body'],
|
|
6778
|
+
ClassExpression: ['decorators', 'id', 'superClass', 'body'],
|
|
6779
|
+
ConditionalExpression: ['test', 'consequent', 'alternate'],
|
|
6780
|
+
ContinueStatement: ['label'],
|
|
6781
|
+
DebuggerStatement: [],
|
|
6782
|
+
Decorator: ['expression'],
|
|
6783
|
+
DoWhileStatement: ['body', 'test'],
|
|
6784
|
+
EmptyStatement: [],
|
|
6785
|
+
ExportAllDeclaration: ['exported', 'source', 'attributes'],
|
|
6786
|
+
ExportDefaultDeclaration: ['declaration'],
|
|
6787
|
+
ExportNamedDeclaration: ['specifiers', 'source', 'attributes', 'declaration'],
|
|
6788
|
+
ExportSpecifier: ['local', 'exported'],
|
|
6789
|
+
ExpressionStatement: ['expression'],
|
|
6790
|
+
ForInStatement: ['left', 'right', 'body'],
|
|
6791
|
+
ForOfStatement: ['left', 'right', 'body'],
|
|
6792
|
+
ForStatement: ['init', 'test', 'update', 'body'],
|
|
6793
|
+
FunctionDeclaration: ['id', 'params', 'body'],
|
|
6794
|
+
FunctionExpression: ['id', 'params', 'body'],
|
|
6795
|
+
Identifier: [],
|
|
6796
|
+
IfStatement: ['test', 'consequent', 'alternate'],
|
|
6797
|
+
ImportAttribute: ['key', 'value'],
|
|
6798
|
+
ImportDeclaration: ['specifiers', 'source', 'attributes'],
|
|
6799
|
+
ImportDefaultSpecifier: ['local'],
|
|
6800
|
+
ImportExpression: ['source', 'options'],
|
|
6801
|
+
ImportNamespaceSpecifier: ['local'],
|
|
6802
|
+
ImportSpecifier: ['imported', 'local'],
|
|
6803
|
+
JSXAttribute: ['name', 'value'],
|
|
6804
|
+
JSXClosingElement: ['name'],
|
|
6805
|
+
JSXClosingFragment: [],
|
|
6806
|
+
JSXElement: ['openingElement', 'children', 'closingElement'],
|
|
6807
|
+
JSXEmptyExpression: [],
|
|
6808
|
+
JSXExpressionContainer: ['expression'],
|
|
6809
|
+
JSXFragment: ['openingFragment', 'children', 'closingFragment'],
|
|
6810
|
+
JSXIdentifier: [],
|
|
6811
|
+
JSXMemberExpression: ['object', 'property'],
|
|
6812
|
+
JSXNamespacedName: ['namespace', 'name'],
|
|
6813
|
+
JSXOpeningElement: ['name', 'attributes'],
|
|
6814
|
+
JSXOpeningFragment: [],
|
|
6815
|
+
JSXSpreadAttribute: ['argument'],
|
|
6816
|
+
JSXSpreadChild: ['expression'],
|
|
6817
|
+
JSXText: [],
|
|
6818
|
+
LabeledStatement: ['label', 'body'],
|
|
6819
|
+
Literal: [],
|
|
6820
|
+
LogicalExpression: ['left', 'right'],
|
|
6821
|
+
MemberExpression: ['object', 'property'],
|
|
6822
|
+
MetaProperty: ['meta', 'property'],
|
|
6823
|
+
MethodDefinition: ['decorators', 'key', 'value'],
|
|
6824
|
+
NewExpression: ['callee', 'arguments'],
|
|
6825
|
+
ObjectExpression: ['properties'],
|
|
6826
|
+
ObjectPattern: ['properties'],
|
|
6827
|
+
PanicError: [],
|
|
6828
|
+
ParseError: [],
|
|
6829
|
+
PrivateIdentifier: [],
|
|
6830
|
+
Program: ['body'],
|
|
6831
|
+
Property: ['key', 'value'],
|
|
6832
|
+
PropertyDefinition: ['decorators', 'key', 'value'],
|
|
6833
|
+
RestElement: ['argument'],
|
|
6834
|
+
ReturnStatement: ['argument'],
|
|
6835
|
+
SequenceExpression: ['expressions'],
|
|
6836
|
+
SpreadElement: ['argument'],
|
|
6837
|
+
StaticBlock: ['body'],
|
|
6838
|
+
Super: [],
|
|
6839
|
+
SwitchCase: ['test', 'consequent'],
|
|
6840
|
+
SwitchStatement: ['discriminant', 'cases'],
|
|
6841
|
+
TaggedTemplateExpression: ['tag', 'quasi'],
|
|
6842
|
+
TemplateElement: [],
|
|
6843
|
+
TemplateLiteral: ['quasis', 'expressions'],
|
|
6844
|
+
ThisExpression: [],
|
|
6845
|
+
ThrowStatement: ['argument'],
|
|
6846
|
+
TryStatement: ['block', 'handler', 'finalizer'],
|
|
6847
|
+
UnaryExpression: ['argument'],
|
|
6848
|
+
UpdateExpression: ['argument'],
|
|
6849
|
+
VariableDeclaration: ['declarations'],
|
|
6850
|
+
VariableDeclarator: ['id', 'init'],
|
|
6851
|
+
WhileStatement: ['test', 'body'],
|
|
6852
|
+
YieldExpression: ['argument']
|
|
6775
6853
|
};
|
|
6776
6854
|
|
|
6777
|
-
function
|
|
6778
|
-
return
|
|
6855
|
+
function createInclusionContext() {
|
|
6856
|
+
return {
|
|
6857
|
+
brokenFlow: false,
|
|
6858
|
+
hasBreak: false,
|
|
6859
|
+
hasContinue: false,
|
|
6860
|
+
includedCallArguments: new Set(),
|
|
6861
|
+
includedLabels: new Set()
|
|
6862
|
+
};
|
|
6779
6863
|
}
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6864
|
+
function createHasEffectsContext() {
|
|
6865
|
+
return {
|
|
6866
|
+
accessed: new EntityPathTracker(),
|
|
6867
|
+
assigned: new EntityPathTracker(),
|
|
6868
|
+
brokenFlow: false,
|
|
6869
|
+
called: new DiscriminatedPathTracker(),
|
|
6870
|
+
hasBreak: false,
|
|
6871
|
+
hasContinue: false,
|
|
6872
|
+
ignore: {
|
|
6873
|
+
breaks: false,
|
|
6874
|
+
continues: false,
|
|
6875
|
+
labels: new Set(),
|
|
6876
|
+
returnYield: false,
|
|
6877
|
+
this: false
|
|
6878
|
+
},
|
|
6879
|
+
includedLabels: new Set(),
|
|
6880
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
6881
|
+
replacedVariableInits: new Map()
|
|
6882
|
+
};
|
|
6883
|
+
}
|
|
6884
|
+
|
|
6885
|
+
const INCLUDE_PARAMETERS = 'variables';
|
|
6886
|
+
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
6887
|
+
class NodeBase extends ExpressionEntity {
|
|
6888
|
+
/**
|
|
6889
|
+
* Nodes can apply custom deoptimizations once they become part of the
|
|
6890
|
+
* executed code. To do this, they must initialize this as false, implement
|
|
6891
|
+
* applyDeoptimizations and call this from include and hasEffects if they have
|
|
6892
|
+
* custom handlers
|
|
6893
|
+
*/
|
|
6894
|
+
get deoptimized() {
|
|
6895
|
+
return isFlagSet(this.flags, 2 /* Flag.deoptimized */);
|
|
6783
6896
|
}
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
value: {
|
|
6787
|
-
hasEffectsWhenCalled: null,
|
|
6788
|
-
returns: UNKNOWN_EXPRESSION
|
|
6897
|
+
set deoptimized(value) {
|
|
6898
|
+
this.flags = setFlag(this.flags, 2 /* Flag.deoptimized */, value);
|
|
6789
6899
|
}
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
}
|
|
6796
|
-
return UNKNOWN_RETURN_EXPRESSION;
|
|
6900
|
+
constructor(parent, parentScope) {
|
|
6901
|
+
super();
|
|
6902
|
+
this.parent = parent;
|
|
6903
|
+
this.scope = parentScope;
|
|
6904
|
+
this.createScope(parentScope);
|
|
6797
6905
|
}
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6906
|
+
addExportedVariables(_variables, _exportNamesByVariable) { }
|
|
6907
|
+
/**
|
|
6908
|
+
* Override this to bind assignments to variables and do any initialisations
|
|
6909
|
+
* that require the scopes to be populated with variables.
|
|
6910
|
+
*/
|
|
6911
|
+
bind() {
|
|
6912
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6913
|
+
const value = this[key];
|
|
6914
|
+
if (Array.isArray(value)) {
|
|
6915
|
+
for (const child of value) {
|
|
6916
|
+
child?.bind();
|
|
6917
|
+
}
|
|
6918
|
+
}
|
|
6919
|
+
else if (value) {
|
|
6920
|
+
value.bind();
|
|
6921
|
+
}
|
|
6804
6922
|
}
|
|
6805
|
-
return true;
|
|
6806
6923
|
}
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6924
|
+
/**
|
|
6925
|
+
* Override if this node should receive a different scope than the parent
|
|
6926
|
+
* scope.
|
|
6927
|
+
*/
|
|
6928
|
+
createScope(parentScope) {
|
|
6929
|
+
this.scope = parentScope;
|
|
6812
6930
|
}
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6931
|
+
hasEffects(context) {
|
|
6932
|
+
if (!this.deoptimized)
|
|
6933
|
+
this.applyDeoptimizations();
|
|
6934
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6935
|
+
const value = this[key];
|
|
6936
|
+
if (value === null)
|
|
6937
|
+
continue;
|
|
6938
|
+
if (Array.isArray(value)) {
|
|
6939
|
+
for (const child of value) {
|
|
6940
|
+
if (child?.hasEffects(context))
|
|
6941
|
+
return true;
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
6944
|
+
else if (value.hasEffects(context))
|
|
6945
|
+
return true;
|
|
6818
6946
|
}
|
|
6819
|
-
return
|
|
6947
|
+
return false;
|
|
6820
6948
|
}
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6949
|
+
hasEffectsAsAssignmentTarget(context, _checkAccess) {
|
|
6950
|
+
return (this.hasEffects(context) ||
|
|
6951
|
+
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
6952
|
+
}
|
|
6953
|
+
include(context, includeChildrenRecursively, _options) {
|
|
6954
|
+
if (!this.included)
|
|
6955
|
+
this.includeNode(context);
|
|
6956
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6957
|
+
const value = this[key];
|
|
6958
|
+
if (value === null)
|
|
6959
|
+
continue;
|
|
6960
|
+
if (Array.isArray(value)) {
|
|
6961
|
+
for (const child of value) {
|
|
6962
|
+
child?.include(context, includeChildrenRecursively);
|
|
6963
|
+
}
|
|
6964
|
+
}
|
|
6965
|
+
else {
|
|
6966
|
+
value.include(context, includeChildrenRecursively);
|
|
6967
|
+
}
|
|
6824
6968
|
}
|
|
6825
|
-
|
|
6826
|
-
|
|
6969
|
+
}
|
|
6970
|
+
includeNode(context) {
|
|
6971
|
+
this.included = true;
|
|
6972
|
+
if (!this.deoptimized)
|
|
6973
|
+
this.applyDeoptimizations();
|
|
6974
|
+
for (const key of childNodeKeys[this.type]) {
|
|
6975
|
+
const value = this[key];
|
|
6976
|
+
if (value === null)
|
|
6977
|
+
continue;
|
|
6978
|
+
if (Array.isArray(value)) {
|
|
6979
|
+
for (const child of value) {
|
|
6980
|
+
child?.includePath(UNKNOWN_PATH, context);
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
else {
|
|
6984
|
+
value.includePath(UNKNOWN_PATH, context);
|
|
6985
|
+
}
|
|
6827
6986
|
}
|
|
6828
|
-
return true;
|
|
6829
6987
|
}
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
value: {
|
|
6833
|
-
hasEffectsWhenCalled: null,
|
|
6834
|
-
returns: UNKNOWN_LITERAL_NUMBER
|
|
6988
|
+
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
6989
|
+
this.include(context, includeChildrenRecursively);
|
|
6835
6990
|
}
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6991
|
+
/**
|
|
6992
|
+
* Override to perform special initialisation steps after the scope is
|
|
6993
|
+
* initialised
|
|
6994
|
+
*/
|
|
6995
|
+
initialise() {
|
|
6996
|
+
this.scope.context.magicString.addSourcemapLocation(this.start);
|
|
6997
|
+
this.scope.context.magicString.addSourcemapLocation(this.end);
|
|
6843
6998
|
}
|
|
6844
|
-
|
|
6845
|
-
if (
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
6999
|
+
removeAnnotations(code) {
|
|
7000
|
+
if (this.annotations) {
|
|
7001
|
+
for (const annotation of this.annotations) {
|
|
7002
|
+
code.remove(annotation.start, annotation.end);
|
|
7003
|
+
}
|
|
6850
7004
|
}
|
|
6851
|
-
return true;
|
|
6852
7005
|
}
|
|
6853
|
-
|
|
6854
|
-
const
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
7006
|
+
render(code, options) {
|
|
7007
|
+
for (const key of childNodeKeys[this.type]) {
|
|
7008
|
+
const value = this[key];
|
|
7009
|
+
if (value === null)
|
|
7010
|
+
continue;
|
|
7011
|
+
if (Array.isArray(value)) {
|
|
7012
|
+
for (const child of value) {
|
|
7013
|
+
child?.render(code, options);
|
|
7014
|
+
}
|
|
7015
|
+
}
|
|
7016
|
+
else {
|
|
7017
|
+
value.render(code, options);
|
|
7018
|
+
}
|
|
7019
|
+
}
|
|
6858
7020
|
}
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
value: {
|
|
6862
|
-
hasEffectsWhenCalled({ args }, context) {
|
|
6863
|
-
const argument1 = args[2];
|
|
6864
|
-
return (args.length < 3 ||
|
|
6865
|
-
(typeof argument1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
6866
|
-
deoptimizeCache() { }
|
|
6867
|
-
}) === 'symbol' &&
|
|
6868
|
-
argument1.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)));
|
|
6869
|
-
},
|
|
6870
|
-
returns: UNKNOWN_LITERAL_STRING
|
|
7021
|
+
setAssignedValue(value) {
|
|
7022
|
+
this.assignmentInteraction = { args: [null, value], type: INTERACTION_ASSIGNED };
|
|
6871
7023
|
}
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
hasOwnProperty: returnsBoolean,
|
|
6875
|
-
isPrototypeOf: returnsBoolean,
|
|
6876
|
-
propertyIsEnumerable: returnsBoolean,
|
|
6877
|
-
toLocaleString: returnsString,
|
|
6878
|
-
toString: returnsString,
|
|
6879
|
-
valueOf: returnsUnknown
|
|
6880
|
-
});
|
|
6881
|
-
const literalBooleanMembers = assembleMemberDescriptions({
|
|
6882
|
-
valueOf: returnsBoolean
|
|
6883
|
-
}, objectMembers);
|
|
6884
|
-
const literalNumberMembers = assembleMemberDescriptions({
|
|
6885
|
-
toExponential: returnsString,
|
|
6886
|
-
toFixed: returnsString,
|
|
6887
|
-
toLocaleString: returnsString,
|
|
6888
|
-
toPrecision: returnsString,
|
|
6889
|
-
valueOf: returnsNumber
|
|
6890
|
-
}, objectMembers);
|
|
6891
|
-
/**
|
|
6892
|
-
* RegExp are stateful when they have the global or sticky flags set.
|
|
6893
|
-
* But if we actually don't use them, the side effect does not matter.
|
|
6894
|
-
* the check logic in `hasEffectsOnInteractionAtPath`.
|
|
6895
|
-
*/
|
|
6896
|
-
const literalRegExpMembers = assembleMemberDescriptions({
|
|
6897
|
-
exec: returnsUnknown,
|
|
6898
|
-
test: returnsBoolean
|
|
6899
|
-
}, objectMembers);
|
|
6900
|
-
const literalStringMembers = assembleMemberDescriptions({
|
|
6901
|
-
anchor: returnsString,
|
|
6902
|
-
at: returnsUnknown,
|
|
6903
|
-
big: returnsString,
|
|
6904
|
-
blink: returnsString,
|
|
6905
|
-
bold: returnsString,
|
|
6906
|
-
charAt: returnsString,
|
|
6907
|
-
charCodeAt: returnsNumber,
|
|
6908
|
-
codePointAt: returnsUnknown,
|
|
6909
|
-
concat: returnsString,
|
|
6910
|
-
endsWith: returnsBoolean,
|
|
6911
|
-
fixed: returnsString,
|
|
6912
|
-
fontcolor: returnsString,
|
|
6913
|
-
fontsize: returnsString,
|
|
6914
|
-
includes: returnsBoolean,
|
|
6915
|
-
indexOf: returnsNumber,
|
|
6916
|
-
italics: returnsString,
|
|
6917
|
-
lastIndexOf: returnsNumber,
|
|
6918
|
-
link: returnsString,
|
|
6919
|
-
localeCompare: returnsNumber,
|
|
6920
|
-
match: returnsUnknown,
|
|
6921
|
-
matchAll: returnsUnknown,
|
|
6922
|
-
normalize: returnsString,
|
|
6923
|
-
padEnd: returnsString,
|
|
6924
|
-
padStart: returnsString,
|
|
6925
|
-
repeat: returnsString,
|
|
6926
|
-
replace: stringReplace,
|
|
6927
|
-
replaceAll: stringReplace,
|
|
6928
|
-
search: returnsNumber,
|
|
6929
|
-
slice: returnsString,
|
|
6930
|
-
small: returnsString,
|
|
6931
|
-
split: returnsUnknown,
|
|
6932
|
-
startsWith: returnsBoolean,
|
|
6933
|
-
strike: returnsString,
|
|
6934
|
-
sub: returnsString,
|
|
6935
|
-
substr: returnsString,
|
|
6936
|
-
substring: returnsString,
|
|
6937
|
-
sup: returnsString,
|
|
6938
|
-
toLocaleLowerCase: returnsString,
|
|
6939
|
-
toLocaleUpperCase: returnsString,
|
|
6940
|
-
toLowerCase: returnsString,
|
|
6941
|
-
toString: returnsString, // overrides the toString() method of the Object object; it does not inherit Object.prototype.toString()
|
|
6942
|
-
toUpperCase: returnsString,
|
|
6943
|
-
trim: returnsString,
|
|
6944
|
-
trimEnd: returnsString,
|
|
6945
|
-
trimLeft: returnsString,
|
|
6946
|
-
trimRight: returnsString,
|
|
6947
|
-
trimStart: returnsString,
|
|
6948
|
-
valueOf: returnsString
|
|
6949
|
-
}, objectMembers);
|
|
6950
|
-
function getLiteralMembersForValue(value) {
|
|
6951
|
-
if (value instanceof RegExp) {
|
|
6952
|
-
return literalRegExpMembers;
|
|
7024
|
+
shouldBeIncluded(context) {
|
|
7025
|
+
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
6953
7026
|
}
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
7027
|
+
/**
|
|
7028
|
+
* Just deoptimize everything by default so that when e.g. we do not track
|
|
7029
|
+
* something properly, it is deoptimized.
|
|
7030
|
+
* @protected
|
|
7031
|
+
*/
|
|
7032
|
+
applyDeoptimizations() {
|
|
7033
|
+
this.deoptimized = true;
|
|
7034
|
+
for (const key of childNodeKeys[this.type]) {
|
|
7035
|
+
const value = this[key];
|
|
7036
|
+
if (value === null)
|
|
7037
|
+
continue;
|
|
7038
|
+
if (Array.isArray(value)) {
|
|
7039
|
+
for (const child of value) {
|
|
7040
|
+
child?.deoptimizePath(UNKNOWN_PATH);
|
|
7041
|
+
}
|
|
7042
|
+
}
|
|
7043
|
+
else {
|
|
7044
|
+
value.deoptimizePath(UNKNOWN_PATH);
|
|
7045
|
+
}
|
|
6963
7046
|
}
|
|
7047
|
+
this.scope.context.requestTreeshakingPass();
|
|
6964
7048
|
}
|
|
6965
|
-
return Object.create(null);
|
|
6966
7049
|
}
|
|
6967
|
-
function
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false;
|
|
7050
|
+
function onlyIncludeSelf() {
|
|
7051
|
+
this.included = true;
|
|
7052
|
+
if (!this.deoptimized)
|
|
7053
|
+
this.applyDeoptimizations();
|
|
6972
7054
|
}
|
|
6973
|
-
function
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
7055
|
+
function onlyIncludeSelfNoDeoptimize() {
|
|
7056
|
+
this.included = true;
|
|
7057
|
+
}
|
|
7058
|
+
function doNotDeoptimize() {
|
|
7059
|
+
this.deoptimized = true;
|
|
7060
|
+
}
|
|
7061
|
+
|
|
7062
|
+
function isObjectExpressionNode(node) {
|
|
7063
|
+
return node instanceof NodeBase && node.type === parseAst_js.ObjectExpression;
|
|
7064
|
+
}
|
|
7065
|
+
function isArrowFunctionExpressionNode(node) {
|
|
7066
|
+
return node instanceof NodeBase && node.type === parseAst_js.ArrowFunctionExpression;
|
|
7067
|
+
}
|
|
7068
|
+
function isFunctionExpressionNode(node) {
|
|
7069
|
+
return node instanceof NodeBase && node.type === parseAst_js.FunctionExpression;
|
|
7070
|
+
}
|
|
7071
|
+
function isIdentifierNode(node) {
|
|
7072
|
+
return node instanceof NodeBase && node.type === parseAst_js.Identifier;
|
|
6977
7073
|
}
|
|
6978
7074
|
|
|
7075
|
+
// To avoid infinite recursions
|
|
7076
|
+
const MAX_PATH_DEPTH = 6;
|
|
7077
|
+
// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at
|
|
7078
|
+
// most MAX_PATH_DEPTH long. The last element is always UnknownKey
|
|
7079
|
+
const limitConcatenatedPathDepth = (path1, path2) => {
|
|
7080
|
+
const { length: length1 } = path1;
|
|
7081
|
+
const { length: length2 } = path2;
|
|
7082
|
+
return length1 === 0
|
|
7083
|
+
? path2
|
|
7084
|
+
: length2 === 0
|
|
7085
|
+
? path1
|
|
7086
|
+
: length1 + length2 > MAX_PATH_DEPTH
|
|
7087
|
+
? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey']
|
|
7088
|
+
: [...path1, ...path2];
|
|
7089
|
+
};
|
|
7090
|
+
|
|
6979
7091
|
class Variable extends ExpressionEntity {
|
|
6980
7092
|
markReassigned() {
|
|
6981
7093
|
this.isReassigned = true;
|
|
6982
7094
|
}
|
|
7095
|
+
markTargetOfAssignment() {
|
|
7096
|
+
this.isTargetOfAssignment = true;
|
|
7097
|
+
}
|
|
6983
7098
|
constructor(name) {
|
|
6984
7099
|
super();
|
|
6985
7100
|
this.name = name;
|
|
@@ -6992,6 +7107,9 @@ class Variable extends ExpressionEntity {
|
|
|
6992
7107
|
this.renderBaseName = null;
|
|
6993
7108
|
this.renderName = null;
|
|
6994
7109
|
this.isReassigned = false;
|
|
7110
|
+
// Unlike isReassigned, set eagerly during binding for every assignment,
|
|
7111
|
+
// including ones that are never included
|
|
7112
|
+
this.isTargetOfAssignment = false;
|
|
6995
7113
|
this.onlyFunctionCallUsed = true;
|
|
6996
7114
|
}
|
|
6997
7115
|
/**
|
|
@@ -7080,10 +7198,9 @@ class LocalVariable extends Variable {
|
|
|
7080
7198
|
this.kind = kind;
|
|
7081
7199
|
this.calledFromTryStatement = false;
|
|
7082
7200
|
this.additionalInitializers = null;
|
|
7083
|
-
// A possibly incomplete list of
|
|
7084
|
-
//
|
|
7085
|
-
|
|
7086
|
-
this.reassignedValues = null;
|
|
7201
|
+
// A possibly incomplete list of functions assigned to this variable; only used
|
|
7202
|
+
// to retain call arguments of assigned try-catch helpers, never for value queries
|
|
7203
|
+
this.assignedFunctions = null;
|
|
7087
7204
|
this.includedPathTracker = new IncludedFullPathTracker();
|
|
7088
7205
|
this.expressionsToBeDeoptimized = [];
|
|
7089
7206
|
this.declarations = declarator ? [declarator] : [];
|
|
@@ -7209,16 +7326,12 @@ class LocalVariable extends Variable {
|
|
|
7209
7326
|
}
|
|
7210
7327
|
includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
|
|
7211
7328
|
if (this.isReassigned) {
|
|
7212
|
-
//
|
|
7213
|
-
//
|
|
7329
|
+
// The value may still be one of the assigned functions, whose try-catch
|
|
7330
|
+
// helpers need their call arguments retained
|
|
7214
7331
|
includeInteraction(interaction, context);
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
const previousTracker = context.includedCallArgumentsOfPossibleValues;
|
|
7219
|
-
context.includedCallArgumentsOfPossibleValues ??= new DiscriminatedPathTracker();
|
|
7220
|
-
this.includeCallArgumentsOfPossibleValues(path, interaction, context, context.includedCallArgumentsOfPossibleValues);
|
|
7221
|
-
context.includedCallArgumentsOfPossibleValues = previousTracker;
|
|
7332
|
+
if (path.length === 0) {
|
|
7333
|
+
this.includeCallArgumentsOfAssignedTryCatchHelpers(interaction, context);
|
|
7334
|
+
}
|
|
7222
7335
|
return;
|
|
7223
7336
|
}
|
|
7224
7337
|
if (context.includedCallArguments.has(this.init) ||
|
|
@@ -7230,25 +7343,25 @@ class LocalVariable extends Variable {
|
|
|
7230
7343
|
this.init.includeCallArgumentsWhenCalledAtPath([...this.initPath, ...path], interaction, context);
|
|
7231
7344
|
context.includedCallArguments.delete(this.init);
|
|
7232
7345
|
}
|
|
7233
|
-
|
|
7234
|
-
if (this.
|
|
7235
|
-
|
|
7346
|
+
includeCallArgumentsOfAssignedTryCatchHelpers(interaction, context) {
|
|
7347
|
+
if (this.initPath.length === 0) {
|
|
7348
|
+
this.includeCallArgumentsOfTryCatchHelper(this.init, interaction, context);
|
|
7236
7349
|
}
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
this.includeCallArgumentsOfPossibleValue(entity, path, interaction, context, tracker);
|
|
7350
|
+
for (const assignedFunction of this.assignedFunctions ?? parseAst_js.EMPTY_ARRAY) {
|
|
7351
|
+
this.includeCallArgumentsOfTryCatchHelper(assignedFunction, interaction, context);
|
|
7240
7352
|
}
|
|
7241
7353
|
}
|
|
7242
|
-
|
|
7243
|
-
if (
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7354
|
+
includeCallArgumentsOfTryCatchHelper(value, interaction, context) {
|
|
7355
|
+
if (isArrowFunctionExpressionNode(value) || isFunctionExpressionNode(value)) {
|
|
7356
|
+
if (value.scope.hasParameterCalledFromTryStatement()) {
|
|
7357
|
+
value.scope.includeCallArguments(interaction, context);
|
|
7358
|
+
}
|
|
7247
7359
|
}
|
|
7248
|
-
entity.includeCallArgumentsWhenCalledAtPath(path, interaction, context);
|
|
7249
7360
|
}
|
|
7250
7361
|
addReassignedValue(value) {
|
|
7251
|
-
(
|
|
7362
|
+
if (isArrowFunctionExpressionNode(value) || isFunctionExpressionNode(value)) {
|
|
7363
|
+
(this.assignedFunctions ??= []).push(value);
|
|
7364
|
+
}
|
|
7252
7365
|
}
|
|
7253
7366
|
markCalledFromTryStatement() {
|
|
7254
7367
|
this.calledFromTryStatement = true;
|
|
@@ -7461,37 +7574,6 @@ function is_reference(node, parent) {
|
|
|
7461
7574
|
}
|
|
7462
7575
|
}
|
|
7463
7576
|
|
|
7464
|
-
function createInclusionContext() {
|
|
7465
|
-
return {
|
|
7466
|
-
brokenFlow: false,
|
|
7467
|
-
hasBreak: false,
|
|
7468
|
-
hasContinue: false,
|
|
7469
|
-
includedCallArguments: new Set(),
|
|
7470
|
-
includedCallArgumentsOfPossibleValues: null,
|
|
7471
|
-
includedLabels: new Set()
|
|
7472
|
-
};
|
|
7473
|
-
}
|
|
7474
|
-
function createHasEffectsContext() {
|
|
7475
|
-
return {
|
|
7476
|
-
accessed: new EntityPathTracker(),
|
|
7477
|
-
assigned: new EntityPathTracker(),
|
|
7478
|
-
brokenFlow: false,
|
|
7479
|
-
called: new DiscriminatedPathTracker(),
|
|
7480
|
-
hasBreak: false,
|
|
7481
|
-
hasContinue: false,
|
|
7482
|
-
ignore: {
|
|
7483
|
-
breaks: false,
|
|
7484
|
-
continues: false,
|
|
7485
|
-
labels: new Set(),
|
|
7486
|
-
returnYield: false,
|
|
7487
|
-
this: false
|
|
7488
|
-
},
|
|
7489
|
-
includedLabels: new Set(),
|
|
7490
|
-
instantiated: new DiscriminatedPathTracker(),
|
|
7491
|
-
replacedVariableInits: new Map()
|
|
7492
|
-
};
|
|
7493
|
-
}
|
|
7494
|
-
|
|
7495
7577
|
const PureFunctionKey = Symbol('PureFunction');
|
|
7496
7578
|
const getPureFunctions = ({ treeshake }) => {
|
|
7497
7579
|
const pureFunctions = Object.create(null);
|
|
@@ -7684,297 +7766,215 @@ function markModuleAndImpureDependenciesAsExecuted(baseModule) {
|
|
|
7684
7766
|
if (!(dependency instanceof ExternalModule) &&
|
|
7685
7767
|
!dependency.isExecuted &&
|
|
7686
7768
|
(dependency.info.moduleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
|
|
7687
|
-
!visitedModules.has(dependency.id)) {
|
|
7688
|
-
dependency.isExecuted = true;
|
|
7689
|
-
visitedModules.add(dependency.id);
|
|
7690
|
-
modules.push(dependency);
|
|
7691
|
-
}
|
|
7692
|
-
}
|
|
7693
|
-
}
|
|
7694
|
-
}
|
|
7695
|
-
|
|
7696
|
-
// This file is generated by scripts/generate-child-node-keys.ts.
|
|
7697
|
-
// Do not edit this file directly.
|
|
7698
|
-
const childNodeKeys = {
|
|
7699
|
-
ArrayExpression: ['elements'],
|
|
7700
|
-
ArrayPattern: ['elements'],
|
|
7701
|
-
ArrowFunctionExpression: ['params', 'body'],
|
|
7702
|
-
AssignmentExpression: ['left', 'right'],
|
|
7703
|
-
AssignmentPattern: ['left', 'right'],
|
|
7704
|
-
AwaitExpression: ['argument'],
|
|
7705
|
-
BinaryExpression: ['left', 'right'],
|
|
7706
|
-
BlockStatement: ['body'],
|
|
7707
|
-
BreakStatement: ['label'],
|
|
7708
|
-
CallExpression: ['callee', 'arguments'],
|
|
7709
|
-
CatchClause: ['param', 'body'],
|
|
7710
|
-
ChainExpression: ['expression'],
|
|
7711
|
-
ClassBody: ['body'],
|
|
7712
|
-
ClassDeclaration: ['decorators', 'id', 'superClass', 'body'],
|
|
7713
|
-
ClassExpression: ['decorators', 'id', 'superClass', 'body'],
|
|
7714
|
-
ConditionalExpression: ['test', 'consequent', 'alternate'],
|
|
7715
|
-
ContinueStatement: ['label'],
|
|
7716
|
-
DebuggerStatement: [],
|
|
7717
|
-
Decorator: ['expression'],
|
|
7718
|
-
DoWhileStatement: ['body', 'test'],
|
|
7719
|
-
EmptyStatement: [],
|
|
7720
|
-
ExportAllDeclaration: ['exported', 'source', 'attributes'],
|
|
7721
|
-
ExportDefaultDeclaration: ['declaration'],
|
|
7722
|
-
ExportNamedDeclaration: ['specifiers', 'source', 'attributes', 'declaration'],
|
|
7723
|
-
ExportSpecifier: ['local', 'exported'],
|
|
7724
|
-
ExpressionStatement: ['expression'],
|
|
7725
|
-
ForInStatement: ['left', 'right', 'body'],
|
|
7726
|
-
ForOfStatement: ['left', 'right', 'body'],
|
|
7727
|
-
ForStatement: ['init', 'test', 'update', 'body'],
|
|
7728
|
-
FunctionDeclaration: ['id', 'params', 'body'],
|
|
7729
|
-
FunctionExpression: ['id', 'params', 'body'],
|
|
7730
|
-
Identifier: [],
|
|
7731
|
-
IfStatement: ['test', 'consequent', 'alternate'],
|
|
7732
|
-
ImportAttribute: ['key', 'value'],
|
|
7733
|
-
ImportDeclaration: ['specifiers', 'source', 'attributes'],
|
|
7734
|
-
ImportDefaultSpecifier: ['local'],
|
|
7735
|
-
ImportExpression: ['source', 'options'],
|
|
7736
|
-
ImportNamespaceSpecifier: ['local'],
|
|
7737
|
-
ImportSpecifier: ['imported', 'local'],
|
|
7738
|
-
JSXAttribute: ['name', 'value'],
|
|
7739
|
-
JSXClosingElement: ['name'],
|
|
7740
|
-
JSXClosingFragment: [],
|
|
7741
|
-
JSXElement: ['openingElement', 'children', 'closingElement'],
|
|
7742
|
-
JSXEmptyExpression: [],
|
|
7743
|
-
JSXExpressionContainer: ['expression'],
|
|
7744
|
-
JSXFragment: ['openingFragment', 'children', 'closingFragment'],
|
|
7745
|
-
JSXIdentifier: [],
|
|
7746
|
-
JSXMemberExpression: ['object', 'property'],
|
|
7747
|
-
JSXNamespacedName: ['namespace', 'name'],
|
|
7748
|
-
JSXOpeningElement: ['name', 'attributes'],
|
|
7749
|
-
JSXOpeningFragment: [],
|
|
7750
|
-
JSXSpreadAttribute: ['argument'],
|
|
7751
|
-
JSXSpreadChild: ['expression'],
|
|
7752
|
-
JSXText: [],
|
|
7753
|
-
LabeledStatement: ['label', 'body'],
|
|
7754
|
-
Literal: [],
|
|
7755
|
-
LogicalExpression: ['left', 'right'],
|
|
7756
|
-
MemberExpression: ['object', 'property'],
|
|
7757
|
-
MetaProperty: ['meta', 'property'],
|
|
7758
|
-
MethodDefinition: ['decorators', 'key', 'value'],
|
|
7759
|
-
NewExpression: ['callee', 'arguments'],
|
|
7760
|
-
ObjectExpression: ['properties'],
|
|
7761
|
-
ObjectPattern: ['properties'],
|
|
7762
|
-
PanicError: [],
|
|
7763
|
-
ParseError: [],
|
|
7764
|
-
PrivateIdentifier: [],
|
|
7765
|
-
Program: ['body'],
|
|
7766
|
-
Property: ['key', 'value'],
|
|
7767
|
-
PropertyDefinition: ['decorators', 'key', 'value'],
|
|
7768
|
-
RestElement: ['argument'],
|
|
7769
|
-
ReturnStatement: ['argument'],
|
|
7770
|
-
SequenceExpression: ['expressions'],
|
|
7771
|
-
SpreadElement: ['argument'],
|
|
7772
|
-
StaticBlock: ['body'],
|
|
7773
|
-
Super: [],
|
|
7774
|
-
SwitchCase: ['test', 'consequent'],
|
|
7775
|
-
SwitchStatement: ['discriminant', 'cases'],
|
|
7776
|
-
TaggedTemplateExpression: ['tag', 'quasi'],
|
|
7777
|
-
TemplateElement: [],
|
|
7778
|
-
TemplateLiteral: ['quasis', 'expressions'],
|
|
7779
|
-
ThisExpression: [],
|
|
7780
|
-
ThrowStatement: ['argument'],
|
|
7781
|
-
TryStatement: ['block', 'handler', 'finalizer'],
|
|
7782
|
-
UnaryExpression: ['argument'],
|
|
7783
|
-
UpdateExpression: ['argument'],
|
|
7784
|
-
VariableDeclaration: ['declarations'],
|
|
7785
|
-
VariableDeclarator: ['id', 'init'],
|
|
7786
|
-
WhileStatement: ['test', 'body'],
|
|
7787
|
-
YieldExpression: ['argument']
|
|
7788
|
-
};
|
|
7789
|
-
|
|
7790
|
-
const INCLUDE_PARAMETERS = 'variables';
|
|
7791
|
-
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
7792
|
-
class NodeBase extends ExpressionEntity {
|
|
7793
|
-
/**
|
|
7794
|
-
* Nodes can apply custom deoptimizations once they become part of the
|
|
7795
|
-
* executed code. To do this, they must initialize this as false, implement
|
|
7796
|
-
* applyDeoptimizations and call this from include and hasEffects if they have
|
|
7797
|
-
* custom handlers
|
|
7798
|
-
*/
|
|
7799
|
-
get deoptimized() {
|
|
7800
|
-
return isFlagSet(this.flags, 2 /* Flag.deoptimized */);
|
|
7801
|
-
}
|
|
7802
|
-
set deoptimized(value) {
|
|
7803
|
-
this.flags = setFlag(this.flags, 2 /* Flag.deoptimized */, value);
|
|
7804
|
-
}
|
|
7805
|
-
constructor(parent, parentScope) {
|
|
7806
|
-
super();
|
|
7807
|
-
this.parent = parent;
|
|
7808
|
-
this.scope = parentScope;
|
|
7809
|
-
this.createScope(parentScope);
|
|
7810
|
-
}
|
|
7811
|
-
addExportedVariables(_variables, _exportNamesByVariable) { }
|
|
7812
|
-
/**
|
|
7813
|
-
* Override this to bind assignments to variables and do any initialisations
|
|
7814
|
-
* that require the scopes to be populated with variables.
|
|
7815
|
-
*/
|
|
7816
|
-
bind() {
|
|
7817
|
-
for (const key of childNodeKeys[this.type]) {
|
|
7818
|
-
const value = this[key];
|
|
7819
|
-
if (Array.isArray(value)) {
|
|
7820
|
-
for (const child of value) {
|
|
7821
|
-
child?.bind();
|
|
7822
|
-
}
|
|
7823
|
-
}
|
|
7824
|
-
else if (value) {
|
|
7825
|
-
value.bind();
|
|
7826
|
-
}
|
|
7827
|
-
}
|
|
7828
|
-
}
|
|
7829
|
-
/**
|
|
7830
|
-
* Override if this node should receive a different scope than the parent
|
|
7831
|
-
* scope.
|
|
7832
|
-
*/
|
|
7833
|
-
createScope(parentScope) {
|
|
7834
|
-
this.scope = parentScope;
|
|
7835
|
-
}
|
|
7836
|
-
hasEffects(context) {
|
|
7837
|
-
if (!this.deoptimized)
|
|
7838
|
-
this.applyDeoptimizations();
|
|
7839
|
-
for (const key of childNodeKeys[this.type]) {
|
|
7840
|
-
const value = this[key];
|
|
7841
|
-
if (value === null)
|
|
7842
|
-
continue;
|
|
7843
|
-
if (Array.isArray(value)) {
|
|
7844
|
-
for (const child of value) {
|
|
7845
|
-
if (child?.hasEffects(context))
|
|
7846
|
-
return true;
|
|
7847
|
-
}
|
|
7769
|
+
!visitedModules.has(dependency.id)) {
|
|
7770
|
+
dependency.isExecuted = true;
|
|
7771
|
+
visitedModules.add(dependency.id);
|
|
7772
|
+
modules.push(dependency);
|
|
7848
7773
|
}
|
|
7849
|
-
else if (value.hasEffects(context))
|
|
7850
|
-
return true;
|
|
7851
7774
|
}
|
|
7852
|
-
return false;
|
|
7853
7775
|
}
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7776
|
+
}
|
|
7777
|
+
|
|
7778
|
+
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
7779
|
+
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
7780
|
+
}
|
|
7781
|
+
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
7782
|
+
getLiteralValueAtPath(path) {
|
|
7783
|
+
return path.length > 0 ? UnknownValue : undefined;
|
|
7857
7784
|
}
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
}
|
|
7870
|
-
else {
|
|
7871
|
-
value.include(context, includeChildrenRecursively);
|
|
7872
|
-
}
|
|
7785
|
+
})();
|
|
7786
|
+
const returnsUnknown = {
|
|
7787
|
+
value: {
|
|
7788
|
+
hasEffectsWhenCalled: null,
|
|
7789
|
+
returns: UNKNOWN_EXPRESSION
|
|
7790
|
+
}
|
|
7791
|
+
};
|
|
7792
|
+
const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEntity {
|
|
7793
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
7794
|
+
if (path.length === 1) {
|
|
7795
|
+
return getMemberReturnExpressionWhenCalled(literalBooleanMembers, path[0]);
|
|
7873
7796
|
}
|
|
7797
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
7874
7798
|
}
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
this.applyDeoptimizations();
|
|
7879
|
-
for (const key of childNodeKeys[this.type]) {
|
|
7880
|
-
const value = this[key];
|
|
7881
|
-
if (value === null)
|
|
7882
|
-
continue;
|
|
7883
|
-
if (Array.isArray(value)) {
|
|
7884
|
-
for (const child of value) {
|
|
7885
|
-
child?.includePath(UNKNOWN_PATH, context);
|
|
7886
|
-
}
|
|
7887
|
-
}
|
|
7888
|
-
else {
|
|
7889
|
-
value.includePath(UNKNOWN_PATH, context);
|
|
7890
|
-
}
|
|
7799
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7800
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
7801
|
+
return path.length > 1;
|
|
7891
7802
|
}
|
|
7803
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
7804
|
+
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0], interaction, context);
|
|
7805
|
+
}
|
|
7806
|
+
return true;
|
|
7892
7807
|
}
|
|
7893
|
-
|
|
7894
|
-
|
|
7808
|
+
})();
|
|
7809
|
+
const returnsBoolean = {
|
|
7810
|
+
value: {
|
|
7811
|
+
hasEffectsWhenCalled: null,
|
|
7812
|
+
returns: UNKNOWN_LITERAL_BOOLEAN
|
|
7895
7813
|
}
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7814
|
+
};
|
|
7815
|
+
const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity {
|
|
7816
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
7817
|
+
if (path.length === 1) {
|
|
7818
|
+
return getMemberReturnExpressionWhenCalled(literalNumberMembers, path[0]);
|
|
7819
|
+
}
|
|
7820
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
7903
7821
|
}
|
|
7904
|
-
|
|
7905
|
-
if (
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7822
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7823
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
7824
|
+
return path.length > 1;
|
|
7825
|
+
}
|
|
7826
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
7827
|
+
return hasMemberEffectWhenCalled(literalNumberMembers, path[0], interaction, context);
|
|
7909
7828
|
}
|
|
7829
|
+
return true;
|
|
7910
7830
|
}
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
value.render(code, options);
|
|
7923
|
-
}
|
|
7831
|
+
})();
|
|
7832
|
+
const returnsNumber = {
|
|
7833
|
+
value: {
|
|
7834
|
+
hasEffectsWhenCalled: null,
|
|
7835
|
+
returns: UNKNOWN_LITERAL_NUMBER
|
|
7836
|
+
}
|
|
7837
|
+
};
|
|
7838
|
+
const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity {
|
|
7839
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
7840
|
+
if (path.length === 1) {
|
|
7841
|
+
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
7924
7842
|
}
|
|
7843
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
7925
7844
|
}
|
|
7926
|
-
|
|
7927
|
-
|
|
7845
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7846
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
7847
|
+
return path.length > 1;
|
|
7848
|
+
}
|
|
7849
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
7850
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
7851
|
+
}
|
|
7852
|
+
return true;
|
|
7928
7853
|
}
|
|
7929
|
-
|
|
7930
|
-
|
|
7854
|
+
})();
|
|
7855
|
+
const returnsString = {
|
|
7856
|
+
value: {
|
|
7857
|
+
hasEffectsWhenCalled: null,
|
|
7858
|
+
returns: UNKNOWN_LITERAL_STRING
|
|
7931
7859
|
}
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7860
|
+
};
|
|
7861
|
+
const stringReplace = {
|
|
7862
|
+
value: {
|
|
7863
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
7864
|
+
const argument1 = args[2];
|
|
7865
|
+
return (args.length < 3 ||
|
|
7866
|
+
(typeof argument1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
7867
|
+
deoptimizeCache() { }
|
|
7868
|
+
}) === 'symbol' &&
|
|
7869
|
+
argument1.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)));
|
|
7870
|
+
},
|
|
7871
|
+
returns: UNKNOWN_LITERAL_STRING
|
|
7872
|
+
}
|
|
7873
|
+
};
|
|
7874
|
+
const objectMembers = assembleMemberDescriptions({
|
|
7875
|
+
hasOwnProperty: returnsBoolean,
|
|
7876
|
+
isPrototypeOf: returnsBoolean,
|
|
7877
|
+
propertyIsEnumerable: returnsBoolean,
|
|
7878
|
+
toLocaleString: returnsString,
|
|
7879
|
+
toString: returnsString,
|
|
7880
|
+
valueOf: returnsUnknown
|
|
7881
|
+
});
|
|
7882
|
+
const literalBooleanMembers = assembleMemberDescriptions({
|
|
7883
|
+
valueOf: returnsBoolean
|
|
7884
|
+
}, objectMembers);
|
|
7885
|
+
const literalNumberMembers = assembleMemberDescriptions({
|
|
7886
|
+
toExponential: returnsString,
|
|
7887
|
+
toFixed: returnsString,
|
|
7888
|
+
toLocaleString: returnsString,
|
|
7889
|
+
toPrecision: returnsString,
|
|
7890
|
+
valueOf: returnsNumber
|
|
7891
|
+
}, objectMembers);
|
|
7892
|
+
/**
|
|
7893
|
+
* RegExp are stateful when they have the global or sticky flags set.
|
|
7894
|
+
* But if we actually don't use them, the side effect does not matter.
|
|
7895
|
+
* the check logic in `hasEffectsOnInteractionAtPath`.
|
|
7896
|
+
*/
|
|
7897
|
+
const literalRegExpMembers = assembleMemberDescriptions({
|
|
7898
|
+
exec: returnsUnknown,
|
|
7899
|
+
test: returnsBoolean
|
|
7900
|
+
}, objectMembers);
|
|
7901
|
+
const literalStringMembers = assembleMemberDescriptions({
|
|
7902
|
+
anchor: returnsString,
|
|
7903
|
+
at: returnsUnknown,
|
|
7904
|
+
big: returnsString,
|
|
7905
|
+
blink: returnsString,
|
|
7906
|
+
bold: returnsString,
|
|
7907
|
+
charAt: returnsString,
|
|
7908
|
+
charCodeAt: returnsNumber,
|
|
7909
|
+
codePointAt: returnsUnknown,
|
|
7910
|
+
concat: returnsString,
|
|
7911
|
+
endsWith: returnsBoolean,
|
|
7912
|
+
fixed: returnsString,
|
|
7913
|
+
fontcolor: returnsString,
|
|
7914
|
+
fontsize: returnsString,
|
|
7915
|
+
includes: returnsBoolean,
|
|
7916
|
+
indexOf: returnsNumber,
|
|
7917
|
+
italics: returnsString,
|
|
7918
|
+
lastIndexOf: returnsNumber,
|
|
7919
|
+
link: returnsString,
|
|
7920
|
+
localeCompare: returnsNumber,
|
|
7921
|
+
match: returnsUnknown,
|
|
7922
|
+
matchAll: returnsUnknown,
|
|
7923
|
+
normalize: returnsString,
|
|
7924
|
+
padEnd: returnsString,
|
|
7925
|
+
padStart: returnsString,
|
|
7926
|
+
repeat: returnsString,
|
|
7927
|
+
replace: stringReplace,
|
|
7928
|
+
replaceAll: stringReplace,
|
|
7929
|
+
search: returnsNumber,
|
|
7930
|
+
slice: returnsString,
|
|
7931
|
+
small: returnsString,
|
|
7932
|
+
split: returnsUnknown,
|
|
7933
|
+
startsWith: returnsBoolean,
|
|
7934
|
+
strike: returnsString,
|
|
7935
|
+
sub: returnsString,
|
|
7936
|
+
substr: returnsString,
|
|
7937
|
+
substring: returnsString,
|
|
7938
|
+
sup: returnsString,
|
|
7939
|
+
toLocaleLowerCase: returnsString,
|
|
7940
|
+
toLocaleUpperCase: returnsString,
|
|
7941
|
+
toLowerCase: returnsString,
|
|
7942
|
+
toString: returnsString, // overrides the toString() method of the Object object; it does not inherit Object.prototype.toString()
|
|
7943
|
+
toUpperCase: returnsString,
|
|
7944
|
+
trim: returnsString,
|
|
7945
|
+
trimEnd: returnsString,
|
|
7946
|
+
trimLeft: returnsString,
|
|
7947
|
+
trimRight: returnsString,
|
|
7948
|
+
trimStart: returnsString,
|
|
7949
|
+
valueOf: returnsString
|
|
7950
|
+
}, objectMembers);
|
|
7951
|
+
function getLiteralMembersForValue(value) {
|
|
7952
|
+
if (value instanceof RegExp) {
|
|
7953
|
+
return literalRegExpMembers;
|
|
7954
|
+
}
|
|
7955
|
+
switch (typeof value) {
|
|
7956
|
+
case 'boolean': {
|
|
7957
|
+
return literalBooleanMembers;
|
|
7958
|
+
}
|
|
7959
|
+
case 'number': {
|
|
7960
|
+
return literalNumberMembers;
|
|
7961
|
+
}
|
|
7962
|
+
case 'string': {
|
|
7963
|
+
return literalStringMembers;
|
|
7951
7964
|
}
|
|
7952
|
-
this.scope.context.requestTreeshakingPass();
|
|
7953
7965
|
}
|
|
7966
|
+
return Object.create(null);
|
|
7954
7967
|
}
|
|
7955
|
-
function
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
function onlyIncludeSelfNoDeoptimize() {
|
|
7961
|
-
this.included = true;
|
|
7962
|
-
}
|
|
7963
|
-
function doNotDeoptimize() {
|
|
7964
|
-
this.deoptimized = true;
|
|
7965
|
-
}
|
|
7966
|
-
|
|
7967
|
-
function isObjectExpressionNode(node) {
|
|
7968
|
-
return node instanceof NodeBase && node.type === parseAst_js.ObjectExpression;
|
|
7969
|
-
}
|
|
7970
|
-
function isArrowFunctionExpressionNode(node) {
|
|
7971
|
-
return node instanceof NodeBase && node.type === parseAst_js.ArrowFunctionExpression;
|
|
7972
|
-
}
|
|
7973
|
-
function isFunctionExpressionNode(node) {
|
|
7974
|
-
return node instanceof NodeBase && node.type === parseAst_js.FunctionExpression;
|
|
7968
|
+
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
7969
|
+
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
7970
|
+
return true;
|
|
7971
|
+
}
|
|
7972
|
+
return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false;
|
|
7975
7973
|
}
|
|
7976
|
-
function
|
|
7977
|
-
|
|
7974
|
+
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
7975
|
+
if (typeof memberName !== 'string' || !members[memberName])
|
|
7976
|
+
return UNKNOWN_RETURN_EXPRESSION;
|
|
7977
|
+
return [members[memberName].returns, false];
|
|
7978
7978
|
}
|
|
7979
7979
|
|
|
7980
7980
|
class Method extends ExpressionEntity {
|
|
@@ -8814,6 +8814,18 @@ const PURE_WITH_ARRAY = {
|
|
|
8814
8814
|
return args.length > 1 && !(args[1] instanceof ArrayExpression);
|
|
8815
8815
|
}
|
|
8816
8816
|
};
|
|
8817
|
+
const PURE_WITH_ARRAY_OR_LENGTH = {
|
|
8818
|
+
deoptimizeArgumentsOnCall: doNothing,
|
|
8819
|
+
getLiteralValue: getUnknownValue,
|
|
8820
|
+
hasEffectsWhenCalled({ args }) {
|
|
8821
|
+
const [_thisArgument, firstArgument] = args;
|
|
8822
|
+
return (firstArgument !== undefined &&
|
|
8823
|
+
!(firstArgument instanceof ArrayExpression) &&
|
|
8824
|
+
typeof firstArgument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
8825
|
+
deoptimizeCache: doNothing
|
|
8826
|
+
}) !== 'number');
|
|
8827
|
+
}
|
|
8828
|
+
};
|
|
8817
8829
|
const GETTER_ACCESS = {
|
|
8818
8830
|
deoptimizeArgumentsOnCall: doNothing,
|
|
8819
8831
|
getLiteralValue: getUnknownValue,
|
|
@@ -8872,7 +8884,7 @@ const PC_WITH_ARRAY = {
|
|
|
8872
8884
|
};
|
|
8873
8885
|
const ARRAY_TYPE = {
|
|
8874
8886
|
__proto__: null,
|
|
8875
|
-
[ValueProperties]:
|
|
8887
|
+
[ValueProperties]: PURE_WITH_ARRAY_OR_LENGTH,
|
|
8876
8888
|
from: O,
|
|
8877
8889
|
of: PF,
|
|
8878
8890
|
prototype: O
|
|
@@ -10040,6 +10052,9 @@ class Identifier extends IdentifierBase {
|
|
|
10040
10052
|
this.variable = this.scope.findVariable(this.name);
|
|
10041
10053
|
this.variable.addReference(this);
|
|
10042
10054
|
this.isVariableReference = true;
|
|
10055
|
+
if (this.assignmentInteraction) {
|
|
10056
|
+
this.variable.markTargetOfAssignment();
|
|
10057
|
+
}
|
|
10043
10058
|
}
|
|
10044
10059
|
}
|
|
10045
10060
|
declare(kind, destructuredInitPath, init) {
|
|
@@ -10206,9 +10221,51 @@ class MethodDefinition extends PropertyBase {
|
|
|
10206
10221
|
}
|
|
10207
10222
|
}
|
|
10208
10223
|
|
|
10224
|
+
class PropertyDefinition extends NodeBase {
|
|
10225
|
+
get computed() {
|
|
10226
|
+
return isFlagSet(this.flags, 1024 /* Flag.computed */);
|
|
10227
|
+
}
|
|
10228
|
+
set computed(value) {
|
|
10229
|
+
this.flags = setFlag(this.flags, 1024 /* Flag.computed */, value);
|
|
10230
|
+
}
|
|
10231
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10232
|
+
this.value?.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10233
|
+
}
|
|
10234
|
+
deoptimizePath(path) {
|
|
10235
|
+
this.value?.deoptimizePath(path);
|
|
10236
|
+
}
|
|
10237
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
10238
|
+
return this.value
|
|
10239
|
+
? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
|
|
10240
|
+
: UnknownValue;
|
|
10241
|
+
}
|
|
10242
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10243
|
+
return this.value
|
|
10244
|
+
? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
10245
|
+
: UNKNOWN_RETURN_EXPRESSION;
|
|
10246
|
+
}
|
|
10247
|
+
hasEffects(context) {
|
|
10248
|
+
return (this.key.hasEffects(context) ||
|
|
10249
|
+
(this.static && !!this.value?.hasEffects(context)) ||
|
|
10250
|
+
checkEffectForNodes(this.decorators, context));
|
|
10251
|
+
}
|
|
10252
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10253
|
+
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
10254
|
+
}
|
|
10255
|
+
includeNode(context) {
|
|
10256
|
+
this.included = true;
|
|
10257
|
+
this.value?.includePath(UNKNOWN_PATH, context);
|
|
10258
|
+
for (const decorator of this.decorators) {
|
|
10259
|
+
decorator.includePath(UNKNOWN_PATH, context);
|
|
10260
|
+
}
|
|
10261
|
+
}
|
|
10262
|
+
}
|
|
10263
|
+
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
10264
|
+
|
|
10209
10265
|
class ClassNode extends NodeBase {
|
|
10210
10266
|
constructor() {
|
|
10211
10267
|
super(...arguments);
|
|
10268
|
+
this.instanceFieldValues = null;
|
|
10212
10269
|
this.objectEntity = null;
|
|
10213
10270
|
}
|
|
10214
10271
|
createScope(parentScope) {
|
|
@@ -10242,7 +10299,7 @@ class ClassNode extends NodeBase {
|
|
|
10242
10299
|
(this.classConstructor === null
|
|
10243
10300
|
? this.superClass?.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
10244
10301
|
: this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
|
|
10245
|
-
|
|
10302
|
+
this.hasEffectsOnInstanceFieldInitialization(context)
|
|
10246
10303
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
10247
10304
|
}
|
|
10248
10305
|
include(context, includeChildrenRecursively) {
|
|
@@ -10260,6 +10317,10 @@ class ClassNode extends NodeBase {
|
|
|
10260
10317
|
initialise() {
|
|
10261
10318
|
super.initialise();
|
|
10262
10319
|
this.id?.declare('class', EMPTY_PATH, this);
|
|
10320
|
+
this.instanceEntity = new ObjectEntity(new Map(), new ObjectMember(this, ['prototype']));
|
|
10321
|
+
// This makes sure that all deoptimizations of "this" are applied to the
|
|
10322
|
+
// instance entity, even if the class is only instantiated by unknown code.
|
|
10323
|
+
this.body.scope.instanceThisVariable.addArgumentForDeoptimization(this.instanceEntity);
|
|
10263
10324
|
for (const method of this.body.body) {
|
|
10264
10325
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
10265
10326
|
this.classConstructor = method;
|
|
@@ -10280,6 +10341,36 @@ class ClassNode extends NodeBase {
|
|
|
10280
10341
|
}
|
|
10281
10342
|
this.scope.context.requestTreeshakingPass();
|
|
10282
10343
|
}
|
|
10344
|
+
hasEffectsOnInstanceFieldInitialization(context) {
|
|
10345
|
+
const fieldValues = this.getInstanceFieldValues();
|
|
10346
|
+
if (fieldValues.length === 0)
|
|
10347
|
+
return false;
|
|
10348
|
+
const { replacedVariableInits } = context;
|
|
10349
|
+
const thisVariable = this.body.scope.instanceThisVariable;
|
|
10350
|
+
const thisInit = replacedVariableInits.get(thisVariable);
|
|
10351
|
+
replacedVariableInits.set(thisVariable, this.instanceEntity);
|
|
10352
|
+
const hasEffects = fieldValues.some(value => value.hasEffects(context));
|
|
10353
|
+
if (thisInit) {
|
|
10354
|
+
replacedVariableInits.set(thisVariable, thisInit);
|
|
10355
|
+
}
|
|
10356
|
+
else {
|
|
10357
|
+
replacedVariableInits.delete(thisVariable);
|
|
10358
|
+
}
|
|
10359
|
+
return hasEffects;
|
|
10360
|
+
}
|
|
10361
|
+
getInstanceFieldValues() {
|
|
10362
|
+
if (this.instanceFieldValues === null) {
|
|
10363
|
+
this.instanceFieldValues = [];
|
|
10364
|
+
for (const definition of this.body.body) {
|
|
10365
|
+
if (definition instanceof PropertyDefinition &&
|
|
10366
|
+
!definition.static &&
|
|
10367
|
+
definition.value !== null) {
|
|
10368
|
+
this.instanceFieldValues.push(definition.value);
|
|
10369
|
+
}
|
|
10370
|
+
}
|
|
10371
|
+
}
|
|
10372
|
+
return this.instanceFieldValues;
|
|
10373
|
+
}
|
|
10283
10374
|
getObjectEntity() {
|
|
10284
10375
|
if (this.objectEntity !== null) {
|
|
10285
10376
|
return this.objectEntity;
|
|
@@ -10600,6 +10691,31 @@ class ThisVariable extends ParameterVariable {
|
|
|
10600
10691
|
}
|
|
10601
10692
|
}
|
|
10602
10693
|
|
|
10694
|
+
/**
|
|
10695
|
+
* Represents the return value of a function where all return statements return
|
|
10696
|
+
* the same variable that is the target of an assignment. As the assigned value
|
|
10697
|
+
* may replace the declaration initializer before the function returns, value
|
|
10698
|
+
* queries resolve to unknown, and call arguments are deoptimized directly
|
|
10699
|
+
* instead of being forwarded to the initializer alone.
|
|
10700
|
+
*/
|
|
10701
|
+
class ReturnedIdentifier extends ExpressionEntity {
|
|
10702
|
+
constructor(returnedIdentifier) {
|
|
10703
|
+
super();
|
|
10704
|
+
this.returnedIdentifier = returnedIdentifier;
|
|
10705
|
+
}
|
|
10706
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10707
|
+
// The initializer may never be the value that is returned
|
|
10708
|
+
deoptimizeInteraction(interaction);
|
|
10709
|
+
this.returnedIdentifier.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10710
|
+
}
|
|
10711
|
+
deoptimizePath(path) {
|
|
10712
|
+
this.returnedIdentifier.deoptimizePath(path);
|
|
10713
|
+
}
|
|
10714
|
+
includeCallArgumentsWhenCalledAtPath(path, interaction, context) {
|
|
10715
|
+
this.returnedIdentifier.includeCallArgumentsWhenCalledAtPath(path, interaction, context);
|
|
10716
|
+
}
|
|
10717
|
+
}
|
|
10718
|
+
|
|
10603
10719
|
class CatchBodyScope extends ChildScope {
|
|
10604
10720
|
constructor(parent) {
|
|
10605
10721
|
super(parent, parent.context);
|
|
@@ -10708,6 +10824,9 @@ class ParameterScope extends ChildScope {
|
|
|
10708
10824
|
}
|
|
10709
10825
|
this.hasRest = hasRest;
|
|
10710
10826
|
}
|
|
10827
|
+
hasParameterCalledFromTryStatement() {
|
|
10828
|
+
return this.parameters.some(parameterVariables => parameterVariables.some(variable => variable.calledFromTryStatement));
|
|
10829
|
+
}
|
|
10711
10830
|
includeCallArguments({ args }, context) {
|
|
10712
10831
|
let calledFromTryStatement = false;
|
|
10713
10832
|
let argumentIncluded = false;
|
|
@@ -10831,21 +10950,21 @@ class ReturnValueScope extends ParameterScope {
|
|
|
10831
10950
|
addArgumentToBeDeoptimized(_argument) { }
|
|
10832
10951
|
updateReturnExpression() {
|
|
10833
10952
|
const { returnExpressions } = this;
|
|
10834
|
-
|
|
10835
|
-
|
|
10953
|
+
const [firstExpression] = returnExpressions;
|
|
10954
|
+
// A single return, or the same variable returned on all paths, can be
|
|
10955
|
+
// resolved to that variable
|
|
10956
|
+
if (firstExpression && this.returnExpressionsResolveToSameVariable(firstExpression)) {
|
|
10957
|
+
this.returnExpression = firstExpression.variable.isTargetOfAssignment
|
|
10958
|
+
? new ReturnedIdentifier(firstExpression)
|
|
10959
|
+
: firstExpression;
|
|
10960
|
+
}
|
|
10961
|
+
else if (returnExpressions.length === 1) {
|
|
10962
|
+
this.returnExpression = firstExpression;
|
|
10836
10963
|
}
|
|
10837
10964
|
else {
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
if (firstExpression && this.returnExpressionsResolveToSameVariable(firstExpression)) {
|
|
10842
|
-
this.returnExpression = firstExpression;
|
|
10843
|
-
}
|
|
10844
|
-
else {
|
|
10845
|
-
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
10846
|
-
for (const expression of returnExpressions) {
|
|
10847
|
-
expression.deoptimizePath(UNKNOWN_PATH);
|
|
10848
|
-
}
|
|
10965
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
10966
|
+
for (const expression of returnExpressions) {
|
|
10967
|
+
expression.deoptimizePath(UNKNOWN_PATH);
|
|
10849
10968
|
}
|
|
10850
10969
|
}
|
|
10851
10970
|
}
|
|
@@ -12591,7 +12710,7 @@ function getCompleteAmdId(options, chunkId) {
|
|
|
12591
12710
|
}
|
|
12592
12711
|
|
|
12593
12712
|
function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, reexportProtoFromExternal, mechanism = 'return ') {
|
|
12594
|
-
const { _,
|
|
12713
|
+
const { _, getFunctionIntro, getPropertyAccess, n, s } = snippets;
|
|
12595
12714
|
if (!namedExportsMode) {
|
|
12596
12715
|
return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings, getPropertyAccess)};`;
|
|
12597
12716
|
}
|
|
@@ -12607,15 +12726,7 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
12607
12726
|
if (exportBlock)
|
|
12608
12727
|
exportBlock += n;
|
|
12609
12728
|
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
12610
|
-
|
|
12611
|
-
functionReturn: true,
|
|
12612
|
-
lineBreakIndent: null,
|
|
12613
|
-
name: null
|
|
12614
|
-
});
|
|
12615
|
-
exportBlock +=
|
|
12616
|
-
`Object.defineProperty(exports,${_}${JSON.stringify(specifier.reexported)},${_}{${n}` +
|
|
12617
|
-
`${t}enumerable:${_}true,${n}` +
|
|
12618
|
-
`${t}get:${_}${left}${importName}${right}${n}});`;
|
|
12729
|
+
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(specifier.reexported)},${_}${getGetter(importName, false, t, snippets)});`;
|
|
12619
12730
|
}
|
|
12620
12731
|
else if (specifier.reexported === '__proto__') {
|
|
12621
12732
|
exportBlock +=
|
|
@@ -12630,12 +12741,16 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
12630
12741
|
}
|
|
12631
12742
|
}
|
|
12632
12743
|
}
|
|
12633
|
-
for (const { exported, local } of exports) {
|
|
12744
|
+
for (const { exported, local, needsLiveBinding } of exports) {
|
|
12634
12745
|
const lhs = `exports${getPropertyAccess(exported)}`;
|
|
12635
12746
|
const rhs = local;
|
|
12636
12747
|
if (lhs !== rhs) {
|
|
12637
12748
|
if (exportBlock)
|
|
12638
12749
|
exportBlock += n;
|
|
12750
|
+
if (needsLiveBinding) {
|
|
12751
|
+
exportBlock += `Object.defineProperty(exports,${_}${JSON.stringify(exported)},${_}${getGetter(rhs, true, t, snippets)});`;
|
|
12752
|
+
continue;
|
|
12753
|
+
}
|
|
12639
12754
|
exportBlock +=
|
|
12640
12755
|
exported === '__proto__'
|
|
12641
12756
|
? `Object.defineProperty(exports,${_}"__proto__",${_}{${n}` +
|
|
@@ -12737,19 +12852,27 @@ function getNamespaceMarkers(hasNamedExports, addEsModule, addNamespaceToStringT
|
|
|
12737
12852
|
}
|
|
12738
12853
|
return '';
|
|
12739
12854
|
}
|
|
12740
|
-
const getDefineProperty = (name, needsLiveBinding, t,
|
|
12855
|
+
const getDefineProperty = (name, needsLiveBinding, t, snippets) => {
|
|
12856
|
+
const { _ } = snippets;
|
|
12741
12857
|
if (needsLiveBinding) {
|
|
12742
|
-
|
|
12743
|
-
functionReturn: true,
|
|
12744
|
-
lineBreakIndent: null,
|
|
12745
|
-
name: null
|
|
12746
|
-
});
|
|
12747
|
-
return (`Object.defineProperty(exports,${_}k,${_}{${n}` +
|
|
12748
|
-
`${t}${t}enumerable:${_}true,${n}` +
|
|
12749
|
-
`${t}${t}get:${_}${left}${name}[k]${right}${n}${t}})`);
|
|
12858
|
+
return `Object.defineProperty(exports,${_}k,${_}${getGetter(`${name}[k]`, false, t, snippets, t)})`;
|
|
12750
12859
|
}
|
|
12751
12860
|
return `exports[k]${_}=${_}${name}[k]`;
|
|
12752
12861
|
};
|
|
12862
|
+
const getGetter = (expression, configurable, t, { getDirectReturnFunction, getObject }, base = '') => {
|
|
12863
|
+
const [left, right] = getDirectReturnFunction([], {
|
|
12864
|
+
functionReturn: true,
|
|
12865
|
+
lineBreakIndent: null,
|
|
12866
|
+
name: null
|
|
12867
|
+
});
|
|
12868
|
+
const fields = [
|
|
12869
|
+
['enumerable', 'true'],
|
|
12870
|
+
['get', `${left}${expression}${right}`]
|
|
12871
|
+
];
|
|
12872
|
+
if (configurable)
|
|
12873
|
+
fields.unshift(['configurable', 'true']);
|
|
12874
|
+
return getObject(fields, { lineBreakIndent: { base, t } });
|
|
12875
|
+
};
|
|
12753
12876
|
|
|
12754
12877
|
function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, symbols, accessedGlobals, indent, snippets) {
|
|
12755
12878
|
const { _, cnst, n } = snippets;
|
|
@@ -13725,6 +13848,14 @@ class ArrayPattern extends NodeBase {
|
|
|
13725
13848
|
}
|
|
13726
13849
|
}
|
|
13727
13850
|
}
|
|
13851
|
+
setAssignedValue(value) {
|
|
13852
|
+
super.setAssignedValue(value);
|
|
13853
|
+
// Destructuring assigns each target only some subpath of the assigned
|
|
13854
|
+
// value, which is not tracked
|
|
13855
|
+
for (const element of this.elements) {
|
|
13856
|
+
element?.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
13857
|
+
}
|
|
13858
|
+
}
|
|
13728
13859
|
markDeclarationReached() {
|
|
13729
13860
|
for (const element of this.elements) {
|
|
13730
13861
|
element?.markDeclarationReached();
|
|
@@ -13894,6 +14025,14 @@ class ObjectPattern extends NodeBase {
|
|
|
13894
14025
|
}
|
|
13895
14026
|
}
|
|
13896
14027
|
}
|
|
14028
|
+
setAssignedValue(value) {
|
|
14029
|
+
super.setAssignedValue(value);
|
|
14030
|
+
// Destructuring assigns each target only some subpath of the assigned
|
|
14031
|
+
// value, which is not tracked
|
|
14032
|
+
for (const property of this.properties) {
|
|
14033
|
+
property.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
14034
|
+
}
|
|
14035
|
+
}
|
|
13897
14036
|
}
|
|
13898
14037
|
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13899
14038
|
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
@@ -14058,6 +14197,9 @@ class AssignmentPattern extends NodeBase {
|
|
|
14058
14197
|
this.left.render(code, options, { isShorthandProperty });
|
|
14059
14198
|
this.right.render(code, options);
|
|
14060
14199
|
}
|
|
14200
|
+
setAssignedValue(value) {
|
|
14201
|
+
this.left.setAssignedValue(value);
|
|
14202
|
+
}
|
|
14061
14203
|
applyDeoptimizations() {
|
|
14062
14204
|
this.deoptimized = true;
|
|
14063
14205
|
this.left.deoptimizePath(EMPTY_PATH);
|
|
@@ -14066,6 +14208,22 @@ class AssignmentPattern extends NodeBase {
|
|
|
14066
14208
|
}
|
|
14067
14209
|
}
|
|
14068
14210
|
|
|
14211
|
+
function markTopLevelAwait(node) {
|
|
14212
|
+
if (node.scope.context.usesTopLevelAwait)
|
|
14213
|
+
return;
|
|
14214
|
+
let parent = node.parent;
|
|
14215
|
+
while (parent) {
|
|
14216
|
+
const { type } = parent;
|
|
14217
|
+
if (type === parseAst_js.ArrowFunctionExpression ||
|
|
14218
|
+
type === parseAst_js.FunctionExpression ||
|
|
14219
|
+
type === parseAst_js.FunctionDeclaration) {
|
|
14220
|
+
return;
|
|
14221
|
+
}
|
|
14222
|
+
parent = parent.parent;
|
|
14223
|
+
}
|
|
14224
|
+
node.scope.context.usesTopLevelAwait = true;
|
|
14225
|
+
}
|
|
14226
|
+
|
|
14069
14227
|
class AwaitExpression extends NodeBase {
|
|
14070
14228
|
deoptimizePath(path) {
|
|
14071
14229
|
this.argument.deoptimizePath(path);
|
|
@@ -14077,16 +14235,7 @@ class AwaitExpression extends NodeBase {
|
|
|
14077
14235
|
}
|
|
14078
14236
|
initialise() {
|
|
14079
14237
|
super.initialise();
|
|
14080
|
-
|
|
14081
|
-
do {
|
|
14082
|
-
const { type } = parent;
|
|
14083
|
-
if (type === parseAst_js.ArrowFunctionExpression ||
|
|
14084
|
-
type === parseAst_js.FunctionExpression ||
|
|
14085
|
-
type === parseAst_js.FunctionDeclaration) {
|
|
14086
|
-
return;
|
|
14087
|
-
}
|
|
14088
|
-
} while ((parent = parent.parent));
|
|
14089
|
-
this.scope.context.usesTopLevelAwait = true;
|
|
14238
|
+
markTopLevelAwait(this);
|
|
14090
14239
|
}
|
|
14091
14240
|
include(context, includeChildrenRecursively) {
|
|
14092
14241
|
if (!this.included)
|
|
@@ -14567,7 +14716,8 @@ class ClassBodyScope extends ChildScope {
|
|
|
14567
14716
|
super(parent, context);
|
|
14568
14717
|
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, EMPTY_PATH, context, 'other')));
|
|
14569
14718
|
this.instanceScope = new ChildScope(this, context);
|
|
14570
|
-
this.
|
|
14719
|
+
this.instanceThisVariable = new ThisVariable(context);
|
|
14720
|
+
this.instanceScope.variables.set('this', this.instanceThisVariable);
|
|
14571
14721
|
}
|
|
14572
14722
|
findLexicalBoundary() {
|
|
14573
14723
|
return this;
|
|
@@ -15059,6 +15209,8 @@ class ForOfStatement extends NodeBase {
|
|
|
15059
15209
|
}
|
|
15060
15210
|
initialise() {
|
|
15061
15211
|
super.initialise();
|
|
15212
|
+
if (this.await)
|
|
15213
|
+
markTopLevelAwait(this);
|
|
15062
15214
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
15063
15215
|
}
|
|
15064
15216
|
render(code, options) {
|
|
@@ -16815,6 +16967,9 @@ class Property extends PropertyBase {
|
|
|
16815
16967
|
}
|
|
16816
16968
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
16817
16969
|
}
|
|
16970
|
+
setAssignedValue(value) {
|
|
16971
|
+
this.value.setAssignedValue(value);
|
|
16972
|
+
}
|
|
16818
16973
|
getPathInProperty(destructuredInitPath) {
|
|
16819
16974
|
return destructuredInitPath.at(-1) === UnknownKey
|
|
16820
16975
|
? destructuredInitPath
|
|
@@ -16830,47 +16985,6 @@ class Property extends PropertyBase {
|
|
|
16830
16985
|
Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
16831
16986
|
Property.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
16832
16987
|
|
|
16833
|
-
class PropertyDefinition extends NodeBase {
|
|
16834
|
-
get computed() {
|
|
16835
|
-
return isFlagSet(this.flags, 1024 /* Flag.computed */);
|
|
16836
|
-
}
|
|
16837
|
-
set computed(value) {
|
|
16838
|
-
this.flags = setFlag(this.flags, 1024 /* Flag.computed */, value);
|
|
16839
|
-
}
|
|
16840
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
16841
|
-
this.value?.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
16842
|
-
}
|
|
16843
|
-
deoptimizePath(path) {
|
|
16844
|
-
this.value?.deoptimizePath(path);
|
|
16845
|
-
}
|
|
16846
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
16847
|
-
return this.value
|
|
16848
|
-
? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
|
|
16849
|
-
: UnknownValue;
|
|
16850
|
-
}
|
|
16851
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
16852
|
-
return this.value
|
|
16853
|
-
? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
16854
|
-
: UNKNOWN_RETURN_EXPRESSION;
|
|
16855
|
-
}
|
|
16856
|
-
hasEffects(context) {
|
|
16857
|
-
return (this.key.hasEffects(context) ||
|
|
16858
|
-
(this.static && !!this.value?.hasEffects(context)) ||
|
|
16859
|
-
checkEffectForNodes(this.decorators, context));
|
|
16860
|
-
}
|
|
16861
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
16862
|
-
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
16863
|
-
}
|
|
16864
|
-
includeNode(context) {
|
|
16865
|
-
this.included = true;
|
|
16866
|
-
this.value?.includePath(UNKNOWN_PATH, context);
|
|
16867
|
-
for (const decorator of this.decorators) {
|
|
16868
|
-
decorator.includePath(UNKNOWN_PATH, context);
|
|
16869
|
-
}
|
|
16870
|
-
}
|
|
16871
|
-
}
|
|
16872
|
-
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
16873
|
-
|
|
16874
16988
|
class RestElement extends NodeBase {
|
|
16875
16989
|
constructor() {
|
|
16876
16990
|
super(...arguments);
|
|
@@ -16915,6 +17029,9 @@ class RestElement extends NodeBase {
|
|
|
16915
17029
|
markDeclarationReached() {
|
|
16916
17030
|
this.argument.markDeclarationReached();
|
|
16917
17031
|
}
|
|
17032
|
+
setAssignedValue(value) {
|
|
17033
|
+
this.argument.setAssignedValue(value);
|
|
17034
|
+
}
|
|
16918
17035
|
applyDeoptimizations() {
|
|
16919
17036
|
this.deoptimized = true;
|
|
16920
17037
|
if (this.declarationInit !== null) {
|
|
@@ -17678,6 +17795,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
17678
17795
|
}
|
|
17679
17796
|
initialise() {
|
|
17680
17797
|
super.initialise();
|
|
17798
|
+
if (this.kind === 'await using')
|
|
17799
|
+
markTopLevelAwait(this);
|
|
17681
17800
|
for (const declarator of this.declarations) {
|
|
17682
17801
|
declarator.declareDeclarator(this.kind);
|
|
17683
17802
|
}
|
|
@@ -18446,7 +18565,7 @@ const bufferParsers = [
|
|
|
18446
18565
|
function literalNumber(node, position, buffer) {
|
|
18447
18566
|
const rawPosition = buffer[position];
|
|
18448
18567
|
node.raw = rawPosition === 0 ? undefined : buffer.convertString(rawPosition);
|
|
18449
|
-
node.value =
|
|
18568
|
+
node.value = buffer.convertFloat64(position + 1);
|
|
18450
18569
|
},
|
|
18451
18570
|
function literalRegExp(node, position, buffer) {
|
|
18452
18571
|
const flags = buffer.convertString(buffer[position]);
|
|
@@ -19389,6 +19508,9 @@ class Module {
|
|
|
19389
19508
|
hasEffects() {
|
|
19390
19509
|
return this.info.moduleSideEffects === 'no-treeshake' || this.ast.hasCachedEffects();
|
|
19391
19510
|
}
|
|
19511
|
+
hasTopLevelAwait() {
|
|
19512
|
+
return this.astContext.usesTopLevelAwait;
|
|
19513
|
+
}
|
|
19392
19514
|
include() {
|
|
19393
19515
|
const context = createInclusionContext();
|
|
19394
19516
|
if (this.ast.shouldBeIncluded(context))
|
|
@@ -20663,6 +20785,7 @@ class Chunk {
|
|
|
20663
20785
|
const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
|
|
20664
20786
|
const renderedDependencies = [...this.getRenderedDependencies().values()];
|
|
20665
20787
|
const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
|
|
20788
|
+
const renderedExportNames = format === 'es' && new Set(renderedExports.map(({ exported }) => exported));
|
|
20666
20789
|
let hasExports = renderedExports.length > 0;
|
|
20667
20790
|
let hasDefaultExport = false;
|
|
20668
20791
|
for (const renderedDependency of renderedDependencies) {
|
|
@@ -20672,8 +20795,8 @@ class Chunk {
|
|
|
20672
20795
|
if (!hasDefaultExport && reexports.some(reexport => reexport.reexported === 'default')) {
|
|
20673
20796
|
hasDefaultExport = true;
|
|
20674
20797
|
}
|
|
20675
|
-
if (
|
|
20676
|
-
renderedDependency.reexports = reexports.filter(({ reexported }) => !
|
|
20798
|
+
if (renderedExportNames) {
|
|
20799
|
+
renderedDependency.reexports = reexports.filter(({ reexported }) => !renderedExportNames.has(reexported));
|
|
20677
20800
|
}
|
|
20678
20801
|
}
|
|
20679
20802
|
}
|
|
@@ -20862,7 +20985,8 @@ class Chunk {
|
|
|
20862
20985
|
exported: exportName,
|
|
20863
20986
|
expression,
|
|
20864
20987
|
hoisted,
|
|
20865
|
-
local
|
|
20988
|
+
local,
|
|
20989
|
+
needsLiveBinding: variable.isReassigned && this.exportNamesByVariable.get(variable).length > 1
|
|
20866
20990
|
});
|
|
20867
20991
|
}
|
|
20868
20992
|
return exports;
|
|
@@ -21565,7 +21689,8 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log
|
|
|
21565
21689
|
// Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
|
|
21566
21690
|
// If we no longer want this, we should make a copy here.
|
|
21567
21691
|
const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, entriesAndManualChunksCount);
|
|
21568
|
-
|
|
21692
|
+
// Warning: This will consume dynamicallyDependentEntriesByAwaitedDynamicEntry.
|
|
21693
|
+
const awaitedAlreadyLoadedAtomsByEntry = getAwaitedAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, entriesAndManualChunksCount);
|
|
21569
21694
|
// A manual chunk only behaves like a dynamic entry if its whole member atom
|
|
21570
21695
|
// is not already loaded whenever any entry dynamically loads it. Otherwise
|
|
21571
21696
|
// there is nothing to gain (and cycles could be created) and the manual
|
|
@@ -21668,9 +21793,11 @@ function analyzeModuleGraph(entries, manualChunks, manualChunkByModule, manualCh
|
|
|
21668
21793
|
dynamicManualChunksForCurrentEntry;
|
|
21669
21794
|
awaitedLoadedManualChunksByEntry[entryOrManualChunkIndex] = awaitedManualChunksForCurrentEntry;
|
|
21670
21795
|
const staticDependencies = new Set(currentEntryModules);
|
|
21796
|
+
let hasTopLevelAwait = false;
|
|
21671
21797
|
// If we have a very large manual chunk, tracking if it is already added to the dependencies will improve performance
|
|
21672
21798
|
const addedManualChunks = new Set();
|
|
21673
21799
|
for (const module of staticDependencies) {
|
|
21800
|
+
hasTopLevelAwait ||= module.hasTopLevelAwait();
|
|
21674
21801
|
getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryOrManualChunkIndex);
|
|
21675
21802
|
const manualChunk = manualChunkByModule.get(module);
|
|
21676
21803
|
if (manualChunk && !addedManualChunks.has(manualChunk)) {
|
|
@@ -21685,7 +21812,6 @@ function analyzeModuleGraph(entries, manualChunks, manualChunkByModule, manualCh
|
|
|
21685
21812
|
}
|
|
21686
21813
|
}
|
|
21687
21814
|
for (const { node: { resolution } } of module.dynamicImports) {
|
|
21688
|
-
let manuallyLoadedChunk = null;
|
|
21689
21815
|
if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
|
|
21690
21816
|
if (!allEntriesSet.has(resolution)) {
|
|
21691
21817
|
dynamicEntryModules.add(resolution);
|
|
@@ -21693,25 +21819,13 @@ function analyzeModuleGraph(entries, manualChunks, manualChunkByModule, manualCh
|
|
|
21693
21819
|
allEntriesAndManualChunks.push([resolution]);
|
|
21694
21820
|
}
|
|
21695
21821
|
else if (!dynamicEntryModules.has(resolution)) {
|
|
21696
|
-
manuallyLoadedChunk = manualChunkByModule.get(resolution)
|
|
21822
|
+
const manuallyLoadedChunk = manualChunkByModule.get(resolution);
|
|
21697
21823
|
if (!manuallyLoadedChunk) {
|
|
21698
21824
|
continue;
|
|
21699
21825
|
}
|
|
21700
21826
|
dynamicManualChunksForCurrentEntry.add(manuallyLoadedChunk);
|
|
21701
21827
|
}
|
|
21702
21828
|
dynamicImportsForCurrentEntry.add(resolution);
|
|
21703
|
-
for (const includedTopLevelAwaitingDynamicImporter of resolution.includedTopLevelAwaitingDynamicImporters) {
|
|
21704
|
-
if (staticDependencies.has(includedTopLevelAwaitingDynamicImporter)) {
|
|
21705
|
-
awaitedDynamicImportsForCurrentEntry.add(resolution);
|
|
21706
|
-
if (manuallyLoadedChunk) {
|
|
21707
|
-
awaitedManualChunksForCurrentEntry.add(manuallyLoadedChunk);
|
|
21708
|
-
}
|
|
21709
|
-
else {
|
|
21710
|
-
awaitedDynamicEntryModules.add(resolution);
|
|
21711
|
-
}
|
|
21712
|
-
break;
|
|
21713
|
-
}
|
|
21714
|
-
}
|
|
21715
21829
|
}
|
|
21716
21830
|
}
|
|
21717
21831
|
for (const dependency of module.implicitlyLoadedBefore) {
|
|
@@ -21729,13 +21843,30 @@ function analyzeModuleGraph(entries, manualChunks, manualChunkByModule, manualCh
|
|
|
21729
21843
|
}
|
|
21730
21844
|
}
|
|
21731
21845
|
}
|
|
21846
|
+
// A dynamic import can be awaited indirectly through a static dependency:
|
|
21847
|
+
// if any module of this entry uses a top-level await, the entry may
|
|
21848
|
+
// still be evaluating when any of its dynamic imports runs, so all of
|
|
21849
|
+
// them are awaited. This includes manual chunks that are loaded
|
|
21850
|
+
// dynamically or implicitly, which behave like dynamic entries here.
|
|
21851
|
+
if (hasTopLevelAwait) {
|
|
21852
|
+
for (const dynamicImportTarget of dynamicImportsForCurrentEntry) {
|
|
21853
|
+
const manualChunk = manualChunkByModule.get(dynamicImportTarget);
|
|
21854
|
+
if (manualChunk) {
|
|
21855
|
+
awaitedManualChunksForCurrentEntry.add(manualChunk);
|
|
21856
|
+
}
|
|
21857
|
+
else {
|
|
21858
|
+
awaitedDynamicEntryModules.add(dynamicImportTarget);
|
|
21859
|
+
}
|
|
21860
|
+
awaitedDynamicImportsForCurrentEntry.add(dynamicImportTarget);
|
|
21861
|
+
}
|
|
21862
|
+
}
|
|
21732
21863
|
entryOrManualChunkIndex++;
|
|
21733
21864
|
}
|
|
21734
21865
|
const { awaitedDynamicEntries, awaitedDynamicImportsByEntry, dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntriesAndManualChunks, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry, dynamicallyLoadedManualChunksByEntry, awaitedLoadedManualChunksByEntry, manualChunkIndexByChunk);
|
|
21735
21866
|
return {
|
|
21736
21867
|
awaitedDynamicImportsByEntry,
|
|
21737
21868
|
dependentEntriesByModule,
|
|
21738
|
-
dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntriesAndManualChunks, dynamicEntry => dynamicEntry.includedTopLevelAwaitingDynamicImporters),
|
|
21869
|
+
dynamicallyDependentEntriesByAwaitedDynamicEntry: addAwaitingEntries(getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntriesAndManualChunks, dynamicEntry => dynamicEntry.includedTopLevelAwaitingDynamicImporters), awaitedDynamicImportsByEntry),
|
|
21739
21870
|
dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntriesAndManualChunks, dynamicEntry => dynamicEntry.includedDynamicImporters),
|
|
21740
21871
|
dynamicImportsByEntry,
|
|
21741
21872
|
entriesAndManualChunksCount: allEntriesAndManualChunks.length
|
|
@@ -21789,6 +21920,18 @@ function getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModul
|
|
|
21789
21920
|
}
|
|
21790
21921
|
return dynamicImportsByEntry;
|
|
21791
21922
|
}
|
|
21923
|
+
// A dynamic entry can be awaited by an entry even if the importing module does
|
|
21924
|
+
// not have a top-level await itself, e.g. if the import is inside a function
|
|
21925
|
+
// that is awaited in the entry. In that case, the entry is still evaluating
|
|
21926
|
+
// when the dynamic entry is executed, so we add all awaiting entries here.
|
|
21927
|
+
function addAwaitingEntries(dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry) {
|
|
21928
|
+
for (const [entryIndex, awaitedDynamicImports] of awaitedDynamicImportsByEntry.entries()) {
|
|
21929
|
+
for (const dynamicEntryIndex of awaitedDynamicImports) {
|
|
21930
|
+
getOrCreate(dynamicallyDependentEntriesByAwaitedDynamicEntry, dynamicEntryIndex, (getNewSet)).add(entryIndex);
|
|
21931
|
+
}
|
|
21932
|
+
}
|
|
21933
|
+
return dynamicallyDependentEntriesByAwaitedDynamicEntry;
|
|
21934
|
+
}
|
|
21792
21935
|
function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntriesAndManualChunks, getDynamicImporters) {
|
|
21793
21936
|
const dynamicallyDependentEntriesByDynamicEntry = new Map();
|
|
21794
21937
|
for (const dynamicEntryIndex of dynamicEntries) {
|
|
@@ -21884,6 +22027,34 @@ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyD
|
|
|
21884
22027
|
}
|
|
21885
22028
|
return alreadyLoadedAtomsByEntry;
|
|
21886
22029
|
}
|
|
22030
|
+
// Warning: This will consume dynamicallyDependentEntriesByAwaitedDynamicEntry.
|
|
22031
|
+
function getAwaitedAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, allEntriesCount) {
|
|
22032
|
+
// Unlike already loaded atoms, this is a union and not an intersection: If
|
|
22033
|
+
// any importer that is still evaluating while it awaits a dynamic entry has
|
|
22034
|
+
// loaded an atom, merging that atom into the chunk of this importer would
|
|
22035
|
+
// create a cycle. Entries that are not awaited have no such atoms.
|
|
22036
|
+
const awaitedAlreadyLoadedAtomsByEntry = new Array(allEntriesCount).fill(0n);
|
|
22037
|
+
for (const [dynamicEntryIndex, dynamicallyDependentEntries] of dynamicallyDependentEntriesByAwaitedDynamicEntry) {
|
|
22038
|
+
// We delete here so that they can be added again if necessary to be handled
|
|
22039
|
+
// again by the loop
|
|
22040
|
+
dynamicallyDependentEntriesByAwaitedDynamicEntry.delete(dynamicEntryIndex);
|
|
22041
|
+
const knownLoadedAtoms = awaitedAlreadyLoadedAtomsByEntry[dynamicEntryIndex];
|
|
22042
|
+
let updatedLoadedAtoms = knownLoadedAtoms;
|
|
22043
|
+
for (const entryIndex of dynamicallyDependentEntries) {
|
|
22044
|
+
updatedLoadedAtoms |=
|
|
22045
|
+
staticDependencyAtomsByEntry[entryIndex] | awaitedAlreadyLoadedAtomsByEntry[entryIndex];
|
|
22046
|
+
}
|
|
22047
|
+
// If the knownLoadedAtoms changed, all awaited dynamic imports of this
|
|
22048
|
+
// entry need to be updated again
|
|
22049
|
+
if (updatedLoadedAtoms !== knownLoadedAtoms) {
|
|
22050
|
+
awaitedAlreadyLoadedAtomsByEntry[dynamicEntryIndex] = updatedLoadedAtoms;
|
|
22051
|
+
for (const dynamicImport of awaitedDynamicImportsByEntry[dynamicEntryIndex]) {
|
|
22052
|
+
getOrCreate(dynamicallyDependentEntriesByAwaitedDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
|
|
22053
|
+
}
|
|
22054
|
+
}
|
|
22055
|
+
}
|
|
22056
|
+
return awaitedAlreadyLoadedAtomsByEntry;
|
|
22057
|
+
}
|
|
21887
22058
|
/**
|
|
21888
22059
|
* Manual chunks whose member atom is already loaded in every context that
|
|
21889
22060
|
* dynamically loads them must not be treated like dynamic entries as that
|
|
@@ -22575,8 +22746,8 @@ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
|
|
|
22575
22746
|
timeStart('transform chunks', 2);
|
|
22576
22747
|
const getHash = hasherByType[outputOptions.hashCharacters];
|
|
22577
22748
|
const chunkGraph = getChunkGraph(chunks);
|
|
22578
|
-
const { hashDependenciesByPlaceholder, initialHashesByPlaceholder, nonHashedChunksWithPlaceholders, placeholders, renderedChunksByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, getHash, log);
|
|
22579
|
-
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, placeholders, bundle, getHash);
|
|
22749
|
+
const { hashDependenciesByPlaceholder, initialHashesByPlaceholder, nonHashedChunksWithPlaceholders, placeholders, renderedChunksByPlaceholder, usedFileNames } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, getHash, log, bundle);
|
|
22750
|
+
const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, placeholders, bundle, usedFileNames, getHash);
|
|
22580
22751
|
addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
|
|
22581
22752
|
timeEnd('transform chunks', 2);
|
|
22582
22753
|
}
|
|
@@ -22656,7 +22827,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
|
|
|
22656
22827
|
map
|
|
22657
22828
|
};
|
|
22658
22829
|
}
|
|
22659
|
-
async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, getHash, log) {
|
|
22830
|
+
async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, getHash, log, bundle) {
|
|
22660
22831
|
const nonHashedChunksWithPlaceholders = [];
|
|
22661
22832
|
const renderedChunksByPlaceholder = new Map();
|
|
22662
22833
|
const hashDependenciesByPlaceholder = new Map();
|
|
@@ -22666,51 +22837,93 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
|
|
|
22666
22837
|
if (hashPlaceholder)
|
|
22667
22838
|
placeholders.add(hashPlaceholder);
|
|
22668
22839
|
}
|
|
22669
|
-
await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, preliminarySourcemapFileName, magicString, usedModules }) => {
|
|
22840
|
+
const transformedChunks = await Promise.all(renderedChunks.map(async ({ chunk, preliminaryFileName: { fileName, hashPlaceholder }, preliminarySourcemapFileName, magicString, usedModules }) => {
|
|
22670
22841
|
const transformedChunk = {
|
|
22671
22842
|
chunk,
|
|
22672
22843
|
fileName,
|
|
22673
22844
|
sourcemapFileName: preliminarySourcemapFileName?.fileName ?? null,
|
|
22674
22845
|
...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, log))
|
|
22675
22846
|
};
|
|
22676
|
-
const
|
|
22847
|
+
const hashAugmentation = hashPlaceholder
|
|
22848
|
+
? pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => augmentation + (pluginHash || ''))
|
|
22849
|
+
: '';
|
|
22850
|
+
return {
|
|
22851
|
+
hashAugmentation,
|
|
22852
|
+
hashPlaceholder,
|
|
22853
|
+
preliminarySourcemapFileName,
|
|
22854
|
+
transformedChunk
|
|
22855
|
+
};
|
|
22856
|
+
}));
|
|
22857
|
+
const usedFileNames = new Set(bundle[lowercaseBundleKeys]);
|
|
22858
|
+
for (const { transformedChunk, hashPlaceholder, preliminarySourcemapFileName, hashAugmentation } of transformedChunks) {
|
|
22859
|
+
const { map } = transformedChunk;
|
|
22860
|
+
const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder;
|
|
22861
|
+
if (map && sourcemapHashPlaceholder) {
|
|
22862
|
+
const { transformedCode: normalizedSourcemap } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(map.toString(), placeholders);
|
|
22863
|
+
initialHashesByPlaceholder.set(sourcemapHashPlaceholder, outputOptions.sourcemap === 'inline'
|
|
22864
|
+
? getHash(normalizedSourcemap).slice(0, sourcemapHashPlaceholder.length)
|
|
22865
|
+
: getUniqueHash(normalizedSourcemap, preliminarySourcemapFileName.fileName, sourcemapHashPlaceholder, usedFileNames, getHash));
|
|
22866
|
+
}
|
|
22677
22867
|
if (hashPlaceholder) {
|
|
22678
|
-
// To create a reproducible content-only hash, all placeholders are
|
|
22679
|
-
// replaced with the same value before hashing
|
|
22680
|
-
const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
|
|
22681
|
-
let contentToHash = transformedCode;
|
|
22682
|
-
const hashAugmentation = pluginDriver.hookReduceValueSync('augmentChunkHash', '', [chunk.getRenderedChunkInfo()], (augmentation, pluginHash) => {
|
|
22683
|
-
if (pluginHash) {
|
|
22684
|
-
augmentation += pluginHash;
|
|
22685
|
-
}
|
|
22686
|
-
return augmentation;
|
|
22687
|
-
});
|
|
22688
|
-
if (hashAugmentation) {
|
|
22689
|
-
contentToHash += hashAugmentation;
|
|
22690
|
-
}
|
|
22691
22868
|
renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk);
|
|
22692
|
-
hashDependenciesByPlaceholder.set(hashPlaceholder,
|
|
22693
|
-
containedPlaceholders,
|
|
22694
|
-
contentHash: getHash(contentToHash)
|
|
22695
|
-
});
|
|
22869
|
+
hashDependenciesByPlaceholder.set(hashPlaceholder, getChunkHash(transformedChunk, outputOptions, getHash, placeholders, initialHashesByPlaceholder, hashAugmentation));
|
|
22696
22870
|
}
|
|
22697
22871
|
else {
|
|
22698
22872
|
nonHashedChunksWithPlaceholders.push(transformedChunk);
|
|
22699
22873
|
}
|
|
22700
|
-
|
|
22701
|
-
if (map && sourcemapHashPlaceholder) {
|
|
22702
|
-
initialHashesByPlaceholder.set(preliminarySourcemapFileName.hashPlaceholder, getHash(map.toString()).slice(0, preliminarySourcemapFileName.hashPlaceholder.length));
|
|
22703
|
-
}
|
|
22704
|
-
}));
|
|
22874
|
+
}
|
|
22705
22875
|
return {
|
|
22706
22876
|
hashDependenciesByPlaceholder,
|
|
22707
22877
|
initialHashesByPlaceholder,
|
|
22708
22878
|
nonHashedChunksWithPlaceholders,
|
|
22709
22879
|
placeholders,
|
|
22710
|
-
renderedChunksByPlaceholder
|
|
22880
|
+
renderedChunksByPlaceholder,
|
|
22881
|
+
usedFileNames
|
|
22711
22882
|
};
|
|
22712
22883
|
}
|
|
22713
|
-
function
|
|
22884
|
+
function getChunkHash({ code, map, fileName, sourcemapFileName }, outputOptions, getHash, placeholders, initialHashesByPlaceholder, hashAugmentation) {
|
|
22885
|
+
// To create a reproducible content-only hash, all placeholders are
|
|
22886
|
+
// replaced with the same value before hashing
|
|
22887
|
+
const { containedPlaceholders, transformedCode } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders);
|
|
22888
|
+
let contentToHash = transformedCode;
|
|
22889
|
+
if (map && outputOptions.sourcemap !== 'hidden') {
|
|
22890
|
+
// Normalize raw map data and file names before base64 or URL encoding
|
|
22891
|
+
// can hide placeholders and make hashes depend on chunk order.
|
|
22892
|
+
let sourcemapPlaceholders;
|
|
22893
|
+
if (outputOptions.sourcemap === 'inline') {
|
|
22894
|
+
const { containedPlaceholders: inlinePlaceholders, transformedCode: sourcemapJson } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(map.toString(), placeholders);
|
|
22895
|
+
sourcemapPlaceholders = inlinePlaceholders;
|
|
22896
|
+
contentToHash += `//# ${SOURCEMAPPING_URL}=data:application/json,${sourcemapJson}\n`;
|
|
22897
|
+
}
|
|
22898
|
+
else {
|
|
22899
|
+
const { containedPlaceholders: externalPlaceholders, transformedCode: normalizedFileName } = replacePlaceholdersWithDefaultAndGetContainedPlaceholders(replacePlaceholders(sourcemapFileName ?? `${fileName}.map`, initialHashesByPlaceholder), placeholders);
|
|
22900
|
+
sourcemapPlaceholders = externalPlaceholders;
|
|
22901
|
+
contentToHash += getSourceMapComment(normalizedFileName, map, outputOptions.sourcemap, outputOptions.sourcemapBaseUrl);
|
|
22902
|
+
}
|
|
22903
|
+
for (const placeholder of sourcemapPlaceholders) {
|
|
22904
|
+
containedPlaceholders.add(placeholder);
|
|
22905
|
+
}
|
|
22906
|
+
}
|
|
22907
|
+
if (hashAugmentation) {
|
|
22908
|
+
contentToHash += hashAugmentation;
|
|
22909
|
+
}
|
|
22910
|
+
return { containedPlaceholders, contentHash: getHash(contentToHash) };
|
|
22911
|
+
}
|
|
22912
|
+
function getUniqueHash(contentToHash, fileName, placeholder, usedFileNames, getHash) {
|
|
22913
|
+
let finalFileName;
|
|
22914
|
+
let finalHash;
|
|
22915
|
+
do {
|
|
22916
|
+
// In case of a hash collision, create a hash of the hash
|
|
22917
|
+
if (finalHash) {
|
|
22918
|
+
contentToHash = finalHash;
|
|
22919
|
+
}
|
|
22920
|
+
finalHash = getHash(contentToHash).slice(0, placeholder.length);
|
|
22921
|
+
finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash).toLowerCase();
|
|
22922
|
+
} while (usedFileNames.has(finalFileName));
|
|
22923
|
+
usedFileNames.add(finalFileName);
|
|
22924
|
+
return finalHash;
|
|
22925
|
+
}
|
|
22926
|
+
function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, initialHashesByPlaceholder, placeholders, bundle, usedFileNames, getHash) {
|
|
22714
22927
|
const hashesByPlaceholder = new Map(initialHashesByPlaceholder);
|
|
22715
22928
|
for (const placeholder of placeholders) {
|
|
22716
22929
|
const { fileName } = renderedChunksByPlaceholder.get(placeholder);
|
|
@@ -22724,17 +22937,8 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
|
|
|
22724
22937
|
hashDependencyPlaceholders.add(containedPlaceholder);
|
|
22725
22938
|
}
|
|
22726
22939
|
}
|
|
22727
|
-
|
|
22728
|
-
|
|
22729
|
-
do {
|
|
22730
|
-
// In case of a hash collision, create a hash of the hash
|
|
22731
|
-
if (finalHash) {
|
|
22732
|
-
contentToHash = finalHash;
|
|
22733
|
-
}
|
|
22734
|
-
finalHash = getHash(contentToHash).slice(0, placeholder.length);
|
|
22735
|
-
finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash);
|
|
22736
|
-
} while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase()));
|
|
22737
|
-
bundle[finalFileName] = FILE_PLACEHOLDER;
|
|
22940
|
+
const finalHash = getUniqueHash(contentToHash, fileName, placeholder, usedFileNames, getHash);
|
|
22941
|
+
bundle[replaceSinglePlaceholder(fileName, placeholder, finalHash)] = FILE_PLACEHOLDER;
|
|
22738
22942
|
hashesByPlaceholder.set(placeholder, finalHash);
|
|
22739
22943
|
}
|
|
22740
22944
|
return hashesByPlaceholder;
|
|
@@ -22772,15 +22976,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
22772
22976
|
}
|
|
22773
22977
|
}
|
|
22774
22978
|
function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
|
|
22775
|
-
|
|
22776
|
-
if (sourcemap === 'inline') {
|
|
22777
|
-
url = map.toUrl();
|
|
22778
|
-
}
|
|
22779
|
-
else {
|
|
22780
|
-
const sourcemapFileName = sp.basename(fileName);
|
|
22781
|
-
url = sourcemapBaseUrl
|
|
22782
|
-
? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
|
|
22783
|
-
: sourcemapFileName;
|
|
22979
|
+
if (sourcemap !== 'inline') {
|
|
22784
22980
|
pluginDriver.emitFile({
|
|
22785
22981
|
fileName,
|
|
22786
22982
|
originalFileName: null,
|
|
@@ -22788,6 +22984,14 @@ function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, so
|
|
|
22788
22984
|
type: 'asset'
|
|
22789
22985
|
});
|
|
22790
22986
|
}
|
|
22987
|
+
return getSourceMapComment(fileName, map, sourcemap, sourcemapBaseUrl);
|
|
22988
|
+
}
|
|
22989
|
+
function getSourceMapComment(fileName, map, sourcemap, sourcemapBaseUrl) {
|
|
22990
|
+
const url = sourcemap === 'inline'
|
|
22991
|
+
? map.toUrl()
|
|
22992
|
+
: sourcemapBaseUrl
|
|
22993
|
+
? new URL(sp.basename(fileName), sourcemapBaseUrl).toString()
|
|
22994
|
+
: sp.basename(fileName);
|
|
22791
22995
|
return sourcemap === 'hidden' ? '' : `//# ${SOURCEMAPPING_URL}=${url}\n`;
|
|
22792
22996
|
}
|
|
22793
22997
|
function calculateDebugIdAndGetComment(code, map) {
|
|
@@ -24580,17 +24784,17 @@ async function rollupInternal(rawInputOptions, registerWatchHooks) {
|
|
|
24580
24784
|
...error_,
|
|
24581
24785
|
message: `There was an error during the build:\n ${error_.message}\nAdditionally, handling the error in the 'buildEnd' hook caused the following error:\n ${buildEndError.message}`
|
|
24582
24786
|
});
|
|
24583
|
-
await graph.pluginDriver.hookParallel('closeBundle', [compoundError]);
|
|
24787
|
+
await graph.pluginDriver.hookParallel('closeBundle', [compoundError]).catch(() => { });
|
|
24584
24788
|
throw compoundError;
|
|
24585
24789
|
}
|
|
24586
|
-
await graph.pluginDriver.hookParallel('closeBundle', [error_]);
|
|
24790
|
+
await graph.pluginDriver.hookParallel('closeBundle', [error_]).catch(() => { });
|
|
24587
24791
|
throw error_;
|
|
24588
24792
|
}
|
|
24589
24793
|
try {
|
|
24590
24794
|
await graph.pluginDriver.hookParallel('buildEnd', []);
|
|
24591
24795
|
}
|
|
24592
24796
|
catch (buildEndError) {
|
|
24593
|
-
await graph.pluginDriver.hookParallel('closeBundle', [buildEndError]);
|
|
24797
|
+
await graph.pluginDriver.hookParallel('closeBundle', [buildEndError]).catch(() => { });
|
|
24594
24798
|
throw buildEndError;
|
|
24595
24799
|
}
|
|
24596
24800
|
});
|