tusken
tusken copied to clipboard
Change how the `Database` object is generated
Currently, Rollup cannot treeshake db.xyz access, because ES6 classes are not treeshaked.
Instead of there being a Database class with the generated client having a singleton instance, do the following:
- Move all commands into plugin dependencies of the
tuskenpackage, so *default commands* can be tree-shaked. - Emit database extensions with
export constsyntax instead of using a subclass, so plugin methods can be treeshaked if not used in a bundle. - Refactor database state into a POJO stored in a global variable. Then make this POJO the default database context of each database method.
- Now move the database state & methods from
./index.tsto./database.ts - Inside the
./index.tsmodule, do this instead:export * as db from './database' export * as pg from './functions' export * as t from './types'