Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Auto Barrel GeneratorNew to Visual Studio Code? Get it now.
Auto Barrel Generator

Auto Barrel Generator

Mariano Hilario

|
6 installs
| (0) | Free
Automatically generate and maintain index barrel files (index.ts or index.js) for TypeScript and JavaScript projects. Supports ES Modules and CommonJS.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Auto Barrel Generator

Version VS Code TypeScript JavaScript

Automatically generates and keeps index.ts / index.js barrel files in sync with your folder structure.

Stop manually writing exports.
Keep your modules clean and organized automatically.


🎬 Demo

Demo

✨ Features

  • Automatic index.ts / index.js generation
  • Real-time updates when:
    • A file is created
    • A file is deleted
    • A file is saved
  • Supports:
    • .ts
    • .tsx
    • .js
    • .jsx
  • Smart export detection using TypeScript AST
  • Handles:
    • Default exports
    • Named exports
    • Default + named combined
  • Ignores files without exports
  • Optional subfolder scanning
  • Alphabetical sorting
  • Zero manual maintenance

📦 What It Generates

Named exports only

export * from "./myFile";

Default export only

export { default as MyFile } from "./myFile";

Default + named exports

export { default as MyFile } from "./myFile";
export * from "./myFile";

📁 Example

Before

components/
 ├── Button.tsx
 ├── Card.tsx

After

components/
 ├── index.ts
 ├── Button.tsx
 ├── Card.tsx
// components/index.ts
export { default as Button } from "./Button";
export { default as Card } from "./Card";

📥 Installation

  1. Open VS Code
  2. Go to Extensions
  3. Search for Auto Barrel Generator
  4. Click Install

🚀 How It Works

The extension watches your workspace and regenerates the barrel file automatically when needed.

No manual trigger required.

You can also manually generate a barrel file:

  • Right-click a folder
  • Select Generate Barrel

⚙️ Configuration

Configure behavior in VS Code settings:

"autoBarrel.outputFile": "auto",
"autoBarrel.includeSubfolders": false,
"autoBarrel.skipRootAndSrc": true,
"autoBarrel.sortAlphabetically": true,
"autoBarrel.ignore": ["__tests__", "node_modules"]

Configure via settings.json

You can configure the extension directly in JSON:

Workspace settings (.vscode/settings.json):

{
  "autoBarrel.outputFile": "auto",
  "autoBarrel.includeSubfolders": true,
  "autoBarrel.skipRootAndSrc": true,
  "autoBarrel.sortAlphabetically": true,
  "autoBarrel.ignore": ["__tests__", "__mocks__", "node_modules"]
}

User settings (Preferences: Open User Settings (JSON)) use the same keys.


Settings Explained

Setting Type Description
outputFile string auto, index.ts, or index.js
includeSubfolders boolean Include files from nested directories
skipRootAndSrc boolean Skip auto generation in workspace root and src
sortAlphabetically boolean Sort exports alphabetically
ignore string[] Folder names to ignore

🧠 Smart Export Detection

This extension parses your files using the TypeScript compiler API (AST) to detect:

  • export default
  • export const
  • export function
  • export class
  • export interface
  • export type
  • export { X }
  • CommonJS exports (module.exports, exports.foo, module.exports.foo)

Files without exports are automatically ignored.

🎯 Why Use It?

  • Avoid manual barrel maintenance
  • Prevent missing exports
  • Improve developer experience
  • Keep folder structure clean
  • Scale better in large projects

⚡ Performance

  • Lightweight
  • Event-based file watching
  • No background polling
  • Only regenerates when necessary

⚠️ Limitations

  • Source files named index.ts, index.tsx, index.js, and index.jsx are ignored to avoid self-reexports/cycles.
  • If a folder only contains index.*, no barrel is generated automatically.
  • Recommended pattern: use files like router.tsx or routes.tsx as sources, and keep index.ts for the generated barrel.

🛠 Requirements

  • VS Code 1.75+
  • Node.js project

🗺 Roadmap

  • Exclude patterns (glob support)
  • Marketplace publishing

📄 License

MIT © 2026 Mariano Hilario

👨‍💻 Author

Mariano Hilario
GitHub: https://github.com/marianohilario

Built to simplify barrel management in modern JavaScript and TypeScript projects.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft