fix(javascript): derive loader references from lexical binding ownership
Use shared lexical bindings and recovered bundler identities for require and chunk references. Preserve uncertain writes as unresolved evidence; remove name-only loader aliases and repeated definition scans. Reviewed-PR: #2989 Co-authored-by: Hussnain Ahmad <ha7886899@gmail.com>
This commit is contained in:
1 parent
f2f83934d2
commit
eef4a0bfb4
8 files changed
+509
-32
No files matched your search
@@ -78,6 +78,7 @@ interface BindPatternInput {
|
||||
readonly scope: JavaScriptSemanticScopeState;
|
||||
readonly state: JavaScriptSemanticAnalysisState;
|
||||
readonly mutable: boolean;
|
||||
readonly declarationKind?: "var" | "let" | "const" | "using" | "await using";
|
||||
readonly kind?: JavaScriptSemanticDefinition["kind"];
|
||||
readonly projection?: readonly (string | number | null)[];
|
||||
readonly referenceOnly?: boolean;
|
||||
@@ -101,6 +102,7 @@ interface AddBindingInput {
|
||||
readonly name: string;
|
||||
readonly kind: JavaScriptSemanticDefinition["kind"];
|
||||
readonly mutable: boolean;
|
||||
readonly declarationKind?: "var" | "let" | "const" | "using" | "await using";
|
||||
readonly definitionNode: t.Node;
|
||||
readonly initializer: t.Node | null;
|
||||
readonly directOrigin?: JavaScriptModuleOrigin;
|
||||
@@ -976,6 +978,9 @@ const bindInnerDeclaration = (
|
||||
parent !== null && t.isVariableDeclaration(parent)
|
||||
? parent.kind !== "const"
|
||||
: true,
|
||||
...(parent !== null && t.isVariableDeclaration(parent)
|
||||
? { declarationKind: parent.kind }
|
||||
: {}),
|
||||
});
|
||||
else if (t.isClassExpression(node) && t.isIdentifier(node.id))
|
||||
addBinding({
|
||||
@@ -1258,6 +1263,7 @@ const bindPattern = (input: BindPatternInput): void => {
|
||||
scope,
|
||||
state,
|
||||
mutable,
|
||||
declarationKind,
|
||||
kind = "variable",
|
||||
projection = [],
|
||||
referenceOnly = false,
|
||||
@@ -1300,6 +1306,7 @@ const bindPattern = (input: BindPatternInput): void => {
|
||||
name: pattern.name,
|
||||
kind,
|
||||
mutable,
|
||||
...(declarationKind === undefined ? {} : { declarationKind }),
|
||||
definitionNode: pattern,
|
||||
initializer,
|
||||
projection,
|
||||
@@ -1402,6 +1409,7 @@ const addBinding = (input: AddBindingInput): void => {
|
||||
name,
|
||||
kind,
|
||||
mutable,
|
||||
declarationKind,
|
||||
definitionNode,
|
||||
initializer,
|
||||
directOrigin,
|
||||
@@ -1416,6 +1424,8 @@ const addBinding = (input: AddBindingInput): void => {
|
||||
state.bindingsById.set(binding.bindingId, binding);
|
||||
}
|
||||
binding.mutable ||= mutable;
|
||||
if (declarationKind !== undefined)
|
||||
binding.declarationKinds.add(declarationKind);
|
||||
binding.definitions.push({ kind, location: range(definitionNode) });
|
||||
if (initializer !== null)
|
||||
binding.initializers.push({ node: initializer, projection });
|
||||
@@ -1443,6 +1453,7 @@ const createBinding = (
|
||||
name,
|
||||
kind,
|
||||
mutable,
|
||||
declarationKinds: new Set(),
|
||||
memberWrites: [],
|
||||
escapedPaths: [],
|
||||
definitions: [],
|
||||
|
||||
Reference in new issue
Block a user