Barrel Roll is a Visual Studio Code extension that automates creation and maintenance of index.ts barrel files. Right-click a folder, run a Barrel Roll command, and the extension generates exports from real TypeScript declarations while keeping output deterministic and readable.
- Right-click generation of
index.tsbarrel files from the VS Code explorer - Two command modes: single directory and recursive directory processing
- Recursive barrel generation for child folders with parent re-export wiring
- Export detection for TypeScript values, type-only exports, and default exports
- Stable alphabetical ordering to keep diffs small and predictable
- Sanitized updates that preserve direct definitions in existing
index.ts - Built-in safeguards for ignored directories and oversized files
- 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 selectInstall from VSIX... - Select the downloaded file
- Right-click a folder in the VS Code explorer
- Run one of these commands:
Barrel Roll DirectoryBarrel Roll Directory (Recursive)
- Barrel Roll will:
- scan
.ts/.tsxfiles (excludingindex.ts, declaration files, and test files) - generate or update
index.ts - recursively generate child barrels when recursive mode is selected
- preserve direct definitions in existing index files while refreshing export lines
- scan
You can also run both commands from the Command Palette.
Given:
// 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';Barrel Roll generates:
// index.ts
export { login, logout } from './auth.js';
export { API_URL } from './constants.js';
export { User } from './user.js';
export type { UserData } from './user.js';- Node.js 18+
- npm 8+
npm install
npm run compile
npm run compile-tests
npm run test
npm run test:unit
npm run test:vscode
npm run lint
npm run deps:check
npm run qualitynpm testruns compile, lint, dependency check, then the Node test suite viascripts/run-tests.cjs.npm run test:unitruns a faster compile + test path without lint.- Unit and integration tests live under
src/test/. - Unit test names must start with
should.
npm run deps:check uses scripts/run-depcheck.cjs (programmatic depcheck runner). It writes .depcheck.json, filters known script/repository references, and fails when unused dependencies remain.
# Build production bundle used by VS Code prepublish
npm run package
# Build VSIX package
npm run ext:package
# Install latest packaged VSIX locally
npm run ext:install
# Build + install
npm run ext:reinstallPublishing uses an allowlist in .vscodeignore so only runtime assets are intentionally included:
package.jsonLICENSEREADME.mddist/extension.jspublic/img/barrel-roll-icon.png
Use npx @vscode/vsce ls to inspect final package contents before publishing.
- Scans only
.tsand.tsxsource files. - Dynamic runtime-created named exports cannot be statically detected.
- Existing
index.tscontent is sanitized to preserve direct declarations, but malformed export syntax may still require manual cleanup.
For architecture details and module-level responsibilities, see ARCHITECTURE.md.
Contributions are welcome. See CONTRIBUTING.md and AGENTS.md for contribution and automation details.
Apache 2.0. See LICENSE.
Maintained by Robert Lindley.