Open minht11 opened 2 years ago
Thanks for the input. New built-in features, like liveQuery was added in respect of tree-shakability. Old methods have been kept so far for backward compatibility. In my view, all the static Dexie methods should be moved out and become tree-shakable in dexie@4.0. Keeping this issue open.
I would prefer way how rxjs solve this using operators instead of methods. Each operator is imported separately when needed, lovely architecture ❤️.
Right now if you want to use one method of the library you have to pay the bundle size cost of them all. If you want to use sort you must also include filter. If you want to just insert item into DB you must also include delete method and the problem is that Dexie has a lot of of methods, in a future it's likely that there will be even more. That's not ideal, so making things more treeshable would be big win. I am not quite sure on the exact API and it's very likely that this would be a breaking change unless treeshable API would be provided together with the old one.
Maybe each table creation could take composable with methods it want to use, so typescript types and chaining API still works like this
or/and each method can be a function instead which takes table or DB as an argument like
put(db, ...restOfTheArgs)
instead. Similar how it's done here https://github.com/jakearchibald/idb-keyval/blob/main/custom-stores.md