Is it safe to use several instances Yjs in application if it's never interact?

Hi, we have application that build with webpack and contains of federated modules with isolated dependencies.

Recently we had warnings like in issue Yjs was already imported. · Issue #438 · yjs/yjs · GitHub I have question about it.

Is it safe to have 2 isolated modules if each of it have own Yjs package?

This modules is not interact with each other at all or interact by some API, but code from one module is never use Yjs from another module.

Maybe Yjs is write some objects to a global object and 2 imports from different packages may rewrite something important and lead us to problems?

I’ve read this commit add warning when Yjs was already imported · yjs/yjs@cbddf6e · GitHub and i guess that Yjs is write to global object only importIdentifier, and for our specific case we may use 2 different Yjs package, because inside one module the code use only one package always

If I were you, I’d fix the issues. Even if the modules are completely isolated (I’m not sure how that can be achieved), it doesn’t make sense to have duplicate dependencies.

I created this warning because several projects with supposedly isolated modules experienced issues that were impossible to debug.

Could you explain cause of this problems, please?

Is yjs package write some data to a globalThis (except symbol for warning message) and do instanceof comparison with this global objects?

The problem is that constructor checks won’t work anymore between different Yjs bundles. One scenario is that the provider (e.g. y-websocket) uses Yjs bundle 1 to sync updates, but the supplied Yjs document was created using Yjs bundle 2. The issue will be very hard to debug as content will just seem to be missing. There are many other potential issues, so it is best to avoid these issues.