fix(javascript): retain unbound CommonJS semantic imports

Collect unbound literal CommonJS dependencies at the semantic module-link owner, retain null binding names and source provenance, and avoid duplicate links for calls already represented by bindings or re-exports. Preserve distinct nested calls, shadowing exclusions, dynamic binding uncertainty, and existing static asset references.

Fixes #1793.
This commit is contained in:
Ysopwnable authored and GitHub committed 2026-10-11 19:16:32 +08:00
1 parent 40d9c7b836
commit 3a17882cc4
10 files changed
+388 -33

No files matched your search

@@ -56,7 +56,7 @@ it("retains exact empty method names and environment keys", () => {
]);
});
it("retains exact empty require paths without dynamic-key links", () => {
it("retains exact empty require paths and dependencies without dynamic-key bindings", () => {
const ir = analyzeJavaScriptSemantics(`
const { '': fromPattern } = require("./table.js");
const fromMember = require("./table.js")[''];
@@ -84,6 +84,18 @@ it("retains exact empty require paths without dynamic-key links", () => {
localName: "fromMember",
exportedName: null,
},
{
kind: "require",
importedName: null,
localName: null,
exportedName: null,
},
{
kind: "require",
importedName: null,
localName: null,
exportedName: null,
},
{
kind: "commonjs-export",
importedName: "",