mirror of
https://github.com/morluto/rea.git
synced 2026-11-07 23:36:41 +00:00
fix(javascript): preserve TypeScript loader and dependency semantics
Share loader selection across static findings and module relationships: CTS static imports and re-exports use CommonJS lookup while dynamic imports retain ESM lookup. Retain runtime import-equals dependencies, bindings, and exported names; do not resolve require file-URL strings as local artifacts. Restore import-map descriptions in CLI help. Validated resolver and semantic tests, application reconstruction boundaries, and CLI help. Installed TypeScript NodeNext emission and Node require behavior were checked independently. Refs #2056, #2057, #2058, #2053.
This commit is contained in:
1 parent
966f7cc84b
commit
e4532b5376
8 files changed
+242
-13
No files matched your search
@@ -6,6 +6,51 @@ import {
|
||||
topLevelBinding,
|
||||
} from "./javascriptSemanticAnalysis.fixture.js";
|
||||
|
||||
describe("TypeScript import-equals links", () => {
|
||||
it("retains runtime external import-equals as a require dependency", () => {
|
||||
const links = analyzeJavaScriptSemantics(`
|
||||
import dependency = require("./dependency.cjs");
|
||||
import type types = require("./types");
|
||||
import alias = Namespace.Dependency;
|
||||
`).moduleLinks;
|
||||
|
||||
expect(links).toEqual([
|
||||
expect.objectContaining({
|
||||
kind: "require",
|
||||
specifier: "./dependency.cjs",
|
||||
importedName: null,
|
||||
localName: "dependency",
|
||||
exportedName: null,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps the exported binding for exported import-equals", () => {
|
||||
const source = 'export import dependency = require("./dependency");';
|
||||
const links = analyzeJavaScriptSemantics(source).moduleLinks;
|
||||
|
||||
expect(links).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
kind: "require",
|
||||
specifier: "./dependency",
|
||||
localName: "dependency",
|
||||
exportedName: null,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
kind: "export",
|
||||
specifier: null,
|
||||
localName: "dependency",
|
||||
exportedName: "dependency",
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
links.find(({ kind }) => kind === "require")?.location.start,
|
||||
).toEqual({ line: 1, column: 7 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("CommonJS dependency links", () => {
|
||||
it.each([
|
||||
'require("dependency");',
|
||||
|
||||
Reference in new issue
Block a user