palmerhq / tsdx
- среда, 1 мая 2019 г. в 00:22:54
JavaScript
Zero-config CLI for TypeScript package development
Despite all the recent hype, setting up a new TypeScript library can be tough. Between Rollup, Jest, tsconfig, Yarn resolutions, TSLint, and getting VSCode to play nicely....there is just a whole lot of stuff to do (and things to fuck up). TSDX is a zero-config CLI that helps you develop, test, and publish modern TypeScript packages with ease--so you can focus on your awesome new library and not waste another afternoon on the configuration.
TSDX comes with the "battery-pack included" and is part of a complete TypeScript breakfast:
tsdx testnpx tsdx create mylib
cd mylib
yarn start
That's it. You don't need to worry about setting up Typescript or Rollup or Jest or other plumbing. Just start editing src/index.ts and go!
Below is a list of commands you will probably find useful.
npm start or yarn startRuns the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for your convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
Your library will be rebuilt if you make edits.
npm run build or yarn buildBundles the package to the dist folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
npm test or yarn testRuns the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
TSDX is ripped out of Formik's build tooling. TSDX is very similar to @developit/microbundle, but that is because Formik's Rollup configuration and Microbundle's internals have converged around similar plugins over the last year or so.
tsdx watchDescription
Rebuilds on any change
Usage
$ tsdx watch [options]
Options
-i, --entry Entry module(s)
--target Specify your target environment (default web)
--name Specify name exposed in UMD builds
--format Specify module format(s) (default cjs,es,umd)
-h, --help Displays this message
Examples
$ tsdx watch --entry src/foo.tsx
$ tsdx watch --target node
$ tsdx watch --name Foo
$ tsdx watch --format cjs,estsdx buildDescription
Build your project once and exit
Usage
$ tsdx build [options]
Options
-i, --entry Entry module(s)
--target Specify your target environment (default web)
--name Specify name exposed in UMD builds
--format Specify module format(s) (default cjs,es,umd)
-h, --help Displays this message
Examples
$ tsdx build --entry src/foo.tsx
$ tsdx build --target node
$ tsdx build --name Foo
$ tsdx build --format cjs,estsdx testThis runs Jest v23.x in watch mode. See https://jestjs.io for options. If you are trying to test a React component, you likely want to pass in --env=jsdom just like you do in Create React App.