tusken icon indicating copy to clipboard operation
tusken copied to clipboard

Change how the `Database` object is generated

Open aleclarson opened this issue 3 years ago • 0 comments

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 tusken package, so *default commands* can be tree-shaked.
  • Emit database extensions with export const syntax 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.ts to ./database.ts
  • Inside the ./index.ts module, do this instead:
    export * as db from './database'
    export * as pg from './functions'
    export * as t from './types'
    

aleclarson avatar Sep 07 '22 18:09 aleclarson