reactjs / reactjs/react-docgen
Monorepo support is missing
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 3.8k
- Forks
- 316
- Ø Merge
- 5 Std. 7 Min.
- Gemergte PRs (30 T.)
- 4
Beschreibung
We are working in a huge monorepo setup with hundreds of packages. Now if an interface is imported from an "external" package - just another package that i'm currently scoped into - it won't pick up this file and parse it. This results in missing properties that basically would be delivered by this imported interface/type.
Could be fixed with a patch in the makeFsImporter.ts but i didn't made a pull request yet - i just tried it out very specifically for our own repository, but it would need further work to make a generic solution out of it:
function resolveImportedValue(
path: ImportPath,
name: string,
file: FileState,
seen = new Set<string>(),
): NodePath | null {
// Bail if no filename was provided for the current source file.
// Also never traverse into react itself.
let source = path.node.source?.value;
let { filename } = file.opts;
// Customization: add support to resolve packages from blocks, segments, and libraries in iso monorepo
if (
(typeof filename === "string" && source?.startsWith("@blocks")) ||
source?.startsWith("@segments") ||
source?.startsWith("@libraries")
) {
filename = `${getRepoRoot(filename as string)}/${source.replace("@", "")}/src/index.ts`;
source = "./index";
}
// Customization: end
if (!source || !filename || source === "react") {
return null;
}
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 in makeFsImporter.ts, insbesondere bei resolveImportedValue, und verfolge, wie importierte Schnittstellen und Typen für Dateien in einem Monorepo aufgelöst werden. Verallgemeinere das gemeldete Verhalten der Paketauflösung über das Beispiel mit @blocks, @segments und @libraries hinaus, damit externe Pakete in Scopes von Monorepos geparst und ihre Eigenschaften einbezogen werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100