Implementing a websocket-server on which a y-websocket provider can rely requires using lib0 and y-protocols.
y-protocols exposes esm modules (i’m not sure if that’s the right term) for awareness and sync with type-definition, while the example y-websocket server uses the y-protocols/dist/*.cjs libs. The esm modules give error when I try to run the code compiled with typescript
The y-protocols/dist/*.cjs libs have no type definitions, which makes it impossible to use them in a typescript setup (and I cannot give up typescript).
How can I get started with building a typescript websockets server that is horizontally scalable, persists y-js documents, and which y-websocket can connect to as a provider while maintaining proper typescript typings?
Instead of importing lib0/encoding.js, you can import lib0/encoding. This should give you typings and automatic module resolution to the cjs files if you are running a current node version.