Every bundler builds a module graph and almost none of them will show you one. I wanted to know the shape of the code behind Nakodo rather than its weight: which file everything depends on, which files depend on nothing, and whether the dependency arrows ever go in a circle.
That took about forty lines of Python and no tooling, and the interesting results were all in the places my first version got wrong.
Resolving the edges
Two kinds of specifier matter in this codebase: @/ for the project root alias and ./ for relatives. Everything else is a package.
def resolve ( spec , src ) : if spec . startswith ( "@/" ) : base = Path ( "src" ) / spec [ 2 : ] elif spec . startswith ( "." ) : base = ( src . parent / spec ) . resolve ( ) else : return None # a package, not our code for c in ( base , base . with_suffix ( ".ts" ) , base . with_suffix ( ".tsx" ) , base / "index.ts" , base / "index.tsx" ) : if c .…