Gatsby: [bug]: add warning in Gatsby core when multiple versions of sharp detected

Created on 1 May 2019  路  4Comments  路  Source: gatsbyjs/gatsby

Description

Several of our plugins require sharp@^0.21.3 which does _not_ resolve to the latest version of sharp.

[email protected] seems to have severe issues with Node 12, therefore our plugins should be upgraded to account for this. However--we want to do so in a way that is transparent to the end user, and doesn't introduce breaking changes if e.g. only one plugin is updated but others aren't (or at least warn in this scenario in Gatsby core!).

Steps to reproduce

Upgrade to Node 12. Run gatsby new something and see the yarn install or npm install step fail as in #13780

Expected result

It should successfully install

Actual result

It doesn't.

Environment

Node 12, [email protected].

Steps

  • [x] Upgrade sharp in gatsby-plugin-sharp
  • [x] Upgrade sharp in gatsby-transformer-sharp
  • [x] Upgrade sharp in gatsby-plugin-manifest
  • [x] Upgrade sharp in gatsby-remark-images-contentful
  • [x] Add warnings in core if _our_ packages depend upon different versions of sharp

The last of these is being worked on by @davidbailey00 (but if someone else wants to tackle this--more than welcome to do so!), so it'd be nice to get that in _before_ we bump the versions in the plugins to be as low-impact as possible to our end users.

Related Issues / PRs

See #13646

confirmed bug

Most helpful comment

I did more discovery on last remaining step of resolving this and it really turns out that any solution has some problems and is not guaranteed to work, so what I will do, as add "Troubleshooting" section to 4 packages that depend on sharp and document what is needed to be done to resolve errors that show up when you have mismatched sharp versions.

All 4 comments

I did more discovery on last remaining step of resolving this and it really turns out that any solution has some problems and is not guaranteed to work, so what I will do, as add "Troubleshooting" section to 4 packages that depend on sharp and document what is needed to be done to resolve errors that show up when you have mismatched sharp versions.

Out of curiosity, is there a specific reason not to change it to a peer dependency?
e.g. https://www.gatsbyjs.org/docs/migrating-from-v1-to-v2/#manually-install-plugins-peer-dependencies

That way the user gets to choose what version they install.

@cpboyd That's what we are planning on doing in Gatsby v3, but we felt that it would be detrimental if we changed the behaviour now, since it would break a lot of 3rd party Gatsby tutorials e.g. on blog sites and would require manual intervention upon upgrading packages.

https://github.com/gatsbyjs/gatsby/pull/13646 was merged (sharp updates and warning messages), so this this is handled

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalinchernev picture kalinchernev  路  3Comments

theduke picture theduke  路  3Comments

ferMartz picture ferMartz  路  3Comments

timbrandin picture timbrandin  路  3Comments

jimfilippou picture jimfilippou  路  3Comments