New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@libria/ts-barrels

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libria/ts-barrels

Simple TypeScript barrel generator for typescript projects

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

@libria/ts-barrels

A simple, fast TypeScript barrel file generator that recursively creates index.ts exports for your project.

What are Barrel Files?

Barrel files (typically index.ts) re-export modules from a directory, enabling cleaner imports:

// Without barrels
import { UserService } from './services/user/UserService';
import { AuthService } from './services/auth/AuthService';

// With barrels
import { UserService, AuthService } from './services';

Installation

npm install @libria/ts-barrels

CLI Usage

npx ts-barrels <root> [options]

Options

OptionDescriptionDefault
<root>Root folder to generate barrels in(required)
--allGenerate barrels recursively from leaves to rootfalse
--forceOverwrite existing barrel filesfalse
--name <filename>Custom barrel filenameindex.ts

Examples

Generate barrels for the entire src directory:

npx ts-barrels src --all

Generate with a custom filename:

npx ts-barrels src --all --name barrel.ts

Force regenerate all barrels:

npx ts-barrels src --all --force

Ignore a folder from barrel generation:

npx ts-barrels ignore src/internal

Programmatic Usage

import { generateBarrels } from '@libria/ts-barrels';

await generateBarrels('./src', {
  all: true,
  force: false,
  filename: 'index.ts'
});

Skip Comment

To prevent a barrel file from being overwritten, add a skip comment at the top:

// @libria/ts-barrels skip
export * from './custom-export';
export { specific } from './module';

Files with the skip comment are always preserved, even when using --force.

Ignoring Folders

To completely exclude a folder (and all its children) from barrel generation, create a .lbbign marker file in that folder:

npx ts-barrels ignore src/internal

This creates a .lbbign file in src/internal. When generating barrels, any folder containing .lbbign will be skipped entirely:

  • No barrel file will be created in that folder
  • No child folders will be traversed
  • The parent barrel will not export from the ignored folder

This is useful for internal modules, generated code, or any directory you want to exclude from your public API.

Generated Output

Given this structure:

src/
  features/
    auth/
      login.ts
      logout.ts
    users/
      create.ts
      delete.ts
  utils/
    helpers.ts

Running npx ts-barrels src --all generates:

src/
  index.ts          -> export * from './features'; export * from './utils';
  features/
    index.ts        -> export * from './auth'; export * from './users';
    auth/
      index.ts      -> export * from './login'; export * from './logout';
    users/
      index.ts      -> export * from './create'; export * from './delete';
  utils/
    index.ts        -> export * from './helpers';

License

MIT

Keywords

barrel

FAQs

Package last updated on 13 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts