Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Downgrade to using nanoid@3 to support its use in CJS module bundle (#…
…307) * Downgrade to using nanoid@3 to support its use in CJS module bundle 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 developers [1]. This is the option implemented in this commit. Resolves #306 [1] https://github.com/ai/nanoid?tab=readme-ov-file#install * Prevent `nanoid` major version updates by dependabot
- Loading branch information