microsoft / microsoft/TypeScript
Infer project references from common monorepo patterns / tools
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Genesis: see section "Repetitive configuration" in https://github.com/Microsoft/TypeScript/issues/3469#issuecomment-400439520
Search Terms
monorepo infer project references automatically yarn lerna workspace package.json
Suggestion
For common monorepo managers, we should natively understand cross-project references declared in package.json as if they were declared in tsconfig.json
Open questions:
- Which formats (lerna, yarn, pnpm, etc) would be supported? Can all of them be consistently detected, or would you need to opt in to a specific "monorepo format" to enable a specific resolution algorithm?
- How do we find the
tsconfig.jsonfile? This data is actually not present in the current (non-tsconfig) dependency graph. We could assume it to be in the package root; what if it's elsewhere? - Would you need to opt in? Would there be a way to opt out? What should that look like?
Use Cases
- Monorepos of all (supportable) flavors
Examples
https://github.com/RyanCavanaugh/learn-a
This repo has a fair bit of duplication where projects need to write down their dependencies in package.json and as references (with different syntax) in tsconfig.json.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the issue's proposed relationship between package.json and tsconfig.json project references, then inspect the linked learn-a example. Compare the monorepo formats named in the open questions, including lerna, yarn, and pnpm, and determine how tsconfig.json locations and opt-in behavior should work. Done means a settled design and implementation scope for inferring references consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100