npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pdfking/autoexport

v1.9.4

Published

CLI utility to automatically create index.ts files with exports

Downloads

489

Readme

Autoexport

A CLI utility to automatically create index.ts files with barrel exports.

What it does

This tool scans directories based on glob patterns and automatically generates index.ts files that export all found TypeScript files. It's perfect for creating barrel exports that re-export modules from subdirectories.

Installation

Since this is part of a pnpm workspace, you can install it locally:

pnpm install --filter autoexport

Or install dependencies from the root:

pnpm install

Usage

npx autoexport <output-file> <glob-patterns...>

Arguments

  • <output-file>: The path where the index.ts file should be created (e.g., src/index.ts)
  • <glob-patterns...>: One or more glob patterns to match TypeScript files (e.g., src/utils/** src/types/**)

Options

  • -v, --verbose: Enable verbose output to see what files are being processed
  • -h, --help: Show help information
  • --version: Show version information

Examples

Basic usage

Generate an index.ts file that exports all files from utils and types directories:

npx autoexport src/index.ts "src/utils/**" "src/types/**"

With verbose output

npx autoexport src/index.ts "src/utils/**" "src/types/**" --verbose

More complex patterns

npx autoexport dist/index.ts "src/components/**" "src/hooks/**" "src/lib/**"

Generated Output

Given a directory structure like:

src/
├── utils/
│   ├── format.ts
│   └── validate.ts
├── types/
│   ├── user.ts
│   └── api.ts
└── index.ts (generated)

The generated src/index.ts would contain:

// This file is auto-generated by autoexport
// Do not modify manually

export * from "./types/api"
export * from "./types/user"
export * from "./utils/format"
export * from "./utils/validate"

Features

  • Automatic discovery: Finds all TypeScript files matching your patterns
  • Relative imports: All generated imports are relative to the output file location
  • Smart filtering: Ignores node_modules, dist, build directories and .d.ts files
  • Self-exclusion: Won't include the output file itself in the exports
  • Cross-platform: Works on Windows, macOS, and Linux
  • Sorted output: Exports are alphabetically sorted for consistency

File Types Supported

  • .ts files
  • .tsx files

Ignored Patterns

The tool automatically ignores:

  • **/node_modules/**
  • **/dist/**
  • **/build/**
  • **/*.d.ts
  • The output file itself

Use Cases

  • Component libraries: Export all components from a single entry point
  • Utility libraries: Create barrel exports for utility functions
  • Type definitions: Export all types from a centralized location
  • API modules: Export all API-related modules together
  • Hooks: Export all custom React hooks from one place

Integration with Build Tools

You can integrate this into your build process:

{
  "scripts": {
    "build:exports": "autoexport src/index.ts 'src/components/**' 'src/hooks/**' 'src/utils/**'",
    "prebuild": "npm run build:exports"
  }
}

Error Handling

The tool will exit with code 1 if:

  • Invalid glob patterns are provided
  • Output directory cannot be created
  • File write permissions are insufficient

Use --verbose flag to get detailed information about what the tool is doing.