mirror of
https://github.com/morluto/rea.git
synced 2026-10-30 11:25:39 +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
@@ -10,6 +10,7 @@ import {
|
||||
import {
|
||||
collectSemanticModuleLink,
|
||||
collectSemanticCallable,
|
||||
semanticImportEqualsSpecifier,
|
||||
collectSemanticReferences,
|
||||
collectSemanticReferencesSteps,
|
||||
immutableSemanticBindings,
|
||||
@@ -752,6 +753,8 @@ const bindInnerDeclaration = (
|
||||
state: JavaScriptSemanticAnalysisState,
|
||||
): void => {
|
||||
if (t.isImportDeclaration(node)) bindImports(node, scope, state);
|
||||
else if (t.isTSImportEqualsDeclaration(node))
|
||||
bindImportEquals(node, scope, state);
|
||||
else if (t.isVariableDeclarator(node))
|
||||
bindPattern({
|
||||
pattern: node.id,
|
||||
@@ -785,6 +788,25 @@ const bindInnerDeclaration = (
|
||||
});
|
||||
};
|
||||
|
||||
const bindImportEquals = (
|
||||
node: t.TSImportEqualsDeclaration,
|
||||
scope: JavaScriptSemanticScopeState,
|
||||
state: JavaScriptSemanticAnalysisState,
|
||||
): void => {
|
||||
const specifier = semanticImportEqualsSpecifier(node);
|
||||
if (specifier === null) return;
|
||||
addBinding({
|
||||
state,
|
||||
scope,
|
||||
name: node.id.name,
|
||||
kind: "import",
|
||||
mutable: false,
|
||||
definitionNode: node.id,
|
||||
initializer: null,
|
||||
directOrigin: { specifier, importedPath: [] },
|
||||
});
|
||||
};
|
||||
|
||||
const bindAssignment = (
|
||||
node: t.Node,
|
||||
scope: JavaScriptSemanticScopeState,
|
||||
|
||||
Reference in new issue
Block a user