microsoft / microsoft/TypeScript
Optimal TS monorepos: how to handle project references when projects opt out of composite within dependency chain
@sheetalkamat arbeitet bereits daran.
Seit 06.9.2024.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
project references
no output
🕗 Version & Regression Information
N/A
⏯ Playground Link
N/A
💻 Code
// Your code here
🙁 Actual behavior
Please see full description, repro and video walkthrough
🙂 Expected behavior
Please see full description, repro and video walkthrough
Additional information about the issue
I am reporting this as an issue because @jakebailey advised me that that would make sense for any time a Debug Error is reached in TS, but also to get formal guidance from the TS Team on finalizing our new TypeScript plugin for Nx.
As discussed in our sync between our teams a couple of months ago, we are building a new mechanism to sync Nx project graph (derived from package.json files and import and export statements) automatically to configuration files on disk. This is a generic mechanism, but in the context of TS, this applies to syncing project references in tsconfig.json files.
This should allow us to keep Nx out of the way of tsc where appropriate (tsc will be directly executed by Nx behind the scenes when using nx typecheck my-ts-proj or nx build my-ts-proj for example) and still allow users to run raw tsc if they wish because all the relevant config will live on disk and be up to date thanks to Nx.
The syncing mechanism is working really well already for repo's which can fully stick to composite: true throughout the codebase, but we have already run into one case on the https://github.com/typescript-eslint/typescript-eslint (where @jakebailey and @sheetalkamat kindly help out) where a couple of projects needed to opt out of composite: true and not emit declaration files at all.
As explained in detail in attached loom covering the reproduction repo, we would like some advice on how we should attempt to handle cases like this in our syncing logic.
The super brief summary of the issue causing it to hit the Debug Failure is:
- Projects: A -> B -> C
- B is opting out of composite
- The root solution file can happily reference all 3 projects as hoped, despite the composite opt out of B
- We want to be able to typecheck A, B and C
tsc -b --emitDeclarationOnlyis used for typechecking (intentionally kept distinct from building withtsc, producing JS artifacts)- When typechecking the whole repo, or typechecking just A, we hit the Debug failure because of B not having any outputs before proceeding onto A
🎥 Context and issue reproduction: https://www.loom.com/share/84a7098b3d1e4a819bd598ad7fc3ae7f
🔗 Reproduction repo: https://github.com/JamesHenry/tsc-composite-false-repro
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.