-
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
chore(*): bump of sharp for Node v12 compatibility #13646
Conversation
This turns out to be more problematic than I thought - we already tried bumping The other problem is that even if we do update it here all at once. Users might update just one of those and will hit similar problems, so we do need a way to handle that (it's not yet clear what's best approach, but my initial thought is to check versions of sharp that are installed, and if there is more than one, suggest updating all packages that depend on sharp) |
@pieh Looking through the |
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.
Definitely looks more complete. Thanks for reviewing.
Even if my commit fixes the tests - the PR is still blocked by not handling mismatched sharp versions |
👍 we could just add this to core I think |
@pieh if we're updating all sharp versions why is this blocked? I'm not understanding. |
Because if user will update just single package that depend on sharp he will hit error like:
You can try it for yourself by creating new project from |
I opened issue/question in |
Thank you @pieh |
As mentioned in #13781 (comment) adding warning seems really unfeasible, so best way forward is to document how to troubleshoot this (hopefully section I wrote would be easily google'able and would come up as top result after searching for the exact error) |
One note - I added troubleshooting section to one plugin (for now). And I plan to copy it over to rest of the plugins docs, which I would do after review/feedback |
With the Ink change Ward is working on, couldn't we detect certain errors and show a help message? Obviously that's not ready yet so just thinking through options. Also is there a cheap way to ask node what versions of a module are resolvable? We could detect mismatches this way. |
This relies on user having updated Gatsby core (if we would implement it), which is the problematic scenario - user add or updates single package without updating all of them.
We can try We could try to take this upstream and add instructions directly in |
Ok, I think I can scratch my previous comment as it wasn't entirely true it seems - the problem only occur when older sharp version was loaded first - other way around it works (so for some users - depending on order of their plugins in gatsby-config - they might use different version of sharp without problems). But luckily thanks to that, we can actually catch problematic error (when newer sharp is loaded later). I pushed WIP of sharp error message decorated with Gatsby specific instructions. Those instructions are still TO-DO, but we do get list of packages that depend on sharp along with sharp version, so the message should mention to update them (if |
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.
I like it! I'm unsure if we should show the original error but the advice is 👌
feel free to merge.
@sidharthachatterjee just mentioned that checking error message when determining if we should show message might be too naive, investigating it now (i.e. see what error looks like on ubuntu and windows - it seems to me like it may be platform specific error) |
Soooo, this error happen only on OSX - Ubuntu and Windows work just fine :O |
I was considering hiding it, but because of general hackiness of this code I thought that not swallowing original message is safer option (in case Gatsby specific advice doesn't work or apply, user have more feedback to try to find solution or create issue about it) |
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.
Looking good!
Left a few grammar suggestions and a few questions
let tmpMsg = [] | ||
// npm list seems to work in yarn installed projects as well | ||
const { dependencies } = JSON.parse( | ||
childProcess.execSync(`npm list sharp --json`, { |
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.
Does this factor in a lock file? Would this be inconsistent in case there are both lock files?
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.
good point, it will make use of package-lock.json
if it's available and potentially show not accurate results. If lock file doesn't exist, it will traverse node_modules
. This makes it very hard to support, but I think maybe opting out of it if both yarn and npm lock files exist seems reasonable?
Note: Remember to add |
Hey @polishedwp, could you commit suggestions made by @sidharthachatterjee? It seems like I can't do it because it's not my PR :) |
Looks beautiful! |
Co-Authored-By: polishedwp <chuck@polishedwp.com>
@polishedwp I think @pieh was requesting you apply the suggestions, not merge the PR! |
Co-Authored-By: polishedwp <chuck@polishedwp.com>
@DSchau Ok, I think I have now. |
Sorry for confession @polishedwp :( There are couple of suggestions left - to get them all at once you can go to https://github.com/gatsbyjs/gatsby/pull/13646/files , scroll through code changes, use "Add sugestion to batch" button in suggestion UI and when all are added to batch, on top there is "Commit suggestions" to actually create commit with all the changes I really appreciate it and once more, sorry for inconvenience. |
Co-Authored-By: polishedwp <chuck@polishedwp.com>
Co-Authored-By: polishedwp <chuck@polishedwp.com>
Co-Authored-By: polishedwp <chuck@polishedwp.com>
Co-Authored-By: polishedwp <chuck@polishedwp.com>
Co-Authored-By: polishedwp <chuck@polishedwp.com>
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 should resolve the commits
Co-Authored-By: polishedwp <chuck@polishedwp.com>
@pieh @sidharthachatterjee This should commit the changes. Sorry, what was a simple PR for me, quickly accelerated past my experience level. Thanks for all you all do. |
It wasn't really expected to be so complex from my initial issue discovery. Don't worry, and thanks for being so responsive here! |
This should be good to go now |
Description
Version bump of sharp in
gatsby-plugin-sharp
for Node v12 compatibility. Fixes #13635