1.0.2 • Published 1 year ago

@andriyorehov/ts-graph v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

ts-tree

Creates a module tree based on a given entrypoint.

Builds on top of ts-morph

Install

npm i @andriyorehov/ts-graph

Usage

import { getTreeByFile } from '@andriyorehov/ts-graph';

const tree = getTreeByFile('filePath.ts');
console.dir(tree, { depth: null });

Comparison table

Feature/Namets-treemodule-graphnode-dependency-tree
ts support✅ TypeScript (via typescript)✅ es-module-lexer
ts alias supportissue
jsx supportissue
not ts project support
circular dependencies handling❌ use dpdm

TODO

  • tree by folder dependencies
  • tree by file dependencies
  • ignore third-party dependencies
  • alias handling
  • ignore types/interface/enum/as const dependencies from file tree
  • ignore types/interface/enum/as const dependencies from folder tree
  • ignore object which used only in types for folder tree
  • handle ExportDeclaration with moduleSpecifier
  • exclude barrel files from file tree
  • exclude barrel files from folder tree
  • guarantee id uniqueness of file tree
  • guarantee id uniqueness of folder tree
  • pass meta info about files to file tree
  • pass meta info about files to folder tree
  • arg parser for file tree
  • include used export by parent
  • check named imports from same file on different lines for file tree
  • check named imports from same file on different lines for folder tree
  • handle default import for file tree
  • handle default import for folder tree
  • build package
  • use tsconfig related to passed file path to allow running not from project root directory
  • publish to npm
  • handle files outside of folder tree
  • return flat list to simplify processing
  • create separate method with flat structure and use getReferencingSourceFiles, include types, barrel files, styles
  • check barrel files handling for default import
  • circular dependencies handling?
  • how to get file deps with skipAddingFilesFromTsConfig: false, skipFileDependencyResolution: false,

Tech Debt

  • try https://github.com/thepassle/module-graph
  • reuse code between file and folder tree builder
  • cache file tree builder? (don't need since id need to be unique for each node)
  • improve performance
  • use getReferencingSourceFiles instead own resolution implementation? in such case I will not able to ignore types/interface/enum/as const and barrel files
  • fix eslint
  • add test for folder tree id uniqueness
  • upgrade find-up to latest version with ESM
  • try find-up-simple (ESM)
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.7

1 year ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago