reactjs / reactjs/react-docgen
Monorepo support is missing
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
Description
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;
}
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 in makeFsImporter.ts, especially resolveImportedValue, and trace how imported interfaces and types are resolved for files in a monorepo. Generalize the reported package-resolution behavior beyond the @blocks, @segments, and @libraries example so external packages in scoped monorepos are parsed and their properties are included.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100