-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Add React Styleguidist #2044
Add React Styleguidist #2044
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact [email protected] if you have any questions. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Sorry, been a bit overwhelmed. Is this ready? Can you rebase please? |
@gaearon Done! Looking forward to your review 🍕 |
Did this section accidentally disappear from TOC? Can you add it back? |
Looks like it wasn’t there in the first place ;-/ I’ve updated the TOC. |
There's also one in main README. Is it there? |
Nope, it wasn’t there too ;-) |
Looks good. Thank you! |
Awesome, thanks! 🍕 |
First install Styleguidist and peer dependencies from npm: | ||
|
||
```sh | ||
npm install --save-dev react-styleguidist webpack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this. This is a bit scary.
People had a lot of issues trying to install webpack directly into CRA projects. Things would randomly break, and they would be running a wrong or incompatible version.
Why is it required for Styleguidist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's possible to not make it a peer, and just rely on it existing, this would be awesome. It's always going to exist in CRA projects, but making it a peer puts user in charge of managing webpack versions which goes directly against goals of this project, and will break people's setups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is that users should be able to choose their own version of webpack (if it’s supported by Styleguidist of course). What if we add it as a dependency with a range like >=1 <4
? Would npm properly dedupe them and use the same webpack version for Styleguidist and the host project or CRA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully yes but I'd prefer to avoid relying on this. It doesn't always work.
In my practice peers are often just not worth it either. You can put require in a try catch and show a graceful crash message if you'd like. IMO this is a more solid way to accomplish what you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, we already has a webpack version check so we could just use it to show a warning if it’s not installed or version is not supported. I guess majority of our users already have webpack anyway ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind making this in a patch today? so I can remove this instruction before cutting a release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m going to make a release as soon as I test this fix ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few other things (I'll fix myself but wanted to note).
|
||
Then, add these scripts to your `package.json`: | ||
|
||
```sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a shell file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True ;-|
|
||
```sh | ||
{ | ||
"scripts": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User naïvely following this instruction will replace the whole scripts
section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you recommend here?
Check webpack availability and version at run time instead of using peerDependencies to allow usage of build tools that contains webpack as their own dependency, like Create React App. See discussion here: facebook/create-react-app#2044
I did a followup in #2660. |
Awesome! I’ve just made a new release without webpack peer dependency. |
This is a second try to add React Styleguidist to CRA docs after #921, where we’ve decided that CRA integration in Styleguidist wasn’t good enough. Since then we’ve greatly improved first time experience and out-of-the-box CRA support.