generator-typescript-react-lib
v1.0.178
Published
A Yeoman generator for React libs written with Typescript.
Downloads
41
Maintainers
Readme
generator-typescript-react-lib
A Yeoman generator for React libs written with Typescript.
Table of Contents
Background
To provide a basic starting point when authoring React libraries with Typescript. By design not all use-cases will be handled, so some post-generation modifications may be required.
Features
- Generates CommonJS, ES module, and Universal Module Definition bundles via Rollup.
- Tests bundles via Jest.
- Generates Typescript type declarations for publishing.
- Outputs, strips, or wraps PropTypes declarations according to bundle type.
- Configures continuous integration via GitHub Actions.
- Configures code coverage analysis via Codecov.
- Configures Renovate for dependency management.
- Adds scripts for releasing to npm.
- Makes Universal Module Definition bundles available via unpkg.
- Initialises Git.
Installation
First, install Yeoman and generator-typescript-react-lib:
$ npm install -g yo generator-typescript-react-lib
Then generate your new library:
$ mkdir your-new-react-library && cd $_
$ yo typescript-react-lib
Common Workflows
Setup
- Create a new GitHub repository.
- Install/enable the Renovate GitHub app.
- Use this generator to create your lib.
Development
Everything revolves around GitHub PRs:
- Create a new local branch.
- Add a remote tracking branch.
- Make some changes.
- Push the changes.
- Open a PR.
It's also recommended to set branch protection rules against the master
branch by selecting the following:
Require status checks to pass before merging
.Require branches to be up to date before merging
.ci
.
Testing
Running npm test
will:
- Check code style with Prettier.
- Type check with TypeScript.
- Build the package assets.
- Test the package assets.
Publishing
Once the PR checks have passed:
- Merge the PR.
- Checkout the
master
branch. - Ensure
master
is up-to-date. - Run
npm release <newversion>
. Refer to the npm-version docs for information on thenewversion
argument.
The release
script will:
- Bump the
package.json
version. - Run the test flow.
- Generate a
CHANGELOG.md
that includes these latest changes. - Generate or update the
AUTHORS
file. - Make a version commit and tag.
- Push the commit and tag to GitHub.
- Publish the package to npm.
License
MIT