refactor!: Introduce subpath exports and remove server-registry abstraction in loro-adaptors#25
Merged
refactor!: Introduce subpath exports and remove server-registry abstraction in loro-adaptors#25
Conversation
…stry abstraction
This commit refactors the `loro-adaptors` package to improve modularity and
make peer dependencies truly optional.
Previously, importing from `loro-adaptors` would implicitly pull in all
peer dependencies, leading to "Could not resolve" errors if a user only
intended to use a subset of adaptors (e.g., only `flock` without `loro-crdt`).
Additionally, the `server-registry` abstraction was identified as unnecessary.
This change addresses these issues by:
- Introducing subpath exports for specific adaptor groups:
- `loro-adaptors/loro`: Exports `LoroAdaptor`, `LoroEphemeralAdaptor`,
`LoroPersistentStoreAdaptor`, `EloAdaptor`, and their server counterparts.
This requires `loro-crdt` as a peer dependency.
- `loro-adaptors/flock`: Exports `FlockAdaptor` and `FlockServerAdaptor`.
This requires `@loro-dev/flock` as a peer dependency.
- `loro-adaptors/yjs`: Exports `YjsAwarenessServerAdaptor` for Yjs awareness.
This requires `yjs` as a peer dependency.
- Refactoring `src/index.ts` to only export general types and core utilities,
effectively making it a lean entry point without direct adaptor implementations.
- Removing `src/server/server-registry.ts` and the `AdaptorsForServer` interface
from `src/types.ts`, as this abstraction was deemed unnecessary.
- Updating `package.json` `exports` and `tsdown.config.ts` entry points to reflect
the new modular structure.
- Updating `README.md` with revised installation instructions and usage examples
for the new subpath imports.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit refactors the
loro-adaptorspackage to improve modularity andmake peer dependencies truly optional.
Previously, importing from
loro-adaptorswould implicitly pull in allpeer dependencies, leading to "Could not resolve" errors if a user only
intended to use a subset of adaptors (e.g., only
flockwithoutloro-crdt).Additionally, the
server-registryabstraction was identified as unnecessary.This change addresses these issues by:
loro-adaptors/loro: ExportsLoroAdaptor,LoroEphemeralAdaptor,LoroPersistentStoreAdaptor,EloAdaptor, and their server counterparts.This requires
loro-crdtas a peer dependency.loro-adaptors/flock: ExportsFlockAdaptorandFlockServerAdaptor.This requires
@loro-dev/flockas a peer dependency.loro-adaptors/yjs: ExportsYjsAwarenessServerAdaptorfor Yjs awareness.This requires
yjsas a peer dependency.src/index.tsto only export general types and core utilities,effectively making it a lean entry point without direct adaptor implementations.
src/server/server-registry.tsand theAdaptorsForServerinterfacefrom
src/types.ts, as this abstraction was deemed unnecessary.package.jsonexportsandtsdown.config.tsentry points to reflectthe new modular structure.
README.mdwith revised installation instructions and usage examplesfor the new subpath imports.