Tool to generate package exports configuration for TypeScript packages
npm install @cjkihl/create-exports



A powerful tool to automatically generate exports and binary entries in your package.json based on your TypeScript files. Streamline your TypeScript package configuration with zero manual effort.
- ๐ Automatically finds and generates exports for public files (.pub.ts, .pub.tsx)
- ๐ ๏ธ Automatically finds and generates binary entries for CLI files (.bin.ts, .bin.tsx)
- โ๏ธ Supports custom package.json and tsconfig.json paths
- ๐งช Dry run mode to preview changes
- ๐ Sorts exports and binary entries alphabetically
- ๐ Handles index files and nested directories correctly
- ๐ Zero configuration needed
- ๐ฆ Works with any package manager (npm, yarn, pnpm, bun)
``bashUsing npm
npm install @cjkihl/create-exports
Usage
$3
`bash
Show help
create-exports --helpRun with default settings
create-exportsDry run to see what would change
create-exports --dry-runUse custom package.json and tsconfig.json
create-exports --package-json ./custom/package.json --tsconfig ./custom/tsconfig.json
`$3
-
-p, --package-json : Path to package.json file
- -t, --tsconfig : Path to tsconfig.json file
- -d, --dry-run: Show what would be changed without writing
- -h, --help: Show help message$3
`typescript
import { createExports } from "@cjkihl/create-exports";// With default options
await createExports();
// With custom options
await createExports({
packageJsonPath: "./custom/package.json",
tsconfigPath: "./custom/tsconfig.json",
dryRun: true
});
`File Naming Conventions
$3
Files that should be exported must end with
.pub.ts or .pub.tsx. For example:-
index.pub.ts โ exported as root
- src/utils.pub.ts โ exported as ./src/utils
- src/components/index.pub.tsx โ exported as ./src/components$3
Files that should be available as CLI commands must end with
.bin.ts or .bin.tsx. For example:-
cli.bin.ts โ available as cli command
- tools/helper.bin.ts โ available as helper commandOutput
The tool will update your package.json with:
1.
exports field containing all public exports with their TypeScript types
2. bin field containing all binary entriesExample output:
`json
{
"exports": {
".": {
"types": "types/index.pub.d.ts",
"default": "dist/index.pub.js"
},
"./src/utils": {
"types": "types/src/utils.pub.d.ts",
"default": "dist/src/utils.pub.js"
}
},
"bin": {
"cli": "dist/cli.bin.js",
"helper": "dist/tools/helper.bin.js"
}
}
`Requirements
- Node.js >= 18.0.0
- TypeScript project with tsconfig.json
- package.json
๐ค Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
1. Fork the repository
2. Create your feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)This project is MIT licensed.
- Thanks to all contributors who have helped shape this project
- Inspired by the need for better TypeScript package configuration management
- GitHub: @cjkihl
- Twitter: @cjkihl
Give a โญ๏ธ if this project helped you!
If you find this project helpful, please consider sponsoring me on GitHub:

Your support helps me maintain and improve this project!