ts-morph icon indicating copy to clipboard operation
ts-morph copied to clipboard

Q: How do I navigate source files from a dependency?

Open steinybot opened this issue 2 years ago • 1 comments

I might be doing things totally wrong but I am using ts-morph to generate a TS file at build time. I want to navigate all the source files within a particular dependency using the normal module resolution algorithm. My package is one of many workspaces and so hard coding the path to ./node_modules/foo/ is not a great idea. This seems like it should be possible but I'm not seeing it. How can this be done? Thanks in advance.

steinybot avatar Jan 09 '24 10:01 steinybot

const sourceFile = importDeclaration.getModuleSpecifierSourceFile();

Relevant docs here: https://ts-morph.com/details/imports

quadband avatar Jan 15 '24 06:01 quadband