js-callgraph icon indicating copy to clipboard operation
js-callgraph copied to clipboard

[feature request] Support JSX/TSX Files

Open hydrosquall opened this issue 6 years ago • 1 comments

Hi,

Thanks for the great work on this library! I was hoping to use this tool to analyze a react/typescript based project, but ran into some errors relating to babel being unable to find a class name transformation plugin.

I saw that vue files are supported, and was hoping to extend that to the react ecosystem as well. Thanks for the consideration!

hydrosquall avatar Aug 24 '19 19:08 hydrosquall

Update: I've found that jsx files work sometimes, but not always. TSX files are not working at all. I see that the underlying esprima parser already has the jsx flag set to true, further testing with react projects is needed to see why it's only working some of the time.

https://github.com/Persper/js-callgraph/blob/7abc6bb04fed9d82640716cc410db21fe1e9eb00/src/astutil.js#L286

An alternate approach might be to investigating how to generate callgraphs using some of the non-esprima JS parsers (see the JS listings under AST Explorer), but that would probably be considerably more involved work.

hydrosquall avatar Aug 26 '19 03:08 hydrosquall