yjs / y-websocket

Websocket Connector for Yjs
https://docs.yjs.dev/ecosystem/connection-provider/y-websocket
MIT License
523 stars 261 forks source link

Set type to ESM module, update CommonJS .js files to .cjs #88

Closed TeemuKoivisto closed 2 years ago

TeemuKoivisto commented 2 years ago

Hey so this is a PR to fix the problems as described here https://github.com/yjs/y-websocket/issues/72 Basically as of now, the ESM module import in "exports" is invalid according to the spec. Which some bundlers import despite of it, SvelteKit is perhaps the strictest on this which makes importing the library impossible without modifications (or reverting to an older version).

So I changed the "type" back to module as it was at some point and updated the CJS files to .cjs which ought to keep things working in downstream repos as it was before. I think this works now ok but let me know @dmonad

Huly®: YJS-764

dmonad commented 2 years ago

Thank you for this @TeemuKoivisto!

My plan was to transform the server to a proper ESM module. I did so in https://github.com/yjs/y-websocket/pull/89

I will close this PR because I believe that transforming that ESM is the way to go in the future. We can still keep compatibility to cjs if needed.

TeemuKoivisto commented 2 years ago

Awesome! That's even better 🙂