refactor(react, docs): derive component props from the API schema, drop react-docgen - #10621
refactor(react, docs): derive component props from the API schema, drop react-docgen#10621luvkapur wants to merge 1 commit into
Conversation
…op react-docgen The properties tables in the docs UI (the Compositions "properties" tab and the Overview properties table) were fed by react-docgen 5.3.1 via the legacy `ConsumerComponent.docs` doclets. Point `ReactMain.getDocs` at the TypeScript schema extractor instead and remove react-docgen entirely. react-docgen ran for every non-test file on every cold-cache component load — 3,224 parses in this workspace, of which 2,942 produced nothing — and it read props without type information. The schema extractor already computes this data for the API reference. Measured against real schema artifacts, prop counts match react-docgen exactly (avatar 8, component-preview 15, lane-selector 14, version-dropdown 7, tooltip 3, time-ago 2) with more precise types and default values react-docgen missed. `bit show --legacy` now reports jsdoc-only docs for React components. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CI note
So this PR actually reduces the count the guard measures, by ~240 files in each case — consistent with dropping react-docgen and its transitive babel parsing from the load path. It is still over the threshold, which is a pre-existing master problem and looks like what #10599 is addressing. I deliberately did not bump the thresholds or regenerate Every other check passes: |
What
The properties tables in the docs UI were fed by
react-docgen5.3.1 through the legacyConsumerComponent.docsdoclets. This pointsReactMain.getDocsat the TypeScript schema extractor instead and removesreact-docgenentirely.Two UI surfaces consume
getDocs, and both migrate here:compositions.tsx→useDocs)docs-app→PropertiesTable→useFetchDocs)Neither UI component changed — only the resolver's data source — so there is no client rewiring and no transport change.
Why
react-docgenran for every non-test file on every cold-cache component load: 3,224 parses in this workspace, of which 2,942 produced nothing and fell through to the jsdoc parser. It also read props without type information, so it could only describe what it could pattern-match out of the source.The schema extractor already computes this data for the API Reference tab, and describes props precisely. The package was also pinned at 5.3.1 against a 7.x upstream with an incompatible API, so it was never going to be updated.
Verification
npm run lint(tsc + oxlint) clean;bit compileclean on all 332 components; 9 new unit tests for the mapper.The mapper was run against real schema artifacts, and prop counts match
react-docgenexactly:design/ui/avatarpreview/ui/component-previewlanes/ui/inputs/lane-selectorcomponent/ui/version-dropdowndesign/ui/tooltipdesign/ui/time-agoAlso verified end to end against a running
bit startGraphQL server. The schema output is strictly richer —isTag?: (version?: string): boolean = (version) => semver.valid(version) !== nullwherereact-docgengave a baresignature, including default values it never captured.Aspect graph: no new edge.
SchemaAspectwas already a declared dependency ofReactAspectandschemaMainwas already injected into the provider; this only threads the existing instance into the constructor. There is no reverseschema → reactedge, andbit statusloads all 332 components without a circular-dependency error.Review notes
getDocswent from reading a field to potentially running a schema extraction. For built components it reads the build artifact; for workspace components it runs the extractor (~9s cold via CLI, warm after tsserver is up). Concurrent requests for the same component are deduped by an in-flight map, and nothing is cached past settle so a workspace component is never described from a stale schema. Worth a sanity check on a large workspace.bit show --legacybehaviour change: docs are now jsdoc-only, so React components lose their prop tables there. That command is the only remaining consumer ofConsumerComponent.docs, which stays populated by the jsdoc parser.Version.id()excludesdocs, so no version hashes change.pnpm-lock.yamlis intentionally not regenerated — CI runs plainbit install(no--frozen-lockfile), and regenerating locally produced ~33k lines of unrelated churn.Unrelated pre-existing issues noticed
bit schema <pattern> --jsonfails arg parsing withUnknown argument: jsonand prints help.components/semantics/doc-parser/jsdoc/jsdoc-parser.spec.tsfails to load under mocha with an ESM/CJSERR_UNKNOWN_FILE_EXTENSION; reproduced identically onmaster.🤖 Generated with Claude Code