Has anyone confronted this issue when creating plugins for libraries that already use Yjs? For example, WordPress imports yjs in its editor code, but a WordPress plugin may want to extend this behavior (e.g., customize an awareness implementation). However, the JavaScript bundles for WordPress and a separately distributed plugin must by definition be built separately, which leads to the conflict described in the linked GitHub issue.
Does Yjs provide a way to use dependency injection or some other means to avoid this conflict? Thanks!
This works! Instead of using an actual module, I created a shim file:
// yjs-shim.ts
// To avoid issues with default exports, you must individually export the
// properties you need, including those used by dependencies.
export const applyUpdate = window.Y.applyUpdate;
export const encodeStateVector = window.Y.encodeStateVector;
export const encodeStateAsUpdate = window.Y.encodeStateAsUpdate;
export const Doc = window.Y.Doc;