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.
npm install entrify --save
or
yarn add entrify
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
directory
–String
. The directory to traverse.options
–Object
. Hash of options.format
–String
. Format of theindex.js
to create. Valid options are:cjs
andesm
.
- Clone and fork this repo.
- Install dependencies: yarn or npm install.
- Run tests.
- Prepare a pull request.
yarn test
– to run all tests.yarn test -- --watch
– to run all tests in watch mode.
- 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 ❤️ by Rubens Mariuzzo.