universal-ast-mapper 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/extractors/typescript.js +42 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -605,6 +605,7 @@ Not part of the public API: the internal `src/` module layout and the generated
|
|
|
605
605
|
|
|
606
606
|
| Version | What changed |
|
|
607
607
|
|---------|--------------|
|
|
608
|
+
| **1.4.0** | **Dynamic import tracking** — dynamic `import("...")` and CommonJS `require("...")` calls (anywhere in a file) are now captured as imports with an `isDynamic` flag. Relative dynamic imports resolve and draw graph edges like static ones, so lazy-loaded routes/modules show up in the dependency graph. |
|
|
608
609
|
| **1.3.0** | **TS/JS decorators** — class and method symbols now carry a `decorators` field (`@Component({...})`, `@Injectable()`, `@Get("/x")`), in skeletons and `get_call_graph`. Extends the Python decorator support (v0.8.7) to TypeScript/JavaScript — traces Angular/NestJS-style framework wiring to its class/handler. |
|
|
609
610
|
| **1.2.0** | **File-level cross-package resolution** — in a monorepo, bare imports of a workspace package (`@org/utils`, `@org/utils/sub`) now resolve to the actual source file (preferring `src/` over built `dist/`), so `resolve_imports` marks them in-project and `build_symbol_graph` draws cross-package edges. Builds on the v1.1.0 workspace discovery. |
|
|
610
611
|
| **1.1.0** | **Monorepo support** — new `analyze_workspace` MCP tool + `ast-map workspace` (alias `ws`) CLI: discovers packages from npm/yarn `workspaces`, `pnpm-workspace.yaml`, or `lerna.json`, maps internal package dependencies, and flags circular package deps. **19 MCP tools**. |
|
|
@@ -213,8 +213,50 @@ export function extractImportsTS(root, _source) {
|
|
|
213
213
|
else if (child.type === "export_statement")
|
|
214
214
|
parseReExportStatement(child, imports);
|
|
215
215
|
}
|
|
216
|
+
collectDynamicImports(root, imports);
|
|
216
217
|
return imports;
|
|
217
218
|
}
|
|
219
|
+
/** First string-literal argument of a call's `arguments` node, or null. */
|
|
220
|
+
function firstStringArg(args) {
|
|
221
|
+
for (let i = 0; i < args.namedChildCount; i++) {
|
|
222
|
+
const a = args.namedChild(i);
|
|
223
|
+
if (a && a.type === "string") {
|
|
224
|
+
for (let j = 0; j < a.namedChildCount; j++) {
|
|
225
|
+
const frag = a.namedChild(j);
|
|
226
|
+
if (frag && frag.type === "string_fragment")
|
|
227
|
+
return frag.text;
|
|
228
|
+
}
|
|
229
|
+
return a.text.replace(/^['"`]|['"`]$/g, "");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Walk the whole tree for dynamic `import("...")` and CommonJS `require("...")`
|
|
236
|
+
* calls (they can appear anywhere, not just at the top level). Only string-literal
|
|
237
|
+
* specifiers are captured; computed requires are skipped.
|
|
238
|
+
*/
|
|
239
|
+
function collectDynamicImports(node, out) {
|
|
240
|
+
if (node.type === "call_expression") {
|
|
241
|
+
const fn = node.childForFieldName("function");
|
|
242
|
+
const args = node.childForFieldName("arguments");
|
|
243
|
+
if (fn && args) {
|
|
244
|
+
const isImport = fn.type === "import";
|
|
245
|
+
const isRequire = fn.type === "identifier" && fn.text === "require";
|
|
246
|
+
if (isImport || isRequire) {
|
|
247
|
+
const spec = firstStringArg(args);
|
|
248
|
+
if (spec !== null) {
|
|
249
|
+
out.push({ symbol: "*", from: spec, isNamespaceImport: true, isDynamic: true });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
255
|
+
const c = node.namedChild(i);
|
|
256
|
+
if (c)
|
|
257
|
+
collectDynamicImports(c, out);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
218
260
|
function parseReExportStatement(node, out) {
|
|
219
261
|
const source = extractModulePath(node.text);
|
|
220
262
|
if (!source)
|
package/package.json
CHANGED