ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.53k stars 334 forks source link

Having multiple versions of prosemirror-state and prosemirror-view installed causes issues #1471

Closed stof closed 1 month ago

stof commented 1 month ago

We recently added @policyco/prosemirror-tables in our project. As it depends on prosemirror-state and prosemirror-view, yarn pulled their latest versions to satisfy those dependencies. However, our project was using an older version of those packages (we were 1 or 2 version late for those as we had not updated our dependencies just before). Mixing different versions caused bugs like Uncaught TypeError: this.members[i] is undefined in webpack://incenteev/node_modules/prosemirror-view/dist/index.js:4191 (when a selection is added by the tables plugin which uses the newer version of the package to import the selection classes and so imports a different one) which got solved by updating all prosemirror packages to ensure we don't have duplicate versions.

In Codemirror packages, dependencies on the state and the view are listed both as dependencies (so that they are installed automatically without requiring extra work) and as peerDependencies (so that package managers reuse the same package for all the Codemirror packages being siblings in the tree, instead of pushing them to use different versions when doing partial updates of the tree). Would it make sense to use the same pattern in prosemirror packages (and to encourage third-party plugins to do it as well) ?

marijnh commented 1 month ago

peerDependencies does not solve this. You'll want to move from yarn to npm. Recent version of that tool are actually capable of properly deduplicating your dependencies. There isn't anything ProseMirror itself can do about this.