How to accept extensions at runtime?

I maintain a library built on top of CodeMirror 6 called Ink, and I am working to allow consumers of the library to supply extensions that can be passed directly to CodeMirror. I’m running into a problem with instanceof checks though, because the consumer of the library has to import from @codemirror/* packages in order to create a useful extension. This leads to multiple versions of the CodeMirror library being bundled and the instanceof error at runtime when supplying an extension to Ink. This article has some good ideas for type-checking objects without relying on instanceof, but I imagine that would be a pretty big lift to implement. Curious to hear your thoughts!

My position is that, in a client-side setting, you really don’t want to load the CodeMirror core libraries multiple times (they are not small), so if you are, instanceof not working is the least of your problems.

Find some way for user code to get access to your instances of the @codemirror packages, if you want to go this way, I guess.