Persper / js-callgraph

Construct approximate static call graph for JavaScript & Typescript
Eclipse Public License 2.0
182 stars 54 forks source link

[feature request] Support JSX/TSX Files #40

Open hydrosquall opened 5 years ago

hydrosquall commented 5 years ago

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 commented 5 years ago

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.