CLI to identify all descendant imports of a ts file
- 🏁 Fast - Uses
ts-morph
to analyze the AST import specifiers of a typescript project - 🔵 .ts
- 🙈 Omits imports from
node_modules
and just picks up your source code - 🌲
cp
the resolved tree - Optionally copies the resolved import tree to a new directory for analysis or refactoring. The original relative directory structure is retained - 🔧 Configurable - Functionality for complicated typescript projects and use cases
ts-lineage
takes a typescript file, extracts its dependencies via ts-morph, resolves each relative import to a file on the filesystem, then "recursively" performs those steps on the descendant imports until all relative imports are resolved.
npm install lineage-ts
-f, --file <string>
(required): path to the root file)-tsc, --tsconfig <string>
(optional): path to a typescript config-dir, --destDir <string>
(optional): directory to which the resolved dependency tree should be copied to
- Debugging and performance testing: When analyzing a single element in a large application, it can be useful to extract only the relevant code to remove any potential side effects and complications from the main app.
- Refactoring: When moving an application to a new architecture, it can be cumbersome to manually
cp
over files that relate to the refactor target.
node-dependency-tree
is a generic tool for analyzing dependencies that works for multiple languages and module types. lineage-ts
is exclusively for typescript, uses ts-morph
, and has a utility for cp
'ing the resolved dependency tree to a new dir
lineage-ts --help