Barrel Roll is a Visual Studio Code extension that makes barrel file creation and upkeep effortless. Right-click any folder, pick a Barrel Roll command, and the extension assembles a curated index.ts that reflects the exports your module actually exposes—no tedious manual wiring, no temptation to export * the entire directory.
Whether you need a single barrel refreshed or an entire tree brought into alignment, Barrel Roll keeps your exports clean, consistent, and ready for real work. It discovers TypeScript exports, connects child barrels to their parents, and prevents duplicate re-exports so your team can focus on building features instead of shuffling files.
- Right-click Generation: Right-click any folder in the VS Code explorer to generate or update an
index.tsbarrel file - Two Command Modes: Choose between updating just the selected directory or traversing the full subtree via dedicated context menu entries
- Recursive Barrels: Automatically walks child folders, generating barrels for every directory and wiring parent barrels to re-export their children
- Smart Export Detection: Automatically detects and exports all TypeScript exports (classes, interfaces, types, functions, constants, enums)
- Clean Architecture: Follows SOLID principles for maintainability and extensibility
- Parent Folder Filtering: Automatically removes re-exports from parent folders
- Alphabetical Ordering: Generates consistently ordered exports for better readability
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "Barrel Roll"
- Click Install
- Download the latest
.vsixfile from the releases page - In VS Code, go to Extensions
- Click the
...menu and select "Install from VSIX..." - Select the downloaded file
-
Right-click on any folder in the VS Code explorer
-
Select one of the Barrel Roll commands:
Barrel Roll: Barrel Directory(updates only the selected folder)Barrel Roll: Barrel Directory (Recursive)(updates the selected folder and all subfolders)
-
The extension will:
- Scan all
.ts/.tsxfiles in the folder (excludingindex.tsand declaration files) - Recursively process each subfolder and generate its
index.ts - Extract all exported items
- Generate or update an
index.tsfile with proper exports and re-export child barrels - Filter out any re-exports from parent directories
- Scan all
You can also invoke these commands from the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) by searching for their names.
Given these files in a folder:
// user.ts
export class User {}
export interface UserData {}
// auth.ts
export function login() {}
export function logout() {}
// constants.ts
export const API_URL = 'https://api.example.com';Running Barrel Roll will generate:
// index.ts
export { API_URL } from './constants';
export { login, logout } from './auth';
export { User, UserData } from './user';- Node.js 18.x or later
- npm 8.x or later
npm installnpm run compilenpm run compile-tests# Watch for changes and recompile
npm run watch
# Watch for test changes and recompile
npm run watch-tests# Run all tests (includes pretest: compile, lint, deps check)
npm test
# Run unit tests only (compiles tests and extension, then runs tests)
npm run test:unit
# Run VS Code integration tests (compiles tests, then runs VS Code test harness)
npm run test:vscode
# Run coverage analysis (includes pretest + c8 coverage + badge generation)
npm run coverage
# Check coverage thresholds
npm run coverage:checkNote:
npm testruns the full pretest pipeline (compile tests, compile extension, lint) before executing tests.npm run test:unitcompiles and runs tests directly without linting.
npm run lint
npm run lint:fixNote:
npm run lintnow runs a dependency check as part of the pipeline (npm run deps:check). This invokes the programmatic depcheck runner (scripts/run-depcheck.cjs) which writes.depcheck.jsonand will cause the command to fail if unused dependencies remain.
npm run format
npm run format:checknpm run typecheck# Run all quality checks (linting, duplication, circular dependencies)
npm run quality
# Check for code duplication
npm run duplication
# Check for circular dependencies
npm run madge
# Check dependencies (dependency check is also available as a standalone command)
npm run lint:deps
npm run deps:checkDependency check details: The project uses a programmatic depcheck runner (scripts/run-depcheck.cjs) that writes .depcheck.json and filters references found in scripts and repository files. This ensures unused packages are detected reliably without relying on npx.
# Generate coverage report and badge
npm run coverage
# Generate coverage badge only
npm run coverage:badge
# Check coverage thresholds
npm run coverage:check# Package extension for distribution
npm run package
# Install packaged extension locally
npm run ext:install
# Package and install in one command
npm run ext:reinstallThe extension follows SOLID principles with clear separation of concerns:
- BarrelFileGenerator: Main orchestrator coordinating the barrel file generation process
- FileSystemService: Handles all file I/O operations
- ExportParser: Extracts export statements from TypeScript code
- BarrelContentBuilder: Builds the formatted content for barrel files
This architecture ensures:
- Single Responsibility: Each class has one clear purpose
- Open/Closed: Easy to extend without modifying existing code
- Dependency Inversion: High-level modules don't depend on low-level details
- Testability: Each component can be tested in isolation
Contributions are welcome! Please feel free to submit a Pull Request.
For developer notes on automation, dependency checks, test conventions, and other agent-related details see AGENTS.md.
Apache-2.0
