microsoft / microsoft/TypeScript
Project References Wildcards
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 Search Terms
"project references" "glob" "wildcard" "repetitive" "monorepo"
✅ Viability Checklist
- 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. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Project References currently have to be written out explicitly. It would be super nice if we could use a wildcard/glob like this, where I could simply have all of my tsconfig.json files look like this:
{
"extends": ["../../../tsconfig.base.json"],
"references": [{"path": "../../libs/*"}]
}
Or, even something like this:
{
"extends": ["../../../tsconfig.base.json"],
"references": [{"path": "../../libs/*/tsconfig.build.json"}]
}
We can discuss below whether supporting globstars (**) is prudent or not.
📃 Motivating Example
I've got a project with 8 libs and 3 apps using project references. It follows this basic structure:
tsconfig.base.json
workspaces/
apps/
app-1/
tsconfig.json
app-2/
tsconfig.json
.../
libs/
lib-1/
tsconfig.json
lib-2/
tsconfig.json
.../
There's a little more complexity, but that's the basic idea. However, I have a ton of repetition between all my tsconfig.json files that basically all look like this:
{
"extends": ["../../../tsconfig.base.json"],
"references": [
{
"path": "../../libs/lib-1"
},
{
"path": "../../libs/lib-2"
},
// ...
]
}
I can't rely on the extends functionality from tsconfig.base.json because of things like @RyanCavanaugh's explanation here: https://github.com/microsoft/TypeScript/issues/27098#issuecomment-494161387.
💻 Use Cases
- What do you want to use this for?
- A monorepo with a number of shared libraries and apps
- What shortcomings exist with current approaches?
- Lots of repetition of lengthy amounts of JSON
- What workarounds are you using in the meantime?
- Specifying each lib in the
"references"portion for every single app/lib that needs to be able to import shared libraries.
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.
Rechercherichtung
Beginne mit den Beispielen in tsconfig.json und den verknüpften Diskussionen zur Vererbung von project references. Definiere die unterstützten Wildcard- und Globstar-Formen, einschließlich der Auflösung von Pfaden im Monorepo-Layout, und überprüfe anschließend, dass Wildcard-Referenzen funktionieren, ohne bestehende explizite Referenzen zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- build-system
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100