arthurhsu / lovefield-ts

Lovefield TypeScript port: successor of google/lovefield
Apache License 2.0
47 stars 3 forks source link

Create dist and npm package #7

Closed arthurhsu closed 4 years ago

arthurhsu commented 6 years ago

Create dist and npm package, while keeping most of the Lovefield public API usage. This will need to write a sample test to test usage of it (maybe the harness min one).

arthurhsu commented 6 years ago

First attempt: use rollup and its TypeScript plugin. It successfully generates lf.js, but there are two showstopper:

  1. It does not allow me to control what to export
  2. It does not generate .d.ts (that's a real show stopper)

The rollup config tested is

import multiEntry from 'rollup-plugin-multi-entry';
import typescript from 'rollup-plugin-typescript2';

export default {
  input: 'lib/**/*.ts',
  output: [{
    name: 'lf',
    file: 'dist/lf.js',
    format: 'umd'
  }],
  plugins: [
    multiEntry(),
    typescript()
  ]
}
Brooooooklyn commented 6 years ago

Use one index.ts to export everything you want and this index.ts would be the entry too. And it would make rollup and https://www.npmjs.com/package/dts-bundle-generator easy to setup.

arthurhsu commented 5 years ago

Dist target created, now it can generate one single TypeScript file, that in turn compile into one JS file without changing TSConfig. Advantage: I no longer need to care about umd/commonjs/es6 since everything is in a file.

Remaining work:

  1. minify this JS file
  2. provide proper .d.ts for this JS file
  3. publish .d.ts of this JS file