@kubb/plugin-barrel 5.8.2 → 5.8.4

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
@@ -10,7 +10,7 @@
10
10
  [![Node][node-src]][node-href]
11
11
 
12
12
  <h4>
13
- <a href="https://kubb.dev" target="_blank">Documentation</a>
13
+ <a href="https://kubb.dev/extensions/kubb-labs/plugin-barrel" target="_blank">Documentation</a>
14
14
  <span> · </span>
15
15
  <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
16
16
  <span> · </span>
package/dist/index.cjs CHANGED
@@ -66,12 +66,12 @@ function isPathInside(path, parent) {
66
66
  //#endregion
67
67
  //#region kubb-extension.json
68
68
  var compatibility = {
69
- "kubb": ">=5.8.0",
69
+ "kubb": ">=5.8.3",
70
70
  "node": ">=22"
71
71
  };
72
72
  //#endregion
73
73
  //#region package.json
74
- var version = "5.8.2";
74
+ var version = "5.8.4";
75
75
  //#endregion
76
76
  //#region src/utils.ts
77
77
  const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
package/dist/index.js CHANGED
@@ -43,12 +43,12 @@ function isPathInside(path, parent) {
43
43
  //#endregion
44
44
  //#region kubb-extension.json
45
45
  var compatibility = {
46
- "kubb": ">=5.8.0",
46
+ "kubb": ">=5.8.3",
47
47
  "node": ">=22"
48
48
  };
49
49
  //#endregion
50
50
  //#region package.json
51
- var version = "5.8.2";
51
+ var version = "5.8.4";
52
52
  //#endregion
53
53
  //#region src/utils.ts
54
54
  const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -0,0 +1,119 @@
1
+ # Options
2
+
3
+ `pluginBarrel` takes no arguments. You configure it through `output.barrel`, either on `defineConfig` to set the root barrel and the default every plugin inherits, or on a single plugin to override that plugin's barrel. The plugin-level behavior is also summarized under [`output.barrel`](https://kubb.dev/docs/5.x/reference/plugin-options#output-barrel) in the shared plugin options.
4
+
5
+ ## Options overview
6
+
7
+ | Option | Purpose | Default |
8
+ | ----------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
9
+ | [`output.barrel`](#output-barrel) | Re-export style for the barrel files. | `false` on `defineConfig`, `{ type: 'named' }` in every generator plugin's default `output` |
10
+ | ↳ [`output.barrel.type`](#type) | Named exports or a wildcard export. | Required when `output.barrel` is an object |
11
+ | ↳ [`output.barrel.nested`](#nested) | Choose whether barrels reference subdirectory barrels. | `false` |
12
+
13
+ ## Option details
14
+
15
+ ### output.barrel
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`:
18
+
19
+ ```text
20
+ src/gen
21
+ ├── index.ts root barrel
22
+ ├── models
23
+ │ ├── index.ts plugin barrel
24
+ │ ├── Pet.ts
25
+ │ └── User.ts
26
+ └── clients
27
+ ├── index.ts plugin barrel
28
+ ├── pet
29
+ │ ├── index.ts
30
+ │ └── getPetById.ts
31
+ └── store
32
+ ├── index.ts
33
+ └── getInventory.ts
34
+ ```
35
+
36
+ | | |
37
+ | -------- | ------------------------------------------------------- |
38
+ | Type | `{ type: 'all' \| 'named', nested?: boolean } \| false` |
39
+ | Required | `false` |
40
+ | Default | `false` |
41
+
42
+ The `type` field picks the export style. A plugin's `output.barrel` also accepts `nested`, so each barrel re-exports the barrels below it instead of the leaf files. The root `output.barrel` has no `nested` field and always stays flat.
43
+
44
+ A plugin called without `output` uses its own default, which sets `barrel: { type: 'named' }`. If you pass your own `output` object, it replaces that default. `pluginTs({ output: { path: 'types' } })` then has no `barrel` and uses `config.output.barrel`, which is `false` unless you set it.
45
+
46
+ Set `barrel: { type: 'named' | 'all' }` on `defineConfig` to enable barrels everywhere: a root barrel, and the default every plugin without its own `output.barrel` inherits. A plugin that sets its own `output.barrel` overrides that inherited value, including back to `false`, which also drops its files from the root barrel. A plugin with `output.mode: 'file'` gets no barrel of its own, and the root barrel re-exports that file directly.
47
+
48
+ ### type
49
+
50
+ Export style for the barrel files. Required whenever `output.barrel` is set to an object.
51
+
52
+ | | |
53
+ | -------- | ------------------ |
54
+ | Type | `'all' \| 'named'` |
55
+ | Required | `true` |
56
+
57
+ ::field-group
58
+
59
+ :::field{name="'named'"}
60
+ Re-exports each symbol by name from the file's named exports. Best for tree-shaking and explicit imports.
61
+ :::
62
+
63
+ :::field{name="'all'"}
64
+ Uses `export *`, a smaller barrel that re-exports everything.
65
+ :::
66
+
67
+ ::
68
+
69
+ ::code-group
70
+
71
+ ```typescript ['named']
72
+ // src/gen/index.ts
73
+ export { getUser } from './api/user'
74
+ export { getPost, Post } from './api/post'
75
+ export { User } from './api/types/User'
76
+ ```
77
+
78
+ ```typescript ['all']
79
+ // src/gen/index.ts
80
+ export * from './api/user'
81
+ export * from './api/post'
82
+ export * from './api/types/User'
83
+ ```
84
+
85
+ ::
86
+
87
+ ### nested
88
+
89
+ Changes what each barrel references. A barrel is written for every directory either way. With `nested: false`, the plugin's top barrel reaches through to the leaf files. With `nested: true`, each barrel re-exports only what sits directly inside its directory, including the subdirectory barrels below it, so callers can import from any depth. This field works on a plugin's `output.barrel` only.
90
+
91
+ | | |
92
+ | -------- | --------- |
93
+ | Type | `boolean` |
94
+ | Required | `false` |
95
+ | Default | `false` |
96
+
97
+ ::code-group
98
+
99
+ ```typescript [nested: false (default) → barrels reference leaf files]
100
+ // src/gen/api/index.ts
101
+ export * from './user'
102
+ export * from './post'
103
+ export * from './types/User'
104
+
105
+ // src/gen/api/types/index.ts
106
+ export * from './User'
107
+ ```
108
+
109
+ ```typescript [nested: true → barrels reference sub-barrels]
110
+ // src/gen/api/index.ts re-exports its files and subdirectories
111
+ export * from './user'
112
+ export * from './post'
113
+ export * from './types'
114
+
115
+ // src/gen/api/types/index.ts re-exports its files
116
+ export * from './User'
117
+ ```
118
+
119
+ ::
@@ -8,17 +8,6 @@ Kubb adds it to `plugins` for you. Do not add it yourself. It generates nothing
8
8
 
9
9
  Set `output.barrel` on `defineConfig` to write a root barrel. Plugins without a barrel setting of their own inherit it.
10
10
 
11
- ```ts
12
- import { defineConfig } from 'kubb/config'
13
- import { pluginTs } from '@kubb/plugin-ts'
14
-
15
- export default defineConfig({
16
- input: './petStore.yaml',
17
- output: { path: './src/gen', barrel: { type: 'named' } },
18
- plugins: [pluginTs()],
19
- })
20
- ```
21
-
22
11
  ## Options
23
12
 
24
13
  The plugin takes no arguments. You configure it through `output.barrel`, on `defineConfig` or on a single plugin.
@@ -28,3 +17,18 @@ The plugin takes no arguments. You configure it through `output.barrel`, on `def
28
17
  - `false` on a plugin turns its barrel off and leaves its files out of the root barrel.
29
18
 
30
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.
20
+
21
+ See [Options](https://kubb.dev/extensions/kubb-labs/plugin-barrel/options) for the export `type`, `nested` barrels, and per-plugin overrides.
22
+
23
+ ## Example
24
+
25
+ ```typescript [kubb.config.ts]
26
+ import { defineConfig } from 'kubb/config'
27
+ import { pluginTs } from '@kubb/plugin-ts'
28
+
29
+ export default defineConfig({
30
+ input: './petStore.yaml',
31
+ output: { path: './src/gen', barrel: { type: 'named' } },
32
+ plugins: [pluginTs()],
33
+ })
34
+ ```
@@ -10,9 +10,10 @@
10
10
  "light": "https://kubb.dev/feature/plugins-light.svg"
11
11
  },
12
12
  "tags": ["barrel", "index", "exports", "output"],
13
- "docs": "https://kubb.dev/plugins/plugin-barrel",
13
+ "docs": "https://kubb.dev/extensions/kubb-labs/plugin-barrel",
14
+ "maintainers": [{ "name": "Stijn Van Hulle", "github": "stijnvanhulle" }],
14
15
  "compatibility": {
15
- "kubb": ">=5.8.0",
16
+ "kubb": ">=5.8.3",
16
17
  "node": ">=22"
17
18
  }
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-barrel",
3
- "version": "5.8.2",
3
+ "version": "5.8.4",
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",
@@ -10,7 +10,7 @@
10
10
  "plugin",
11
11
  "typescript"
12
12
  ],
13
- "homepage": "https://kubb.dev/plugins/plugin-barrel",
13
+ "homepage": "https://kubb.dev/extensions/kubb-labs/plugin-barrel",
14
14
  "license": "MIT",
15
15
  "author": "stijnvanhulle",
16
16
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "files": [
36
36
  "dist",
37
37
  "kubb-extension.json",
38
- "OVERVIEW.md",
38
+ "docs",
39
39
  "*.d.ts",
40
40
  "*.d.cts",
41
41
  "!/**/**.test.**",
@@ -61,11 +61,11 @@
61
61
  "registry": "https://registry.npmjs.org/"
62
62
  },
63
63
  "dependencies": {
64
- "@kubb/kit": "5.8.2"
64
+ "@kubb/kit": "5.8.4"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@internals/utils": "0.0.1",
68
- "@kubb/core": "5.8.2"
68
+ "@kubb/core": "5.8.4"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=22"