Closed cdolek closed 9 months ago
I'm testing the example provided in the readme, and I see the following on the console:
Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438
Thank you. I also encounter this error when running my node app with type: module
in package.json
. However, since I typically bundle my projects for production, I haven't spent much time investigating this issue. It is well documented what this issue means, but I don't know yet how to fix it if this library is the problem. I might take the time to investigate in the future, but feel free to do it before me.
I also had to update the code as the following to make it work
I personally don't use this code, but I only wrote it as a quick example. You are absolutely right, in the current ws version, you have to import the Server like that. I will fix the README soon.
Thank you @MaxNoetzold, I was able to resolve my issue by simply using a bundler (rollup)
I made a basic websocket server with mdb persistence, and I'm facing the same problem discussed in this issue. I could bundle my server code, but I prefer to keep the project straightforward.
@raineorshine, any thoughts on fixing this issue?
I'm not entirely sure about the problem's specifics. I'm guessing y-mongodb-provider and the other yjs libraries might not be on the same page with the default module system (mjs or cjs). Any idea on how I can check this?
It's a really annoying issue.
The first step is to make sure all yjs dependencies in your tree are on the same version. I ran npm ls yjs
on your backend project and they are all on v13.6.11 so that's not the problem.
Something else is causing yjs to be imported twice. I don't know the specific solution in your case, but you can learn more here: https://github.com/yjs/yjs/issues/438
I don't know the specific solution in your case, but you can learn more here: yjs/yjs#438
Thank you. I looked into it before. I will rewrite my server to be written in commonjs just to check if this solves it. Honestly I think that my package.json of y-mongodb-provider defines the exports wrong but I don't really understand it anyways. Ill try to do it as esbuild recommends
When I write the server as pure js commonjs node application it works totally fine.
So the problem has to be that the export of y-mongodb-provider as an esm module is wrong?
I'll test it this week on https://github.com/MaxNoetzold/y-mongodb-provider/tree/fix-esm-export. Looks promising
Now actually solved with pr#12
Thank you for this package!
I'm testing the example provided in the readme, and I see the following on the console:
I also had to update the code as the following to make it work:
Using the following: