How do I automatically include outDir when importing a TypeScript project?

Viewed 28

I have a TypeScript library that uses a pretty standard src+dist setup in tsconfig.json:

{
    "rootDir": "./src/",      
    "outDir": "./dist/",  
}

When I compile this project and import it into another project, I can't import *.ts files in subdirectories without including "dist":

import { xyz } from "library/subdirectory/file"; //fails
import { xyz } from "library/dist/subdirectory/file"; //succeeds

What's the best way to automatically infer the dist directory? I was able to get the root by using the main attribute in package.json, but that doesn't help me get subdirectories and other files.

0 Answers
Related