@kubb/plugin-barrel 5.8.3 → 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 +17 -17
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/docs/options.md +1 -1
- package/docs/overview.md +13 -11
- package/kubb-extension.json +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
### Barrel-file plugin for Kubb
|
|
26
26
|
|
|
27
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
|
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
|
|
69
|
-
|
|
|
70
|
-
| `'all'`
|
|
71
|
-
| `'named'`
|
|
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
|
|
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
|
@@ -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.
|
|
69
|
+
"kubb": ">=5.8.3",
|
|
70
70
|
"node": ">=22"
|
|
71
71
|
};
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region package.json
|
|
74
|
-
var version = "5.
|
|
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
|
@@ -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.
|
|
46
|
+
"kubb": ">=5.8.3",
|
|
47
47
|
"node": ">=22"
|
|
48
48
|
};
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region package.json
|
|
51
|
-
var version = "5.
|
|
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
|
|
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
|
|
1
|
+
# Barrel
|
|
2
2
|
|
|
3
|
-
The
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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: [
|
|
32
|
+
plugins: [
|
|
33
|
+
pluginTs(),
|
|
34
|
+
],
|
|
33
35
|
})
|
|
34
36
|
```
|
package/kubb-extension.json
CHANGED
|
@@ -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
|
|
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"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"docs": "https://kubb.dev/extensions/kubb-labs/plugin-barrel",
|
|
14
14
|
"maintainers": [{ "name": "Stijn Van Hulle", "github": "stijnvanhulle" }],
|
|
15
15
|
"compatibility": {
|
|
16
|
-
"kubb": ">=5.8.
|
|
16
|
+
"kubb": ">=5.8.3",
|
|
17
17
|
"node": ">=22"
|
|
18
18
|
}
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-barrel",
|
|
3
|
-
"version": "5.
|
|
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.
|
|
64
|
+
"@kubb/kit": "5.9.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@internals/utils": "0.0.1",
|
|
68
|
-
"@kubb/core": "5.
|
|
68
|
+
"@kubb/core": "5.9.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=22"
|