Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/rmariuzzo/entrify

πŸ“¦ Library to convert package.json to index.js.
https://github.com/rmariuzzo/entrify

main monorepo package-json

Last synced: 3 months ago
JSON representation

πŸ“¦ Library to convert package.json to index.js.

Awesome Lists containing this project

README

        

![entrify – Library to convert package.json to index.js.](banner.svg)

Some project has a `package.json` for each of component directories. This is with the benefit to be able to indicate the a main file per directory, which is nice. However, some tools like prettier and eslint, and features as webpack resolve/alias will not work properly.

To remediate this situation we have to create an `index.js` file for each of those `package.json`. That's where **entrify** shines ✨.

> πŸ’ **Hey!** For the command line tool head to: [entrify-cli](https://github.com/rmariuzzo/entrify-cli).

## Installation

```shell
npm install entrify --save
```

or

```shell
yarn add entrify
```

## Usage

```js
const path = require('path')
const entrify = require('entrify')

entrify(path.join(__dirname, './src/components'))
```

**Before:**

```
src/components/
| -- button
| -- package.json (the main field points to `Button.js`)
| -- Button.js
```

**After:**

```
src/components/
| -- button
| -- index.js (created in place of the package.json, it exports `Button.js`)
| -- Button.js
```

## Documentation

### `entrify(directory)`

- **`directory`** – `String`.Β The directory to traverse.
- **`options`** – `Object`. Hash of options.
- **`format`** – `String`. Format of the `index.js` to create. Valid options are: `cjs` and `esm`.

## Development

1. Clone and fork this repo.
2. Install dependencies: yarn or npm install.
3. [Run tests](#test).
4. Prepare a pull request.

### Test

- `yarn test` – to run all tests.
- `yarn test -- --watch` – to run all tests in watch mode.

### Publish

1. Bump package version: `yarn version --new-version x.x.x -m 'Version %s.'`.
2. Publish to NPM registry: `npm publish`.
3. Push new tag: `git push origin --tags`.

Made with :heart: by [Rubens Mariuzzo](https://github.com/rmariuzzo).

[MIT license](LICENSE)