@kubb/plugin-barrel 5.8.4 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  ### Barrel-file plugin for Kubb
26
26
 
27
- Automatically generates `index.ts` re-export files for each plugin output directory.
27
+ Generates `index.ts` re-export files for each plugin output directory, and a root `index.ts` when `output.barrel` is set on `defineConfig`.
28
28
 
29
29
  ## Installation
30
30
 
@@ -38,42 +38,42 @@ npm install @kubb/plugin-barrel
38
38
 
39
39
  ## Usage
40
40
 
41
- Add `pluginBarrel` to the `plugins` array in your `kubb.config.ts`:
41
+ `defineConfig` adds `pluginBarrel()` to `plugins` for you, so you do not add it yourself. Set `output.barrel` on `defineConfig` to write a root barrel and to give every plugin without its own `output.barrel` the same setting:
42
42
 
43
43
  ```typescript
44
44
  import { defineConfig } from 'kubb'
45
- import { pluginBarrel } from '@kubb/plugin-barrel'
45
+ import { pluginTs } from '@kubb/plugin-ts'
46
46
 
47
47
  export default defineConfig({
48
48
  input: './openapi.yaml',
49
49
  output: {
50
50
  path: './src/gen',
51
+ barrel: { type: 'named' },
51
52
  },
52
- plugins: [
53
- pluginBarrel({
54
- type: 'named',
55
- }),
56
- ],
53
+ plugins: [pluginTs()],
57
54
  })
58
55
  ```
59
56
 
60
57
  ## Options
61
58
 
62
- | Option | Type | Default | Description |
63
- | ------ | --------------------------------- | --------- | ------------------------------------------- |
64
- | `type` | `'all' \| 'named' \| 'propagate'` | `'named'` | Export style for the generated barrel files |
59
+ `pluginBarrel()` takes no arguments. You configure it through `output.barrel`, on `defineConfig` or on a single plugin.
60
+
61
+ | Option | Type | Default | Description |
62
+ | ---------------------- | ------------------------------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------- |
63
+ | `output.barrel` | `{ type: 'all' \| 'named', nested?: boolean } \| false` | `false` on `defineConfig` | Barrel settings. `false` on a plugin turns its barrel off and leaves its files out of the root one |
64
+ | `output.barrel.type` | `'all' \| 'named'` | None | Export style for the generated barrel files |
65
+ | `output.barrel.nested` | `boolean` | `false` | Plugin only. Each barrel re-exports its own directory and the barrels below it |
65
66
 
66
67
  ### Export types
67
68
 
68
- | Value | Output |
69
- | ------------- | ------------------------------------------------------------------------------- |
70
- | `'all'` | `export * from './...'` — wildcard re-exports |
71
- | `'named'` | `export { ... } from './...'` — named re-exports, tree-shaking friendly |
72
- | `'propagate'` | `export * from './...'` on index files only, propagating up through directories |
69
+ | Value | Output |
70
+ | --------- | ----------------------------------------------------------------------- |
71
+ | `'all'` | `export * from './...'` — wildcard re-exports |
72
+ | `'named'` | `export { ... } from './...'` — named re-exports, tree-shaking friendly |
73
73
 
74
74
  ## How it works
75
75
 
76
- After every plugin finishes generating files, `@kubb/plugin-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.
76
+ After every plugin finishes generating files, `@kubb/plugin-barrel` walks the output tree and creates an `index.ts` in each directory of every plugin output with a barrel enabled. When `output.barrel` is set on `defineConfig`, it also creates a root `index.ts` at the top of the output path that re-exports the files of every plugin that does not set `output.barrel: false`.
77
77
 
78
78
  `@kubb/plugin-barrel` uses `enforce: 'post'` so it always runs after all regular plugins complete, giving it access to the full set of generated files.
79
79
 
package/dist/index.cjs CHANGED
@@ -71,7 +71,7 @@ var compatibility = {
71
71
  };
72
72
  //#endregion
73
73
  //#region package.json
74
- var version = "5.8.4";
74
+ var version = "5.9.0";
75
75
  //#endregion
76
76
  //#region src/utils.ts
77
77
  const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ var compatibility = {
48
48
  };
49
49
  //#endregion
50
50
  //#region package.json
51
- var version = "5.8.4";
51
+ var version = "5.9.0";
52
52
  //#endregion
53
53
  //#region src/utils.ts
54
54
  const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
package/docs/options.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ### output.barrel
16
16
 
17
- Kubb writes one root barrel and an `index.ts` in every directory of a plugin's output. For two plugins that write to `models` and `clients`:
17
+ Kubb writes an `index.ts` in every directory of a plugin's output, and a root barrel when `output.barrel` is set on `defineConfig`. For two plugins that write to `models` and `clients`, with `output.barrel` set on `defineConfig`:
18
18
 
19
19
  ```text
