no-barrel-file is a CLI tool for removing barrel file imports in JavaScript/TypeScript projects. It efficiently replaces barrel imports with full paths, counts and displays barrel files in folders, and supports alias paths, gitignore rules, and the handling of nested or circular barrel structures.
Using no-barrel-file to remove barrel files from your project can significantly improve your app’s runtime, build-time and test-time performance. For more details, reading Barrel files and why you should STOP using them now or Speeding up the JavaScript ecosystem - The barrel file debacle is recommended.
- Display Barrel Files: List all barrel files in your project for easy inspection.
- Replace Barrel Imports: Automatically replace barrel file imports with full paths in your project.
- Count Barrel Files: Get the total number of barrel files in your project.
- Customizable: Supports root path, alias configurations, gitignore rules, file extensions, files to ignore.
- Scalable: Designed to work with large projects with complex barrel file structures (Nested barrel files, circular dependencies).
Ensure you have Go installed (go1.23+ recommended).
Ensure you have Docker installed.
no-barrel-file count | Count the number of barrel files in the specified root path. |
no-barrel-file display | Display all barrel files in the specified root path. |
no-barrel-file replace | Replace barrel imports with full paths in the specified root path. |
--root-path, -r | Root path of the targeted project. Required | None (required) |
--extensions, -e | Comma-separated list of file extensions to process. | .ts,.js,.tsx,.jsx |
--gitignore-path, -g | Relative path to .gitignore file to apply ignore rules. | .gitignore |
--ignore-paths, -i | Comma-separated list of directories or files to ignore. | None |
--alias-config-path, -a | Relative path to tsconfig.json or jsconfig.json for alias resolution. Only JSON files are supported. | None |
--barrel-path, -b | Relative path of a barrel file import to replaced. | . |
--target-path, -t | Relative path where imports should be replaced. | . |
--verbose, -v | Enable verbose output for detailed logs. | None |
Docker registry
⚠️ It is recommended to install using Go instead of Docker, as Docker can increase execution time when mounting directories with many files.
This project is licensed under the MIT License.