react-docgen icon indicating copy to clipboard operation
react-docgen copied to clipboard

feature request. Allow to analyze reexported components

Open stepancar opened this issue 8 years ago • 4 comments

AnyComponent.jsx

import * as React from 'react';

export default class AnyComponent extends React.Component {
    anyMethod(){
       //..
    }
    render(){
       return (<div></div>)
    }
}

Test.jsx

export {AnyComponent} from './AnyComponent';
react-docgen Test.jsx

throws exception "No suitable component definition found"

But should analysis content of AnyComponent.jsx.

What do you think about it?

stepancar avatar Apr 13 '16 09:04 stepancar

react-docgen doesn't implement any dependency resolution, so it doesn't know how to load ./AnyComponent or even what it is.

The problem is that we have a different module system at Facebook, so a solution to this problem would require a way to specify how modules are resolved (maybe parts of jest can be reused). I don't think I have time to look into this, but if somebody else wants to, I'm happy to help.

fkling avatar Jun 01 '16 15:06 fkling

@fkling I wouldn't mind investigating this. Do you have any pointers/examples that could help me to kickstart this

roychoo avatar Mar 16 '17 08:03 roychoo

@fkling can https://www.npmjs.com/package/babel-plugin-preval/ help with that?

iamstarkov avatar Aug 11 '17 14:08 iamstarkov

@fkling solution here https://github.com/alfa-laboratory/library-utils/blob/master/react-doc/create-resolver.js

to use it:

1) npm i library-utils
// import 
2) const reactDoc = require('library-utils/react-doc');
// pass file path
console.log(reactDoc(filePath));

stepancar avatar Aug 11 '17 22:08 stepancar