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

feat(gatsby): release plugin option validation #27437

Merged
merged 12 commits into from Nov 2, 2020

Conversation

mxstbr
Copy link
Contributor

@mxstbr mxstbr commented Oct 14, 2020

Merging and publishing this PR releases plugin option validation once we're ready! 🎉

  • Removes the feature flag from all plugin options schemas and core. [ch16665]
  • Adds a @gatsbyVersion pragma to pluginOptionsSchema Node API. This will make Gatsby prompt users on old versions of gatsby that don't support the API to upgrade to the new version. [ch17018]

⚠️ After this is merged we need to publish gatsby@2.25.0, i.e. a minor version. ⚠️

This will make Gatsby prompt users on old versions of gatsby that don't support the API to upgrade to the new version.
@mxstbr mxstbr requested a review from a team October 14, 2020 08:20
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 14, 2020
@@ -431,6 +431,7 @@ export const onCreateDevServer = true

/**
* Called during `gatsby develop` bootstrap to get and validate a plugins options schema
* @gatsbyVersion 2.24.69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, is the PR only that size? How is it working under the hood?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! @DSchau implemented this way back in 2019 in #16105, I just didn't know! Soooo goooood 😍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, this is an incredible feature! Thanks for pointing the PR, will study on that 🚀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxstbr what do you think of arbitrarily bumping the version of Gatsby here? (e.g. to 2.25.0 or something)

Seems better user behavior (cc @vladar useful to think about as a concrete example of release cadence being useful!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not quite following... How are users meant to upgrade to 2.25.0 if it doesn't exist yet? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh -- I mean bump the version locally and then ship this 🚀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bump that version after we land #27381 and set the minimum version to that!

@@ -431,6 +431,7 @@ export const onCreateDevServer = true

/**
* Called during `gatsby develop` bootstrap to get and validate a plugins options schema
* @gatsbyVersion 2.24.69
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is going to need to be bumped to whatever version is the first to include the .default()s support from #27381 (which isn't merged yet).

@LekoArts LekoArts added type: documentation An issue or pull request for improving or updating Gatsby's documentation and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Oct 15, 2020
@mxstbr
Copy link
Contributor Author

mxstbr commented Oct 19, 2020

This is ready to go! Will need to publish this as gatsby@2.25.0 after merging this to ensure this works as expected 👍 👍 👍

@mxstbr mxstbr requested a review from a team as a code owner October 27, 2020 09:00
@mxstbr mxstbr requested a review from a team as a code owner October 27, 2020 09:11
@mxstbr mxstbr changed the title chore(gatsby): add @gatsbyVersion pragma to pluginOptionsSchema Node API feat(gatsby): release plugin option validation Oct 27, 2020
@mxstbr mxstbr merged commit 41ae1c0 into master Nov 2, 2020
@delete-merged-branch delete-merged-branch bot deleted the plugin-options-schema-gatsby-version branch November 2, 2020 13:26
)
.description(`This plugin resolves url() paths relative to the entry SCSS/Sass file not – as might be expected – the location relative to the declaration. Under the hood, it makes use of sass-loader and this is documented in the readme.
const MATCH_ALL_KEYS = /^/
exports.pluginOptionsSchema = function ({ Joi }) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this missing the cssLoader validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Would appreciate if you open an issue 🙏

@cpboyd
Copy link
Contributor

cpboyd commented Nov 2, 2020

Any specific reason that webpackImporter was excluded?
It's required for any Sass files using @forward syntax which all of Google's Material design styles use now: webpack-contrib/sass-loader#804

My Gatsby projects broke today, due to these changes.

if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
await validateConfigPluginsOptions(config, rootDir)
}
await validateConfigPluginsOptions(config, rootDir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxstbr Isn't this technically a breaking change for all plugins when they remove the feature flag? 🤔
Since these plugins won't work anymore with older gatsby versions, because it now errors out with the message to upgrade.

So if that's correct, the peerDependency of all plugins that remove the feature flag should be updated to gatsby@^2.25.0 (which is a breaking change) or am I forgetting something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxstbr Any thoughts on this? 🤔

quality: Joi.number()
.default(50)
.description(`The quality level of the generated files.`),
withWebp: Joi.boolean()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we can no longer pass an object with quality config for withWebp option?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, it looks something that we missed here. I'll make it back :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available in #27944 😊

mwfrost pushed a commit to mwfrost/gatsby that referenced this pull request Apr 20, 2023
* chore(gatsby): add @gatsbyVersion pragma to pluginOptionsSchema Node API

This will make Gatsby prompt users on old versions of gatsby that don't support the API to upgrade to the new version.

* 2.25.0!

* Remove GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION feature flag

* Fix incorrect option in gatsby-admin;

* Fix tests

* Remove obsolete snapshots

* Trigger Build

* Remove flag from remark-autolink-headers

* Fix gatsby-plugin-mdx default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants