AutoBarrel is a Visual Studio Code extension that simplifies the creation of barrel files (index.ts or index.js) in your TypeScript or JavaScript projects. A barrel file centralizes exports from a directory, making imports easier and cleaner in other files.
✨ Features
Automatic Barrel File Creation: Creates an index.ts or index.js file in the selected directory, automatically exporting all modules within that directory.
Subdirectory Support: Detects and handles subdirectories, exporting only the index (index.ts or index.js) of directories that contain it.
Customizable Settings:
File Extension: Choose whether to generate barrel files with a .ts or .js extension.
Remove File Extension: Configure whether to remove the file extension from exported files in the barrel file.
🔧 Installation
Open Visual Studio Code.
Go to the Extensions view (square icon in the sidebar).
Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS).
Type Create Barrel and run it.
Select the directory where you want to create the barrel file.
The extension will create an index.ts or index.js file in the selected directory, automatically exporting all modules in that directory.
⚙️ Configuration
You can customize the extension's behavior through VSCode settings. Go to File > Preferences > Settings (or Code > Preferences > Settings on macOS) and search for AutoBarrel.
Configuration Options
Remove File Extension (autobarrel.removeExtension): Removes the file extension in export statements.
Type: boolean
Default: true
Use JavaScript (autobarrel.useJavaScript): Use .js extension instead of .ts for barrel files.