generate-module-index
v1.0.2
Published
This package helps generate index file exporting all components/ modules of current directory. Current version only support type=module.
Readme
generate-module-index
A simple CLI tool to auto-generate or update an index.js file that re-exports default exports from all modules in a specified directory.
✨ Features
- Automatically scans a target directory for
.jsor.tsfiles. - Generates an
index.jsfile that exports default modules using the filename as the alias. - Skips
index.jsor files starting withindex. - Works well in any component or module folder for easy imports.
📦 Installation
You can run it directly using npx (no need to install globally):
npx generate-module-index <target-directory>Or install locally:
npm install generate-module-index -Dand add package script:
"scripts": {
"generate-index": "generate-module-index ./src/components"
}Usage
Command
npx generate-module-index <target-directory>example
src/components/
├── Button.js
├── Card.js
├── PageTitle.jsRunning command:
npx generate-module-index ./src/componentsWill generate:
// src/components/index.js
export { default as Button } from "./Button";
export { default as Card } from "./Card";
export { default as PageTitle } from "./PageTitle";