Registry / web-framework / react-docgen-annotation-resolver

react-docgen-annotation-resolver

JSON →
library2.0.0jsnpmunverified

A resolver for react-docgen that enables parsing of exports annotated with @component JSDoc tag as React components. Version 2.0.0 is stable; the package is released on npm as needed. Unlike default react-docgen resolvers that infer components from patterns like displayName or propTypes, this resolver explicitly marks any export with a @component annotation as a component, giving developers control over what gets documented.

npm install react-docgen-annotation-resolver
INSTALL
IMPORT
SIG · REACT-DOCGEN-ANNOT
R
react-docgen-annotation-resolver
web-frameworkjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

annotationResolver
import annotationResolver from 'react-docgen-annotation-resolver';
const annotationResolver = require('react-docgen-annotation-resolver');
ESM-only since v1.0.0; CJS require works only if the package is transpiled, but it's not recommended.
default
import annotationResolver from 'react-docgen-annotation-resolver';
import { annotationResolver } from 'react-docgen-annotation-resolver';
This package exports a single default function; named destructuring will result in undefined.
TypeScript types
import annotationResolver from 'react-docgen-annotation-resolver';
import { Resolver } from 'react-docgen-annotation-resolver';
The package does not export TypeScript types. Use @types/react-docgen or declare your own.

Shows how to use the annotation resolver with react-docgen's parse function to extract documentation from a component annotated with @component.

import annotationResolver from 'react-docgen-annotation-resolver'; import reactDocgen from 'react-docgen'; const sourceCode = ` /** @component */ export default function MyButton() { return <button />; } `; const doc = reactDocgen.parse(sourceCode, undefined, annotationResolver); console.log(doc); // [{ description: '', ... }]
Debug
Known issues
breakingv2.0.0 drops support for Node < 10 (was <8 in v1). May break CI pipelines using older Node.
fix
Upgrade to Node >=10 or pin to v1.x if needed.
affects: <2.0.0
deprecatedThe default resolver from react-docgen is deprecated in favor of custom resolvers like this one.
fix
This is the intended alternative; no fix required.
affects: >=1.0.0
gotchaThe resolver only detects @component annotation on default exports; named exports are ignored.
fix
Ensure your component is a default export with a JSDoc block containing @component.
affects: >=1.0.0
gotchaIf the annotated export is not a React component (e.g., a plain object), react-docgen may still parse it but produce incomplete documentation.
fix
Only annotate actual React components with @component.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: annotationResolver is not a function
Importing as a named export instead of default import.
fix
Use import annotationResolver from 'react-docgen-annotation-resolver';
Error: You provided an invalid resolver. Resolvers must be functions.
Passing undefined or a non-function value as resolver to react-docgen.parse.
fix
Ensure you import and pass the default function: reactDocgen.parse(source, undefined, annotationResolver);
Module not found: Can't resolve 'react-docgen-annotation-resolver'
Package not installed or incorrect import path.
fix
Run npm install react-docgen-annotation-resolver --save-dev
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
react-docgen-annotation-resolver — npm install react-docgen-annotation-resolver · libregistry