Skip to content

Conversation

benedictjohannes
Copy link

Description

This PR aligned all safe-sharp.js in official packages and move sharp from direct dependencies to peerDependencies.

Documentation

Moving sharp from direct dependency into gatsby-sharp in all packages would probably cause sharp to not be installed when Gatsby is being used without installing gatsby-sharp.
Yarn or other package managers would warn that a peerDependency is not fulfilled and/or installing them by default.
This might warrant a mention of installing gatsby-sharp in documentation pages pertaining to Gatsby image processing.

Tests

I did not run automated e2e tests that are in this repository. Instead I use the modified packages via yarn link. No problem occurred for my site that use gatsby-plugin-sharp. As the changes are identical with other packages, I think this change will do identically.

Related Issues

These commints carry forward #34339 and should be a way to move forward to allow for single sharp instance source for all Gatsby plugins.
The "friction" mentioned in safe-sharp.js files can be mitigated with documentation, and developers familiar with dependency updates should not face any issues.

All `safe-sharp.js` is now identical, where
all are calling `gatsby-sharp` in a try-catch
with fallback to directly requiring sharp
As `sharp` is already a dependency of `gatsby-sharp`,
it is not necessary to include `sharp` in dependencies.
Instead, peerDependencies should include
`gatsby-sharp` as per best pratices in
dependency management.
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant