reactjs / reactjs/react-docgen
Monorepo support is missing
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 3.8k
- Fork
- 316
- Merge medio
- 5h 7m
- PR unite (30g)
- 4
Descrizione
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;
}
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in makeFsImporter.ts, in particolare in resolveImportedValue, e traccia il modo in cui le interfacce e i tipi importati vengono risolti per i file in un monorepo. Generalizza il comportamento di risoluzione dei pacchetti segnalato oltre l’esempio @blocks, @segments e @libraries, in modo che i pacchetti esterni nei monorepo con scope vengano analizzati e che le loro proprietà vengano incluse.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100