Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-docgen no longer has react-docgen/dist/babylon #5

Closed
reintroducing opened this issue Dec 4, 2018 · 14 comments
Closed

react-docgen no longer has react-docgen/dist/babylon #5

reintroducing opened this issue Dec 4, 2018 · 14 comments

Comments

@reintroducing
Copy link

This is causing an error in version 8.0.5+ of react-styleguidist now when using this plugin.

Cannot find module 'react-docgen/dist/babylon'
npx styleguidist server --open exited with code 1
@siddharthkp
Copy link
Owner

Great catch! Do you know the replacement for it?

@danez
Copy link
Collaborator

danez commented Dec 5, 2018

The replacement is: react-docgen/dist/babelParser.

I guess doing this should make it possible for old and new versions to work:

let babylon
try {
    babylon = require(`react-docgen/dist/babelParser`).default
} catch (e) {
   babylon = require(`react-docgen/dist/babylon`).default
}

@reintroducing
Copy link
Author

Thanks @danez for following up on this. @siddharthkp any chance we can get an updated version with the changes so we can upgrade react-styleguidist without issue?

@Slowl
Copy link

Slowl commented Dec 7, 2018

Thanks @danez ! It fixed my issue but now, docgen return an empty object for every components that require an external variable to define some proptypes
Any idea on how to fix that ?

@reintroducing
Copy link
Author

Any movement on this one gentlemen?

@siddharthkp
Copy link
Owner

siddharthkp commented Dec 12, 2018

Well, I'm not actively maintaining this package (clearly? 😅)

Added @danez as a collaborator to both this repo and package on npm to take this forward

@danez You cool with that?

@Slowl
Copy link

Slowl commented Dec 12, 2018

@reintroducing I personally downgraded react-docgen to a stable version until a fix is found for react-docgen >v3

@danez
Copy link
Collaborator

danez commented Dec 13, 2018

@danez You cool with that?

Okay, thanks.

@danez
Copy link
Collaborator

danez commented Dec 13, 2018

Okay fixed in 1.0.1.

@danez danez closed this as completed Dec 13, 2018
@reintroducing
Copy link
Author

reintroducing commented Dec 13, 2018

Hmm, I just updated and while it does compile, there are now errors for the components that had the setup like I mentioned here: #1
Warning: Cannot parse src/TextInput/TextInput.jsx: TypeError: options.parser.parse is not a function

I can actually fix the errors by destructuring the propTypes like so:

static propTypes = {
    ...TextInputPropTypes,
};

However that doesn't actually fix the propTypes listed in the style guide.

Prior to update: https://www.dropbox.com/s/yhh131i6fvxeqj8/Screenshot%202018-12-13%2007.59.33.png?dl=0

After update: https://www.dropbox.com/s/znok10q5ruwvslw/Screenshot%202018-12-13%2007.59.55.png?dl=0

Post update, only the defaultProps show. Any idea whats going on?

@danez
Copy link
Collaborator

danez commented Dec 14, 2018

Can you try again with 1.0.2? It should work now. Sorry for the mistake.

@reintroducing
Copy link
Author

@danez Please don't be sorry, you're helping out on an OSS project, I really appreciate you even taking time to do this.

As for the update, it fixed most of the components that were erroring last time except one. The new error I now see in that component is Warning: Cannot parse src/TextInput/TextInput.jsx: TypeError: Cannot read property 'loc' of null.

That component's propTypes are simply static propTypes = TextInputPropTypes; and it does work with v1.0.0 and react-styleguidist v8.0.4. Upgrading both to v1.0.2 and v8.0.5+ breaks it with the above error.

@coreybruyere
Copy link

@reintroducing did you ever get this resolved? Keep running into issues you've ran into in some of these GH Issue threads. I'm trying to import and destructure propTypes into my component but I'm having trouble documenting those propTypes in Styleguidist.

Example of what I'm trying to do:
https://spectrum.chat/styled-components/general/how-to-import-external-dep-proptypes-to-display-in-styleguidist~6258f2a2-c31c-4e56-b1ba-45550cbcfa55

@reintroducing
Copy link
Author

@coreybruyere unfortunately no, and i've just stayed on v8.0.4 of react-styleguidist as a result to make sure i'm not getting the errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants