CM4/5 conflicting with CM6

I’m working on a language package for CM6 and have noticed that it works great when installed on its own, but when installed on a web page that also uses either CM4 or CM5 my extension doesn’t work at all. It seems these older versions of CM are somehow conflicting with CM6 or my language package? They’re not used in the same place so I don’t know how that could be, but is there something I need to do to keep my CM6 extension safe from older versions of CM?

This isn’t a known problem, and I can’t think of how it might be happening. Have you tried reducing it to a minimal setup?

doing that now.

OK so I noticed that my language package had its own node_modules/@codemirror/language. Once I deleted that dir, it worked. I should have thought of that earlier. Changing to use peerDependencies for @codemirror stuff is the correct fix for this, right? If so I can submit a PR to change the @codemirror/lang-example to use that.

It will be, once npm versions lower than 7.0 die out, which might unfortunately take a while yet. Right now, using peerDependencies will just cause things to fail to install on old npm versions, and there doesn’t seem to be a proper solution to this, except reinstalling your dependencies whenever it happens.

gotcha. The problem with not using peerDependencies (at least with yarn) is that my language package ends up using a separate @codemirror/language, so despite adding it to the EditorState config, its highlighting doesn’t happen at all. Not sure if there’s a solution that will work for both new and old npm/yarn/etc.