A CLI tool to generate barrels with ease, efficiency, and intelligence
npx js-barrels -d ./folder/to/generate/barrels/for
-d, --dir Directory to generate barrels for [string] [required]
-w, --watch Watch directory and update barrels [boolean]
-e, --ext Extension to create the barrel file with, auto-detected by
default [string]
After developing a Next.js project with many folders and files, I wanted to create barrels to easily use them without clutter in other files and directories, essentially trying to group imports cleanly with the barrels. After trying many different CLI solutions, I concluded that many of them did not fit my use case of default exports combined with named exports, so I set out to make my own CLI which supported both, hence the creation of this tool.
- Generates barrels for all exports including default and named
- Simplistic nature with only two CLI arguments
- Includes a watch mode to detect file changes and regenerate barrels accordingly
- Lightweight
- Generates barrels for nested directories