Open samuelstroschein opened 2 weeks ago
Arguments for tree-shakable:
await commit(lix, { args })
await merge(lix, { args} )
await resolveConflict(lix, { args })
Arguments for an all in one object
await lix.commit({ args })
await lix.merge({ args} )
await lix.resolveConflict({ args })
I tend to favor tree-shakable. The lix
object would become state. Nothing more, nothing less. Smaller bundle sizes, potentially enabling use cases that are restricted in bundle sizes, and easier testing.
I forgot about Paraglide JS style tree-shaking + API discovery! This seems to combine the best of both worlds!
import * as sdk from "lix-js/sdk"
// full api discovery for every sdk api
sdk.x
// even `openLix()` is now discoverable
const lix = await sdk.openLix()
// "state" related functions are discoverable + tree-shakable 🎉
await sdk.commit({ lix, ... args })
await sdk.merge({ lix, ... args })
await sdk.resolveConflict({ lix, ...args })
In case you wonder why I do import * as sdk
and not import * as lix
, I intend to delay discussions on how to call a lix. For branding purposes, I think we can just go with lix (instead of repo, project, etc.). The import * as X api is a variable declaration. Hence, we don't have to make a decision right now.
Context
We are exposing a mix of tree-shakable and non tree-shakable APIs atm.
Proposal
Settle on one consistent approach.