-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Check for incompatible Gatsby plugins #7143
Comments
A first step towards this would be to encourage plugin authors to specify a peerDependencies section of their plugin's package.json file:
We could start with updating the docs to mention this, and updating the official Gatsby plugins to do this. |
We should add to the migration guide for plugins. If it turns out your plugin isn't compatible, the very first thing you do is add peerDependency saying that and release that so people will know and then make a new major release with the changes |
This could be useful: https://github.com/npm/node-semver |
Closes: #7143 #9731 <!-- Q. Which branch should I use for my pull request? A. Use `master` branch (probably). Q. Which branch if my change is a bug fix for Gatsby v1? A. In this case, you should use the `v1` branch Q. Which branch if I'm still not sure? A. Use `master` branch. Ask in the PR if you're not sure and a Gatsby maintainer will be happy to help :) Note: We will only accept bug fixes for Gatsby v1. New features should be added to Gatsby v2. Learn more about contributing: https://www.gatsbyjs.org/docs/how-to-contribute/ -->
Closes: gatsbyjs#7143 gatsbyjs#9731 <!-- Q. Which branch should I use for my pull request? A. Use `master` branch (probably). Q. Which branch if my change is a bug fix for Gatsby v1? A. In this case, you should use the `v1` branch Q. Which branch if I'm still not sure? A. Use `master` branch. Ask in the PR if you're not sure and a Gatsby maintainer will be happy to help :) Note: We will only accept bug fixes for Gatsby v1. New features should be added to Gatsby v2. Learn more about contributing: https://www.gatsbyjs.org/docs/how-to-contribute/ -->
Summary
It can be confusing to work out which version of a plugin to use with your version of Gatsby, particularly when trying out pre-release versions. Gatsby should show a warning if it knows that your plugins are incompatible.
Setting a version to
^1.0.0
won't install pre-release versions like2.0.0-beta.2
.Basic example
The following setup will install a beta version of Gatsby v2, but only version 1 of
gatsby-plugin-foo
, as the^
version range character won't select the pre-release version of the foo plugin.package.json (excerpt)
gatsby-config.js
gatsby-plugin-foo
's most recentpackage.json
gatsby-plugin-foo
v1'spackage.json
Gatsby could be updated to check the peerDependencies of installed plugins that are listed in your project's
gatsby-config.js
. It could display a warning if they don't match.This would be similar to npm / yarn's peerDependency warnings - but can be displayed in the Gatsby CLI and could contain more specific info related to Gatsby.
Motivation
This makes it easier to use pre-release versions of Gatsby by avoiding mysterious errors that occur from using incompatible plugins.
This issue might not be such a problem once Gatsby 2.0.0 is released, so it may not be worth spending the time building this feature.
The text was updated successfully, but these errors were encountered: