Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/roggervalf/create-node-library

CLI for easily bootstrapping modern node packages
https://github.com/roggervalf/create-node-library

Last synced: 29 days ago
JSON representation

CLI for easily bootstrapping modern node packages

Awesome Lists containing this project

README

        

# @node/create-library

> CLI for creating reusable, modern Node libraries using Rollup.

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

## Features

- Easy-to-use CLI
- Handles all modern JS features
- Bundles `cjs` and `es` module formats
- [Rollup](https://rollupjs.org/) for bundling
- [Babel](https://babeljs.io/) for transpiling
- [Jest](https://facebook.github.io/jest/) for testing
- Supports complicated peer-dependencies
- Optional support for TypeScript
- Sourcemap creation
- Thorough documentation :heart_eyes:

## Install globally

This package requires `node >= 5`, but we recommend `node >= 8`.

```bash
npm install -g @node/create-library
```

## Usage with npx

```bash
npx @node/create-library
```

_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_

## Creating a New Module

```bash
@node/create-library
```

Answer some basic prompts about your module, and then the CLI will perform the following steps:

- copy over the template
- install dependencies via yarn or npm
- link packages together for local development
- initialize local git repo

At this point, your new module should resemble this screenshot and is all setup for local development.

## Development

Local development is broken into two parts (ideally using two tabs).

First, run rollup to watch your `src/` module and automatically recompile it into `dist/` whenever you make changes.

```bash
npm start # runs rollup with watch flag
```

The second part will be running the `example/` that's linked to the local version of your module.

```bash
# (in another tab)
cd example
npm start # runs node index.js
```

![](https://media.giphy.com/media/12NUbkX6p4xOO4/giphy.gif)

#### Publishing to npm

```bash
npm publish
```

This builds `cjs` and `es` versions of your module to `dist/` and then publishes your module to `npm`.

Make sure that any npm modules you want as peer dependencies are properly marked as `peerDependencies` in `package.json`. The rollup config will automatically recognize them as peers and not try to bundle them in your module.

## License

MIT © [Rogger794](https://github.com/Rogger794)