Background at https://github.com/netlify/docs/issues/1064 and https://github.com/netlify/next-on-netlify-enterprise/issues/16
We should document the new compatibility
field in this repository's Markdown documentation.
This field is currently used by our own plugins. Based on discussion about it with @verythorough, we should first wait a bit while we try this new field out before documenting it.
Previously it was not possible for plugins to add breaking changes. We have added a new compatibility
field in plugins.json
to support some specific (not all) types of breaking changes.
That field is optional. When present, it looks like this:
{
"author": "netlify-labs",
"description": "Automatically run a Lighthouse audit on your site after every build",
"name": "Lighthouse",
"package": "@netlify/plugin-lighthouse",
"repo": "https://github.com/netlify-labs/netlify-plugin-lighthouse",
"version": "2.0.0",
"compatibility": [
{
"version": "1.4.3",
"nodeVersion": "<12.13.0"
}
]
}
In the above example: sites with a Node.js version below 12.13.0
will use @netlify/[email protected]
, while other sites will use @netlify/[email protected]
. This applies to all sites, both new and existing ones, as soon as the PR in netlify/plugins
is merged.
In other words, compatibility
lists previous versions of a plugin for backward compatibility purpose. When no compatibility
versions matches, the top-level version
is used instead.
compatibility[*].version
is an npm exact version, just like the top-level version
.
The currently available condition properties are:
nodeVersion
(see example above), which checks against the site's Node.js version. Any semver ranges can be used.
siteDependencies
, which checks against the dependencies
or devDependencies
in the site's package.json
. Any semver ranges can be used.
{
...
"version": "2.0.0",
"compatibility": [
{
"version": "1.4.3",
"siteDependencies": { "next": "<=10.0.5" }
}
]
}
When a site is using a plugin's compatibility
version, a warning message is printed in the build logs, indicating that a new version of the plugin is available but that specific conditions must be matched in order to use it. For example, this would print something along the lines of "[email protected] is outdated: [email protected] is the latest version but this is incompatible with next <=10.0.5".
It is also possible to specify a migrationGuide
URL which will be printed in that warning message.
{
...
"version": "2.0.0",
"compatibility": [
{
"version": "1.4.3",
"siteDependencies": { "next": "<=10.0.5" },
"migrationGuide": "https://github.com/netlify/netlify-plugin-example/MIGRATIONS.md#2.0.0"
}
]
}