Gatsby: Question: Is Gatsby a devDependency or dependency?

Created on 20 Apr 2017  路  4Comments  路  Source: gatsbyjs/gatsby

I have looked at some of the starters, and they all seem to specify Gatsby under dependencies in package.json: gatsby-starter-default, gatsby-starter-kitchen-sink, gatsby-starter-documentation

Is there a reason it's not under devDependencies instead?

Most helpful comment

A Gatsby site without Gatsby can't do anything so it's a dependency.

A devDependency is for packages that are published to NPM so you need to differentiate between packages needed by "consumers" of a package vs. "producers". Since anyone using a Gatsby repo is a producer, everything goes in dependencies.

All 4 comments

A Gatsby site without Gatsby can't do anything so it's a dependency.

A devDependency is for packages that are published to NPM so you need to differentiate between packages needed by "consumers" of a package vs. "producers". Since anyone using a Gatsby repo is a producer, everything goes in dependencies.

@KyleAMathews I think that's good as a general rule, but it seems like it may be overly restrictive. For instance, a library with documentation generated by Gatsby might want to have gatsby as a devDependency. Would you be opposed to something like require('gatsby') in the try/catch, rather than looking at the dependencies in package.json? https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-cli/src/index.js#L14

@michaek good point. Yeah there are definitely cases where devDependencies makes more sense.

require('gatsby') wouldn't work as that's relative to the CLI. The resolveCwd could work but node resolution is such that it looks up the hierarchy for modules until it finds something. Which is perhaps what we want (you could run gatsby develop in a sub-directory of a site and it'd work) but it would be a change of behavior.

If nothing else, checking for gatsby in devDependencies in gatsby-cli should definitely happen.

Was this page helpful?
0 / 5 - 0 ratings