reactjs / react-docgen

A CLI and library to extract information from React component files for documentation generation purposes.
https://react-docgen.dev
MIT License
3.68k stars 298 forks source link

ast-types should be a Peer dependency probably #390

Open jquense opened 5 years ago

jquense commented 5 years ago

It doesn't seem possible for third party resolvers or handlers, use different versions of ast-types with react-docgen since it's all operating on the same ast. If someone uses the latest 0.13.0 with react-docgen it breaks, presumable b/c of a change in how visit or parsing works between 0.12.x and 0.13.0.

To address we should probably make ast-types a peer dep or rexport ast-types for consuming third party resolvers/handlers

danez commented 5 years ago

Do you have an example?

We currently supply the parse method to handlers, resolvers as the last argument. Adding the whole ast-types package there would be a little bit risky and every update for ast-types would be potentially breaking also for react-docgen then.

jquense commented 5 years ago

I'm not sure i have a quick reproducible example but i've seen it consistently in gatsby and our our own usages. Effectively any handler that uses a different version of ast-types than react-docgen runs the risk of hitting an indiscernable error. We saw this with ast-types 0.13. I upgraded in gatsby and then react-docgen was using it's own 0.12 version and you'd get a stack overflow in recast trying to loop through a cyclical node.