Add missing peer deps
Let me not agree with you based on two points:
-
what about devs who don't need types. Why should they install
monaco-editorpackage, they absolutely don't need it. -
this line
yarn add @monaco-editor/react monaco-editoras an installation instruction can be confusing; they can think that monaco-editor is a dependency and it will be included for example in the final bundle.
So, in any case, it's not a big deal, but I am in favor of keeping things clear. The other question is - maybe it should be devDependency. Whatever, for now, I just separated npm and yarn installation lines as you showed in PR and added a note for types.
I think you should always install peer dependencies. I looked it up just to be sure and it says:
“ The difference shows up in how npm performs dependency resolution: rather than getting its own copy of a peer dependency, a package expects that dependency to be provided by its dependent.” - http://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/
So if I were consuming your package, I would expect it would require me to add monaco-editor as a result. If you look at the other libraries they make you install them too. Also it’s not just about typescript, even if you don’t use typescript vscode can still resolve types using the type default provided.
I got your point.
When I was writing my previous message, I thought that maybe it should be a dev dependency, because at least it seems like dev dependency. This library uses it for types, your editor also uses it, but all that during development, in production we don't need anything from monaco-editor package, just types during development. But... there are some problems.
First - Dev dependencies are not installing when you use the package directly from npm. I mean when you write npm install xyz, npm will "install" only dependencies of xyz. If you clone xyz repository and run npm install, npm will install both dependencies and dev dependencies. (detailed here)
Second - do we need other dev deps? in most cases no, just types.
So, I faced the problem of "types". To be honest, I never thought about it. I've just found lots of discussions (check, check), where people were talking about where to put @types/xyz, in deps or in dev deps. And the only argument to put @types/xyz to deps is to keep it "installable". So, I can't find a consensus around it. I just need to take more time on this topic to find the right way.
I wonder if we could install monaco-editor as a dev dependency for types in development.
In production (when someone uses it), in the document, we could do something like:
## Use TypeScript?
yarn add @monaco-editor/react monaco-editor
That way it gives the idea that monaco-editor is only for types. Or does it prevent from installing if someone uses JavaScript too if monaco-editor is not included?
I use typescript and need the dependency, but I don't feel it should be included. It doesn't make sense to force those to download/update it who don't need it (non-typescript users).
There really needs to be optional or conditional peer-dependencies within npm, but that's out of scope for this.