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

Clean up dependencies/peer dependencies for image plugins #4387

Closed
jlengstorf opened this issue Mar 6, 2018 · 1 comment
Closed

Clean up dependencies/peer dependencies for image plugins #4387

jlengstorf opened this issue Mar 6, 2018 · 1 comment
Assignees
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation

Comments

@jlengstorf
Copy link
Contributor

Looking deeper into #3545, it looks like things are a little weirder than I initially thought.

I do have gatsby-plugin-sharp installed as a dependency in my site, but not included in the plugin array inside gatsby-config.js.

My guess is that this doesn't fail because gatsby-transformer-sharp is directly importing what it needs, as is gatsby-remark-images.

Currently, gatsby-plugin-sharp is a direct dependency of gatsby-remark-images and not referenced at all in gatsby-transformer-sharp.

To experiment with this, I installed gatsby-plugin-sharp but did not add it as a plugin to Gatsby, then added gatsby-remark-images as a plugin and everything worked as expected.

So this poses two questions:

  1. Is gatsby-plugin-sharp actually a plugin? Or is it a utility package that other plugins rely on?
  2. Given that both gatsby-transformer-sharp and gatsby-remark-images work without gatsby-plugin-sharp being added as a plugin, would it make more sense to add it as a dependency to both for an easier setup?
@jlengstorf
Copy link
Contributor Author

Had an offline conversation with @KyleAMathews that clarified this.

  • gatsby-plugin-sharp manages a job queue that tells the Gatsby bootstrap process when it's complete
  • It's possible to run without this reporting, but likely that problems will occur at some point.
  • There is an idea (see Add a generic jobs logging framework to the Gatsby core to allow custom plugin logging #4299) to move this job queue/reporting into the core, which would eliminate the dependency on gatsby-plugin-sharp for other plugins — instead, the logic would be moved into a utility package (e.g. gatsby-sharp) that would not need to be added as a Gatsby plugin.
  • For now, gatsby-plugin-sharp should be a peerDependency of both gatsby-remark-images and gatsby-transformer-sharp and MUST be declared in the gatsby-config.js plugin array.

I'll submit a PR for this shortly.

@jlengstorf jlengstorf self-assigned this Mar 6, 2018
@jlengstorf jlengstorf added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Mar 6, 2018
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

No branches or pull requests

1 participant