ably / spaces

The Spaces SDK enables you build collaborative spaces for your application and enable features like Avatar stack, Live cursors, Member location, Component locking and more.
https://space.ably.dev/
Apache License 2.0
43 stars 7 forks source link

Downgrade to using nanoid@3 to support its use in CJS module bundle #307

Closed VeskeR closed 4 months ago

VeskeR commented 4 months ago

Resolves #306

Starting from nanoid v4, it only works with ESM projects. We need to support both CJS and ESM bundles for the spaces SDK, so we have the following options to use the nanoid package:

  1. Replace require('nanoid') imports with async await import('nanoid'). This solution is not suitable as the methods we currently use nanoid in are not async, and changing them to async will create cascading effects for a bunch of other methods and change the public API for users.
  2. Replace the nanoid package with an in-project utility function to generate ids. This may be undesired since nanoid uses different crypto packages for its browser and Node.js bundles with some other platform-specific optimizations. Including them locally would not be a trivial change.
  3. Downgrade to using nanoid v3, which supports both CJS and ESM and is still being supported by the developer. This is the option implemented in this PR.

This PR also disables major version updates for nanoid package by GitHub dependabot.