azu / monorepo-utils

A collection of utilities for monorepo/lerna. Tools for TypeScript project references etc..
164 stars 10 forks source link

Ability to reference sub-directories of referenced projects #38

Closed noisyscanner closed 3 years ago

noisyscanner commented 3 years ago

Problem

We have a project with the following layout:

packages/
  a/
    tsconfig.json
    src/
      tsconfig.json # extends ../tsconfig.json
  b/
    tsconfig.json
    src/
      tsconfig.json # extends ../tsconfig.json

We use --tsconfigPath src/tsconfig.json to target the correct tsconfig.json file, as this is where we want the references, but we want the references for example for package b to be like:

{
  "references": [
    {
      "path": "../../a/src"
    }
  ]
}

Instead of:

{
  "references": [
    {
      "path": "../../a"
    }
  ]
}

Solution

Would it be safe to assume that the directory structure given in --tsconfigPath can be used for referenced projects?

I will make a PR for this on my fork and see how it goes - let me know what you think about this solution. I guess the alternative is to add another CLI option for it.

noisyscanner commented 3 years ago

Potential fix here: https://github.com/azu/monorepo-utils/pull/39 What do you think?

This solves our use case and means we can start using this and integrate into our pre-commit hooks and CI :)

azu commented 3 years ago

Fixed in v2.4.5.

Thanks to @noisyscanner

azu commented 3 years ago

@noisyscanner I've invited you as a collaborator. Thanks for committing 👍

noisyscanner commented 3 years ago

Thanks @azu!