Whether a dependency should be considered a devDependency
or a direct dependency
depends on how the code utilizing it will be used.
If the code is intended for use by consumers of your package/module/library, then the dependency should be classified as a direct dependency rather than a development one.
Consider the purpose of the source file that utilizes the dependency. When installing a package with npm install your-cool-package
, consumers do not require the devDependencies
since they are only consuming the module without building or testing it.
If the dependency is necessary for the functionality of your module, then it should be categorized as a direct dependency
instead of a devDependency
.
Ask yourself whether the dependency is essential for the functioning of your module. If so, it's a dependency; otherwise, it's a dev dependency.
When creating a plugin, it relies on the thing it plugs into. Consumers may view it as a development dependency, but it still directly depends on the plugin it integrates with.
For instance, if you're developing a plugin (cool-plugin) for a module like Mobx, Mobx would be considered a dependency of cool-plugin because it's needed for its operation.
In this scenario, Mobx should be listed as a dependencies
since cool-plugin cannot function without it.
There's an argument for labeling it as a peerDependencies
to ensure compatibility with the existing version of Mobx used by consumer-module.