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.
Installation
npm install entrify --save
or
yarn add entrify
Usage
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 theindex.js
to create. Valid options are:cjs
andesm
.
Development
- Clone and fork this repo.
- Install dependencies: yarn or npm install.
- Run tests.
- Prepare a pull request.
Test
yarn test
β to run all tests.yarn test -- --watch
β to run all tests in watch mode.
Publish
- Bump package version:
yarn version --new-version x.x.x -m 'Version %s.'
. - Publish to NPM registry:
npm publish
. - Push new tag:
git push origin --tags
.
Made with