It depends on how the code that will import the dependency will be used. If it will only be used in a development context, then yes, it should be a devDependency
and it's fine for the code to use it.
If the code that uses it is going to be used by a consumer of your package/module/library, then it is a direct dependency and should be annotated as such.
It's kind of how you view the intention of the source file that consumes the dependency. If I install with npm install your-cool-package
, I don't want, and shouldn't need the devDependencies
installed because I'm likely not going to be building your module from source, benchmarking, or testing. I'm just going to consume it.
If I need the dependency to consume your module, then it isn't a devDependencies
, it is just a straight up dependencies
(or maybe a peerDependencies
).
Ask yourself this: When I use your module, for it to function, does the dependency need to be there for it to function? If it does, it's a dependency. If not, it's a dev dependency.
If you author a plugin for something, it depends on the thing it plugs in to. If you author a plugin that helps people develop things, the plugin still depends on what it plugs in to, but the person installing your plugin would consider your plugin a development dependency because they don't need it when they aren't developing. However, your plugin still depends directly on the thing that it plugs in to.
It sounds like you are writing a plugin (let's call it cool-plugin) for a module (Mobx). I don't use Mobx, but it sounds like a development tool. Since it sounds like cool-plugin needs Mobx in order to do anything Mobx is a dependency of cool-plugin, but a consumer would consider cool-plugin a devDependencies of their own hypothetical consumer-module because they don't need it in production.
Because of that, you should consider Mobx a dependencies
because your module doesn't make sense without it.
There is a case to be made that you should actually consider it a peerDependencies
because consumer-module probably doesn't want you to install your own version of Mobx but instead wants you to interface with the one they should already be using.