Move prosemirror-view to peerDependencies #28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ocavue/rm-view-dep"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently,
prosemirror-viewdepends onprosemirror-state, andprosemirror-statealso depends onprosemirror-view. This causes a circular dependency.prosemirror-statedoesn't actually needprosemirror-viewfor runtime JS (see prosemirror-state/dist/index.js); it only needsprosemirror-viewfor some types (see prosemirror-state/dist/index.d.ts).This situation is mostly okay but still has subtle differences. For example, if I want to use
prosemirror-stateandprosemirror-modelto apply some updates on the Node.js server side,npmwould still installprosemirror-viewin thenode_modules, although I don't need it at all.This PR improves it by moving
prosemirror-viewfromdependenciestopeerDependencies.peerDependenciesis still needed so that TypeScript can find the required type during development for type checking.I also tweaked the source TypeScript code a bit by using
import type {...} from "..."instead ofimport {type ...} from "...". This adds an extra assurance that we don't importprosemirror-viewin the runtime JS code, even ifverbatimModuleSyntaxis enabled.My experience with
peerDependenciesis that different packaging tools (and different versions of packaging tools) handle it in weird, unreliable ways. Installing an extra package in a situation where you don't really need it doesn't seem like a big enough problem to open that can of worms again. And also, when you're using TypeScript in the depending package, you'll really want prosemirror-view installed or TypeScript will fail to typecheck the prosemirror-state declaration files.As such, I don't think this is a good idea.
That's true, and that's why I added
peerDependenciesMetaso that it can be truly a peer dependency. See the following npm docs as an example. All other modern package managers (i.e., excluding Yarn v1) are using the same behavior now, AFAIK.o(≧▽≦)o
Fair enough. It's a little embarrassing that we have a circular dependency here, but I can live with it. Thanks for your fast reply! Going to close this.
Pull request closed