-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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 Gatsby cli support #3740
Add Gatsby cli support #3740
Conversation
|
||
// The specific version (7.1.1) of babel-loader solves a problem caused by Gatsby and Storybook using different versions of Webpack. | ||
// Details on the error can be and the solution was found at: https://github.com/babel/babel-loader/issues/505#issuecomment-324268931. | ||
packageJson.devDependencies['babel-loader'] = '7.1.1'; |
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 can overwrite the version that user had before running getstorybook
. Let's at least output a warning in that case
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Codecov Report
@@ Coverage Diff @@
## master #3740 +/- ##
==========================================
+ Coverage 40.59% 40.95% +0.36%
==========================================
Files 483 482 -1
Lines 5747 5696 -51
Branches 770 747 -23
==========================================
Hits 2333 2333
+ Misses 3042 3014 -28
+ Partials 372 349 -23
Continue to review full report at Codecov.
|
Added a warning text after installing storybook. Is it descriptive enough as is? Also, in the original issue a fix was proposed that is more on the Gatsby side of things. but doesn't require overwriting of dependencies: #3716 (comment). Do we want to do something with that? |
What's blocking this from moving forwards? |
How will it work after #3746 ? |
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 dope!
I'm not quite sure either, I will have to see after that PR is done. When do you expect that to be done or at a stage that I can test this PR against it, @Hypnosphi? |
No estimation, sorry. I'll have a quite poor internet connection in the upcoming week |
No problem, just wanted to see if there was an ETA. I will keep an eye out for the other PR and when that's done test this PR again! |
#3746 isn't ready yet, but in contains the relevant changes in Note that it uses |
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.
To avoid preliminary merging
Will try to look into it when I can |
Gatsby community needs this a lot |
09db449
to
17474e1
Compare
.then(() => { | ||
logger.log( | ||
chalk.yellow( | ||
'NOTE: Be careful that the specific version 7.1.1 of babel-loader was installed and has overwritten any previously present version, as this is currently required for Storybook and Gatsby to work together.' |
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.
Ideally, we should output this only if there was some other version installed
if (!packageJson.dependencies['babel-core'] && !packageJson.devDependencies['babel-core']) { | ||
packageJson.devDependencies['babel-core'] = babelCoreVersion; | ||
} | ||
if (!packageJson.dependencies['babel-runtime'] && !packageJson.devDependencies['babel-runtime']) { |
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.
Not needed anymore
'@storybook/addon-actions', | ||
'@storybook/addon-links', | ||
'@storybook/addons', | ||
'babel-core', |
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.
we should either install babel-core@bridge
+ @babel/core
here (see installBabel
helper), or add a babel config, because our default config is now incompatible with Babel 6
FYI saw this project on Twitter that might be relevant: |
That looks promising, @shilman. Will look into it when i can this week |
@Keraito Is this for Gatsby V2? I am starting to have problems with Storybook. They all starting to happen after updating. |
Here are the changes I needed to make Storybook work with Gatsby 2: https://github.com/storybooks/storybook/pull/4238/files#diff-2e7628bfd4b9096136534adeab54a1b1 |
I actually made some changes locally but didnt push to remote according to the configuration in https://github.com/Mathspy/gatsby-storybook-jest-starter, which worked but required some specific versions of packages. can't remind of the top of my head but were related to:
But if @Hypnosphi made it work for Gatsby 2 with the described changed that might be better. I'm atm kind of busy with some university related stuff, so I hope I can find some time this weekend to look into it further and then report back 🤞 |
@Keraito @Hypnosphi I haven't been keeping up on this PR (sorry), but I just wanted to let you know that I've been experimenting with compatibility for SB4: It seems like the current version of SB4 works fine with Gatsby 2 and that Gatsby 1 is incompatible. @Hypnosphi if you got it working with Gatsby 1, maybe you can comment here or on that issue. |
Unfortunately not: gatsbyjs/gatsby#8652 |
@shilman Is this PR still necessary? We discussed this yesterday how you had a document for this? Storybook 4 should be 100% compatible with Gatsby 2 |
I would like to finalize this before moving onto improvements to docs structure and netlify. |
Generated by 🚫 dangerJS |
@ndelangen The comment in question is here: #4281 (comment) I propose that we don't worry about Gatsby 1 support and that Gatsby 2 basically works. I might be missing something though! |
Issue: Fixes #3716
Storybook and Gatsby weren't really compatible. I got storybook working for Gatsby, but then Gatsby's development server wouldn't run anymore.
What I did
After spending some time messing around in the webpack configuration of both projects, I came across gatsbyjs/gatsby#4300. Apparently, Storybook and Gatsby use different versions of Webpack, what does not really go well together and which has been reported multiple times at Gatsby's side gatsbyjs/gatsby#4283 (comment). A detailed description of the underlying issue and work-around is in babel/babel-loader#505 (comment), which is adding specifically version
7.1.1
ofbabel-loader
to the devDependencies.So I added a generator that adds this particular version of
babel-loader
, and the detector is based on thegatsby
dependency. Gatsby are working on their compatibility with webpack 3, so after that we can remove this work around.