npm.io
5.0.0-beta.35 • Published 2 months ago

@kubb/middleware-barrel

Licence
MIT
Version
5.0.0-beta.35
Deps
1
Size
106 kB
Vulns
0
Weekly
0
Stars
1.8K
DeprecatedThis package is deprecated

@kubb/middleware-barrel

Barrel-file middleware for Kubb

Automatically generates index.ts re-export files for each plugin output directory and an optional root barrel after all plugins have run.

Installation

bun add @kubb/middleware-barrel
# or
pnpm add @kubb/middleware-barrel
# or
npm install @kubb/middleware-barrel

Usage

Add middlewareBarrel to the middleware array in your kubb.config.ts:

import { defineConfig } from 'kubb'
import { middlewareBarrel } from '@kubb/middleware-barrel'

export default defineConfig({
  input: {
    path: './openapi.yaml',
  },
  output: {
    path: './src/gen',
  },
  middleware: [
    middlewareBarrel({
      type: 'named',
    }),
  ],
})

Options

Option Type Default Description
type 'all' | 'named' | 'propagate' 'named' Export style for the generated barrel files
Export types
Value Output
'all' export * from './...' — wildcard re-exports
'named' export { ... } from './...' — named re-exports, tree-shaking friendly
'propagate' export * from './...' on index files only, propagating up through directories

How it works

After every plugin finishes generating files, @kubb/middleware-barrel walks the output tree and creates an index.ts in each directory, re-exporting everything inside. It then creates a root index.ts at the top of the output path that re-exports from all plugin directories.

Supporting Kubb

Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:

My sponsors

License

MIT

Keywords