20
20
  src/gen
package/docs/overview.md CHANGED
@@ -1,27 +1,27 @@
1
- # Barrel plugin
1
+ # Barrel
2
2
 
3
- The barrel plugin writes `index.ts` files that re-export generated code, one for each plugin's output and one root barrel, so you can import everything from a single entry point.
4
-
5
- Kubb adds it to `plugins` for you. Do not add it yourself. It generates nothing until you configure `output.barrel`.
3
+ The Barrel plugin writes `index.ts` files that re-export generated code, so you can import everything from a single entry point. It writes a barrel in every folder of each plugin output that has a barrel setting, plus a root barrel when you set `output.barrel` on `defineConfig`.
6
4
 
7
5
  ## Setup
8
6
 
9
- Set `output.barrel` on `defineConfig` to write a root barrel. Plugins without a barrel setting of their own inherit it.
7
+ Kubb adds the plugin to `plugins` for you, so no setup is needed. Generator plugins such as `pluginTs()` turn on their own barrels by default. Plugins without their own `output.barrel` inherit the root setting.
10
8
 
11
- ## Options
9
+ ## Options worth knowing
12
10
 
13
- The plugin takes no arguments. You configure it through `output.barrel`, on `defineConfig` or on a single plugin.
11
+ `pluginBarrel()` takes no arguments. You configure it through `output.barrel`, on `defineConfig` or on a single plugin.
14
12
 
15
13
  - `type: 'named'` re-exports each symbol by name, which suits tree-shaking. `type: 'all'` writes `export *`.
16
- - `nested: true`, on a plugin only, makes each barrel re-export just its own directory and the barrels below it. The root barrel is always flat.
14
+ - `nested: true`, on a plugin only, makes each barrel re-export just its own folder and the barrels below it. The root barrel is always flat.
17
15
  - `false` on a plugin turns its barrel off and leaves its files out of the root barrel.
18
16
 
19
- A plugin with `output.mode: 'file'` gets no barrel of its own. The root barrel re-exports that file directly. Passing your own `output` object to a plugin replaces its default `barrel: { type: 'named' }`, so it falls back to the root setting.
17
+ A plugin with `output.mode: 'file'` gets no barrel of its own, and the root barrel re-exports that file directly. Passing your own `output` object to a plugin replaces its default `barrel: { type: 'named' }`, so that plugin falls back to the root setting. When two files export the same name, Kubb reports an error, and a `named` barrel keeps only the first one.
20
18
 
21
- See [Options](https://kubb.dev/extensions/kubb-labs/plugin-barrel/options) for the export `type`, `nested` barrels, and per-plugin overrides.
19
+ See [Options](https://kubb.dev/extensions/kubb-labs/plugin-barrel/options) for every option and its default.
22
20
 
23
21
  ## Example
24
22
 
23
+ The config below writes a root `src/gen/index.ts` that re-exports the generated types by name.
24
+
25
25
  ```typescript [kubb.config.ts]
26
26
  import { defineConfig } from 'kubb/config'
27
27
  import { pluginTs } from '@kubb/plugin-ts'
@@ -29,6 +29,8 @@ import { pluginTs } from '@kubb/plugin-ts'
29
29
  export default defineConfig({
30
30
  input: './petStore.yaml',
31
31
  output: { path: './src/gen', barrel: { type: 'named' } },
32
- plugins: [pluginTs()],
32
+ plugins: [
33
+ pluginTs(),
34
+ ],
33
35
  })
34
36
  ```
@@ -4,7 +4,7 @@
4
4
  "name": "plugin-barrel",
5
5
  "export": "pluginBarrel",
6
6
  "displayName": "Barrel",
7
- "description": "Generates index.ts barrel files for every plugin output and one root barrel.",
7
+ "description": "Generates index.ts barrel files for every plugin output, plus a root barrel when output.barrel is set on defineConfig.",
8
8
  "category": "output",
9
9
  "icon": {
10
10
  "light": "https://kubb.dev/feature/plugins-light.svg"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-barrel",
3
- "version": "5.8.4",
3
+ "version": "5.9.0",
4
4
  "description": "Barrel-file plugin for Kubb. Automatically generates index.ts re-export files per plugin output directory.",
5
5
  "keywords": [
6
6
  "barrel",
@@ -61,11 +61,11 @@
61
61
  "registry": "https://registry.npmjs.org/"
62
62
  },
63
63
  "dependencies": {
64
- "@kubb/kit": "5.8.4"
64
+ "@kubb/kit": "5.9.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@internals/utils": "0.0.1",
68
- "@kubb/core": "5.8.4"
68
+ "@kubb/core": "5.9.0"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=22"