fix(javascript): preserve loader conditions across application evidence (#12023)

* fix(javascript): honor loader semantics for BOM hashbangs

* fix(javascript): retain conditional BOM hashbang imports

* fix(javascript): share conditional hashbang recovery

* fix(javascript): recover suffix-only source imports

* fix(javascript): retain conditional CommonJS hashbang imports

* fix(javascript): preserve conditional hashbang dependency evidence

* fix(javascript): preserve ambiguous dotfile and worker evidence

* fix(javascript): qualify semantic evidence with source loader conditions

* fix(javascript): qualify all source-backed application evidence

* test(javascript): identify imports by their projected kind

---------

Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
This commit is contained in:
ShuaixinHuangandShuaixinHuang authored and GitHub committed 2026-11-18 09:42:46 -05:00
1 parent 919531c7c1
commit 34f7d2131c
22 files changed
+1053 -69

No files matched your search

@@ -209,6 +209,18 @@ const addReference = (
input.value.loader_authority === "candidate"
? null
: resolveReference(context, input.file.path, input.value, input.coverage);
const candidateLoader = input.value.loader_authority === "candidate";
const loaderEvidence = {
confidence: candidateLoader ? ("low" as const) : ("high" as const),
limitations: [
...(resolved?.limitations ??
(candidateLoader
? [
"The module loader is unknown, so this dependency cannot be resolved against the source file.",
]
: [])),
],
};
if (
input.value.operation === "load" &&
(input.value.kind === "static-import" ||
@@ -261,7 +273,7 @@ const addReference = (
range: input.value.location,
operation: "discover-worker",
coverage: input.coverage,
limitations: resolved?.limitations ?? [],
...loaderEvidence,
}),
},
],
@@ -278,7 +290,7 @@ const addReference = (
resolution_status: resolved?.resolution?.resolution_status ?? null,
...artifactPathResolutionProperties(resolved?.resolution),
},
limitations: resolved?.limitations ?? [],
...loaderEvidence,
});
if (resolved !== null && resolved.path !== null && resolved.node !== null)
addStaticInferenceEdge(context, {
@@ -289,7 +301,7 @@ const addReference = (
coverage: input.coverage,
relation: "maps_to",
properties: { resolved_path: resolved.path },
limitations: resolved.limitations,
...loaderEvidence,
});
return;
}
@@ -338,18 +350,7 @@ const addReference = (
resolution_status: resolved?.resolution?.resolution_status ?? null,
...artifactPathResolutionProperties(resolved?.resolution),
},
...(input.value.loader_authority === "candidate"
? { confidence: "low" as const }
: {}),
...(resolved === null
? input.value.loader_authority === "candidate"
? {
limitations: [
"The module loader is unknown, so this dependency cannot be resolved against the source file.",
],
}
: {}
: { limitations: resolved.limitations }),
...loaderEvidence,
});
};