-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK-3717] Add tree-shakable BaseClient and Rest exports #1400
Conversation
tl;dr: there's a circular import here between utils.ts and defaults.ts. in the following commits this results in a build error, so i'm making utils.ts no longer depend on defaults.ts.
This commit adds: - A minimal BaseClient which takes a map of encapsulated modules which can be provided through the constructor. These modules work like plugins, adding features to the BaseClient. - An encapsulated Rest module/plugin which is compatible with the BaseClient The existing Rest class is moved to DefaultRest and is refactored to use the BaseClient and new Rest module
f818643
to
76d2ab0
Compare
76d2ab0
to
75eaaf8
Compare
75eaaf8
to
8045412
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving (with one comment), but as discussed offline, I'm still not sure whether it makes sense to combine the realtime and REST functionality into a single BaseClient
class. My preference would be to resolve this matter before merging this PR, but if you'd prefer to defer the decision until a bit later then that's cool too 👍
@owenpearson can we remember to link PRs to the jira issue they are fixing please. Happy to have a discussion about why this is required need be. It can be done by tagging the issue key in the title. see ably/ably-go#596 This ask is now reflected in: https://github.com/ably/engineering/blob/main/best-practices/pull-requests.md |
8045412
to
d232195
Compare
available to import from 'ably/modules'
d232195
to
bb31ed8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update the format
task to include this file?
Replaced by #1417. |
Resolves #1374
Refactors the existing
Rest
class intoBaseClient
and an encapsulatedRest
class which can be passed in to theBaseClient
constructor to allow access to the rest interface.The tree-shakable modules are currently available as an esm module from 'ably/modules', example usage:
A new npm script (
npm run modulereport
) is added which displays information about the size of each module in the bundle-report workflow. Currently (76d2ab0) the output shows:These numbers will be lower after we encapsulate further functionality into tree-shakable modules.