@kubb/middleware-barrel 5.0.0-alpha.63 → 5.0.0-alpha.65

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/dist/index.cjs CHANGED
@@ -9,10 +9,13 @@ let _kubb_ast = require("@kubb/ast");
9
9
  */
10
10
  const BARREL_FILENAME = "index.ts";
11
11
  //#endregion
12
- //#region src/utils/buildTree.ts
12
+ //#region ../../internals/utils/src/buildTree.ts
13
13
  /**
14
14
  * Builds a directory tree rooted at `rootPath` from a list of absolute file paths.
15
- * Paths outside `rootPath` are silently ignored.
15
+ * Paths outside `rootPath` are silently ignored. Children are sorted alphabetically
16
+ * by path so consumers (barrel exports, propagated indexes) emit a deterministic order.
17
+ *
18
+ * Both POSIX (`/`) and Windows (`\`) separators are accepted in input paths.
16
19
  *
17
20
  * @example
18
21
  * ```ts
@@ -28,28 +31,45 @@ function buildTree(rootPath, filePaths) {
28
31
  children: [],
29
32
  isFile: false
30
33
  };
34
+ const childIndex = /* @__PURE__ */ new Map();
35
+ childIndex.set(root, /* @__PURE__ */ new Map());
36
+ const rootPrefix = `${rootPath.replaceAll("\\", "/")}/`;
31
37
  for (const filePath of filePaths) {
32
- if (!filePath.startsWith(rootPath + node_path.posix.sep) && !filePath.startsWith(rootPath + "/")) continue;
33
- const parts = filePath.slice(rootPath.length).replace(/^\//g, "").replace(/^\\/g, "").split(/[/\\]/).filter(Boolean);
38
+ const normalized = filePath.replaceAll("\\", "/");
39
+ if (!normalized.startsWith(rootPrefix)) continue;
40
+ const parts = normalized.slice(rootPrefix.length).split("/");
41
+ if (parts.length === 0) continue;
34
42
  let current = root;
35
- for (let i = 0; i < parts.length; i++) {
36
- const isLast = i === parts.length - 1;
37
- const part = parts[i];
38
- const childPath = `${current.path}/${part}`;
39
- let child = current.children.find((c) => c.path === childPath);
43
+ const lastIndex = parts.length - 1;
44
+ for (const [i, part] of parts.entries()) {
45
+ if (!part) continue;
46
+ const isLast = i === lastIndex;
47
+ const siblings = childIndex.get(current);
48
+ let child = siblings.get(part);
40
49
  if (!child) {
41
50
  child = {
42
- path: childPath,
51
+ path: `${current.path}/${part}`,
43
52
  children: [],
44
53
  isFile: isLast
45
54
  };
46
55
  current.children.push(child);
56
+ siblings.set(part, child);
57
+ if (!isLast) childIndex.set(child, /* @__PURE__ */ new Map());
47
58
  }
48
59
  current = child;
49
60
  }
50
61
  }
62
+ sortTree(root);
51
63
  return root;
52
64
  }
65
+ function sortTree(node) {
66
+ if (node.children.length === 0) return;
67
+ node.children.sort(compareByPath);
68
+ for (const child of node.children) if (!child.isFile) sortTree(child);
69
+ }
70
+ function compareByPath(a, b) {
71
+ return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
72
+ }
53
73
  //#endregion
54
74
  //#region src/utils/getBarrelFiles.ts
55
75
  const SOURCE_EXTENSIONS = new Set([
@@ -58,6 +78,7 @@ const SOURCE_EXTENSIONS = new Set([
58
78
  ".js",
59
79
  ".jsx"
60
80
  ]);
81
+ const BARREL_SUFFIX = `/${BARREL_FILENAME}`;
61
82
  /**
62
83
  * Derives a relative module specifier from `filePath` relative to `fromDir`.
63
84
  * The source extension is preserved so `@kubb/parser-ts` can apply its `extNames` mapping.
@@ -69,107 +90,116 @@ const SOURCE_EXTENSIONS = new Set([
69
90
  * ```
70
91
  */
71
92
  function toRelativeModulePath(fromDir, filePath) {
72
- return `./${filePath.slice(fromDir.length).replace(/^[/\\]/g, "")}`;
93
+ return `./${filePath.slice(fromDir.length + 1)}`;
73
94
  }
74
- function getBarrelFilesAll({ treeNode, sourceFiles, recursive = false }) {
75
- const leafPaths = collectLeafPaths(treeNode).filter((p) => !p.endsWith(`/${BARREL_FILENAME}`));
76
- if (leafPaths.length === 0) return [];
77
- const exports = [];
78
- for (const filePath of leafPaths) {
79
- const sourceFile = sourceFiles.find((f) => f.path === filePath);
80
- if (sourceFile && sourceFile.sources.length > 0 && sourceFile.sources.every((s) => !s.isIndexable)) continue;
81
- exports.push((0, _kubb_ast.createExport)({ path: toRelativeModulePath(treeNode.path, filePath) }));
82
- }
83
- const result = [];
84
- if (recursive) {
85
- for (const child of treeNode.children) if (!child.isFile) result.push(...getBarrelFilesAll({
86
- treeNode: child,
87
- sourceFiles,
88
- recursive: true
89
- }));
90
- }
91
- if (exports.length === 0) return result;
92
- result.push((0, _kubb_ast.createFile)({
95
+ function isBarrelPath(path) {
96
+ return path.endsWith(BARREL_SUFFIX);
97
+ }
98
+ function makeBarrel(dirPath, exports) {
99
+ return (0, _kubb_ast.createFile)({
93
100
  baseName: BARREL_FILENAME,
94
- path: `${treeNode.path}/${BARREL_FILENAME}`,
101
+ path: `${dirPath}${BARREL_SUFFIX}`,
95
102
  exports,
96
103
  sources: [],
97
104
  imports: []
98
- }));
99
- return result;
105
+ });
106
+ }
107
+ function hasOnlyNonIndexableSources(sources) {
108
+ if (sources.length === 0) return false;
109
+ for (const source of sources) if (source.isIndexable) return false;
110
+ return true;
100
111
  }
101
- function getBarrelFilesNamed({ treeNode, sourceFiles, recursive = false }) {
102
- const leafPaths = collectLeafPaths(treeNode).filter((p) => !p.endsWith(`/${BARREL_FILENAME}`));
103
- if (leafPaths.length === 0) return [];
112
+ function partitionIndexableNames(sources) {
113
+ const byTypeOnly = new Map([[false, /* @__PURE__ */ new Set()], [true, /* @__PURE__ */ new Set()]]);
114
+ for (const source of sources) {
115
+ if (!source.isIndexable || !source.name) continue;
116
+ byTypeOnly.get(Boolean(source.isTypeOnly)).add(source.name);
117
+ }
118
+ return byTypeOnly;
119
+ }
120
+ const allStrategy = ({ dirPath, leafPath, sourceFile }) => {
121
+ if (sourceFile && hasOnlyNonIndexableSources(sourceFile.sources)) return [];
122
+ return [(0, _kubb_ast.createExport)({ path: toRelativeModulePath(dirPath, leafPath) })];
123
+ };
124
+ const namedStrategy = ({ dirPath, leafPath, sourceFile }) => {
125
+ const modulePath = toRelativeModulePath(dirPath, leafPath);
126
+ if (!sourceFile) return [(0, _kubb_ast.createExport)({ path: modulePath })];
127
+ const namesByTypeOnly = partitionIndexableNames(sourceFile.sources);
128
+ const valueNames = namesByTypeOnly.get(false);
129
+ const typeNames = namesByTypeOnly.get(true);
130
+ if (valueNames.size === 0 && typeNames.size === 0) {
131
+ if (sourceFile.sources.length > 0) return [];
132
+ return [(0, _kubb_ast.createExport)({ path: modulePath })];
133
+ }
104
134
  const exports = [];
105
- for (const filePath of leafPaths) {
106
- const sourceFile = sourceFiles.find((f) => f.path === filePath);
107
- if (!sourceFile) {
108
- exports.push((0, _kubb_ast.createExport)({ path: toRelativeModulePath(treeNode.path, filePath) }));
109
- continue;
110
- }
111
- const indexableSources = sourceFile.sources.filter((s) => s.isIndexable && s.name);
112
- if (indexableSources.length === 0) {
113
- if (sourceFile.sources.length > 0) continue;
114
- exports.push((0, _kubb_ast.createExport)({ path: toRelativeModulePath(treeNode.path, filePath) }));
135
+ if (valueNames.size > 0) exports.push((0, _kubb_ast.createExport)({
136
+ name: [...valueNames].sort(),
137
+ path: modulePath
138
+ }));
139
+ if (typeNames.size > 0) exports.push((0, _kubb_ast.createExport)({
140
+ name: [...typeNames].sort(),
141
+ path: modulePath,
142
+ isTypeOnly: true
143
+ }));
144
+ return exports;
145
+ };
146
+ const LEAF_STRATEGIES = new Map([["all", allStrategy], ["named", namedStrategy]]);
147
+ /**
148
+ * Single-pass post-order traversal that emits a barrel for each visited directory and
149
+ * returns its leaf paths so parents don't have to re-walk the subtree.
150
+ */
151
+ function walkAllOrNamed(node, params, isRoot, out) {
152
+ const subtreeLeaves = [];
153
+ for (const child of node.children) {
154
+ if (child.isFile) {
155
+ if (!isBarrelPath(child.path)) subtreeLeaves.push(child.path);
115
156
  continue;
116
157
  }
117
- const valueNames = indexableSources.filter((s) => !s.isTypeOnly).map((s) => s.name);
118
- const typeNames = indexableSources.filter((s) => s.isTypeOnly).map((s) => s.name);
119
- const modulePath = toRelativeModulePath(treeNode.path, filePath);
120
- if (valueNames.length > 0) exports.push((0, _kubb_ast.createExport)({
121
- name: valueNames,
122
- path: modulePath
123
- }));
124
- if (typeNames.length > 0) exports.push((0, _kubb_ast.createExport)({
125
- name: typeNames,
126
- path: modulePath,
127
- isTypeOnly: true
128
- }));
129
- }
130
- const result = [];
131
- if (recursive) {
132
- for (const child of treeNode.children) if (!child.isFile) result.push(...getBarrelFilesNamed({
133
- treeNode: child,
134
- sourceFiles,
135
- recursive: true
136
- }));
158
+ const childLeaves = walkAllOrNamed(child, params, false, out);
159
+ for (const leaf of childLeaves) subtreeLeaves.push(leaf);
137
160
  }
138
- if (exports.length > 0) result.push((0, _kubb_ast.createFile)({
139
- baseName: BARREL_FILENAME,
140
- path: `${treeNode.path}/${BARREL_FILENAME}`,
141
- exports,
142
- sources: [],
143
- imports: []
161
+ if (!isRoot && !params.recursive) return subtreeLeaves;
162
+ const exports = subtreeLeaves.flatMap((leafPath) => params.strategy({
163
+ dirPath: node.path,
164
+ leafPath,
165
+ sourceFile: params.sourceFiles.get(leafPath)
144
166
  }));
145
- return result;
167
+ if (exports.length > 0) out.push(makeBarrel(node.path, exports));
168
+ return subtreeLeaves;
146
169
  }
147
- function getBarrelFilesPropagate({ treeNode }) {
148
- return collectPropagatedBarrels(treeNode);
149
- }
150
- function collectPropagatedBarrels(node) {
151
- const result = [];
152
- const barrelExports = [];
153
- for (const child of node.children) if (child.isFile) {
154
- if (!child.path.endsWith(`/index.ts`)) barrelExports.push((0, _kubb_ast.createExport)({ path: toRelativeModulePath(node.path, child.path) }));
155
- } else {
156
- const subBarrels = collectPropagatedBarrels(child);
157
- result.push(...subBarrels);
158
- const subBarrelPath = `${child.path}/${BARREL_FILENAME}`;
159
- barrelExports.push((0, _kubb_ast.createExport)({ path: toRelativeModulePath(node.path, subBarrelPath) }));
170
+ /**
171
+ * Emits one barrel per directory: every direct child file is re-exported and every
172
+ * sub-directory is re-exported via its own barrel (recursive by design).
173
+ */
174
+ function walkPropagate(node, out) {
175
+ const exports = [];
176
+ for (const child of node.children) {
177
+ if (child.isFile) {
178
+ if (isBarrelPath(child.path)) continue;
179
+ exports.push((0, _kubb_ast.createExport)({ path: toRelativeModulePath(node.path, child.path) }));
180
+ continue;
181
+ }
182
+ walkPropagate(child, out);
183
+ exports.push((0, _kubb_ast.createExport)({ path: toRelativeModulePath(node.path, `${child.path}${BARREL_SUFFIX}`) }));
160
184
  }
161
- if (barrelExports.length > 0) result.push((0, _kubb_ast.createFile)({
162
- baseName: BARREL_FILENAME,
163
- path: `${node.path}/${BARREL_FILENAME}`,
164
- exports: barrelExports,
165
- sources: [],
166
- imports: []
167
- }));
168
- return result;
185
+ if (exports.length > 0) out.push(makeBarrel(node.path, exports));
169
186
  }
170
- function collectLeafPaths(node) {
171
- if (node.isFile) return [node.path];
172
- return node.children.flatMap((c) => collectLeafPaths(c));
187
+ function indexRelevantFiles(files, outputPath) {
188
+ const outputPrefix = `${outputPath.replaceAll("\\", "/")}/`;
189
+ const sourceFiles = /* @__PURE__ */ new Map();
190
+ const paths = [];
191
+ for (const file of files) {
192
+ const normalized = file.path.replaceAll("\\", "/");
193
+ if (!normalized.startsWith(outputPrefix)) continue;
194
+ if (isBarrelPath(normalized)) continue;
195
+ if (!SOURCE_EXTENSIONS.has((0, node_path.extname)(normalized))) continue;
196
+ sourceFiles.set(file.path, file);
197
+ paths.push(file.path);
198
+ }
199
+ return {
200
+ sourceFiles,
201
+ paths
202
+ };
173
203
  }
174
204
  /**
175
205
  * Generates barrel `FileNode`s for the directory rooted at `outputPath`.
@@ -178,31 +208,22 @@ function collectLeafPaths(node) {
178
208
  * before the tree is built.
179
209
  */
180
210
  function getBarrelFiles({ outputPath, files, barrelType, recursive = false }) {
181
- const relevantFiles = files.filter((f) => {
182
- const normalizedFilePath = f.path.replace(/\\/g, "/");
183
- const normalizedOutputPath = outputPath.replace(/\\/g, "/");
184
- if (!normalizedFilePath.startsWith(normalizedOutputPath + "/")) return false;
185
- if (normalizedFilePath.endsWith(`/index.ts`)) return false;
186
- const dotIndex = normalizedFilePath.lastIndexOf(".");
187
- const ext = dotIndex === -1 ? "" : normalizedFilePath.slice(dotIndex);
188
- return SOURCE_EXTENSIONS.has(ext);
189
- });
190
- if (relevantFiles.length === 0) return [];
191
- const tree = buildTree(outputPath, relevantFiles.map((f) => f.path));
192
- switch (barrelType) {
193
- case "all": return getBarrelFilesAll({
194
- treeNode: tree,
195
- sourceFiles: relevantFiles,
196
- recursive
197
- });
198
- case "named": return getBarrelFilesNamed({
199
- treeNode: tree,
200
- sourceFiles: relevantFiles,
201
- recursive
202
- });
203
- case "propagate": return getBarrelFilesPropagate({ treeNode: tree });
204
- default: return [];
211
+ const { sourceFiles, paths } = indexRelevantFiles(files, outputPath);
212
+ if (paths.length === 0) return [];
213
+ const tree = buildTree(outputPath, paths);
214
+ const result = [];
215
+ if (barrelType === "propagate") {
216
+ walkPropagate(tree, result);
217
+ return result;
205
218
  }
219
+ const strategy = LEAF_STRATEGIES.get(barrelType);
220
+ if (!strategy) return result;
221
+ walkAllOrNamed(tree, {
222
+ sourceFiles,
223
+ strategy,
224
+ recursive
225
+ }, true, result);
226
+ return result;
206
227
  }
207
228
  //#endregion
208
229
  //#region src/utils/generatePerPluginBarrel.ts
@@ -237,6 +258,44 @@ function generateRootBarrel({ barrelType, files, config }) {
237
258
  });
238
259
  }
239
260
  //#endregion
261
+ //#region src/utils/excludedPaths.ts
262
+ /**
263
+ * Returns the absolute output directory of `plugin` with a trailing separator,
264
+ * suitable for prefix-based exclusion checks via {@link isExcludedPath}.
265
+ *
266
+ * The trailing `/` ensures `startsWith` does not match unrelated siblings
267
+ * (e.g. `/foo/bar` vs `/foo/barbaz/x.ts`).
268
+ */
269
+ function getPluginOutputPrefix(plugin, config) {
270
+ return `${(0, node_path.resolve)(config.root, config.output.path, plugin.options.output.path)}/`;
271
+ }
272
+ /**
273
+ * Returns `true` when `filePath` lies under any of the directory prefixes in `prefixes`.
274
+ * Prefixes must already include a trailing separator (see {@link getPluginOutputPrefix}).
275
+ *
276
+ * Uses Node 22 iterator helpers (`Iterator.prototype.some`) to avoid materializing the set.
277
+ */
278
+ function isExcludedPath(filePath, prefixes) {
279
+ return prefixes.values().some((prefix) => filePath.startsWith(prefix));
280
+ }
281
+ //#endregion
282
+ //#region src/utils/resolveBarrelType.ts
283
+ const DEFAULT_BARREL_TYPE = "named";
284
+ /**
285
+ * Resolves the effective barrel style for a single plugin: explicit plugin option →
286
+ * root config option → `'named'` default. Returns `false` when barrel generation is disabled.
287
+ */
288
+ function resolvePluginBarrelType(plugin, config) {
289
+ return plugin.options.output?.barrelType ?? config.output.barrelType ?? DEFAULT_BARREL_TYPE;
290
+ }
291
+ /**
292
+ * Resolves the effective barrel style for the root `index.ts`: root config option → `'named'` default.
293
+ * Returns `false` when the root barrel is disabled.
294
+ */
295
+ function resolveRootBarrelType(config) {
296
+ return config.output.barrelType ?? DEFAULT_BARREL_TYPE;
297
+ }
298
+ //#endregion
240
299
  //#region src/middleware.ts
241
300
  /**
242
301
  * Generates `index.ts` barrel files for each plugin's output directory and one root barrel
@@ -265,15 +324,15 @@ const middlewareBarrel = (0, _kubb_core.defineMiddleware)({
265
324
  name: "middleware-barrel",
266
325
  install(hooks) {
267
326
  let ctx;
268
- const excludedPaths = /* @__PURE__ */ new Set();
327
+ const excludedPrefixes = /* @__PURE__ */ new Set();
269
328
  hooks.on("kubb:build:start", (buildCtx) => {
270
329
  ctx = buildCtx;
271
330
  });
272
331
  hooks.on("kubb:plugin:end", ({ plugin }) => {
273
332
  if (!ctx) return;
274
- const barrelType = plugin.options.output?.barrelType ?? ctx.config.output.barrelType ?? "all";
333
+ const barrelType = resolvePluginBarrelType(plugin, ctx.config);
275
334
  if (!barrelType) {
276
- excludedPaths.add((0, node_path.resolve)(ctx.config.root, ctx.config.output.path, plugin.options.output.path));
335
+ excludedPrefixes.add(getPluginOutputPrefix(plugin, ctx.config));
277
336
  return;
278
337
  }
279
338
  const barrelFiles = generatePerPluginBarrel({
@@ -285,11 +344,11 @@ const middlewareBarrel = (0, _kubb_core.defineMiddleware)({
285
344
  if (barrelFiles.length > 0) ctx.upsertFile(...barrelFiles);
286
345
  });
287
346
  hooks.on("kubb:plugins:end", ({ files, config, upsertFile }) => {
288
- const rootBarrelType = config.output.barrelType ?? "named";
347
+ const rootBarrelType = resolveRootBarrelType(config);
289
348
  if (!rootBarrelType) return;
290
349
  const rootBarrelFiles = generateRootBarrel({
291
350
  barrelType: rootBarrelType,
292
- files: excludedPaths.size > 0 ? files.filter((f) => ![...excludedPaths].some((excluded) => f.path.startsWith(excluded + "/"))) : files,
351
+ files: excludedPrefixes.size === 0 ? files : files.filter((f) => !isExcludedPath(f.path, excludedPrefixes)),
293
352
  config
294
353
  });
295
354
  if (rootBarrelFiles.length > 0) upsertFile(...rootBarrelFiles);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["posix"],"sources":["../src/constants.ts","../src/utils/buildTree.ts","../src/utils/getBarrelFiles.ts","../src/utils/generatePerPluginBarrel.ts","../src/utils/generateRootBarrel.ts","../src/middleware.ts"],"sourcesContent":["/**\n * Full file name for barrel files (with extension).\n */\nexport const BARREL_FILENAME = 'index.ts' as const\n","import { posix } from 'node:path'\n\n/**\n * A node in the directory tree used to compute barrel file exports.\n * Either represents a directory (with `children`) or a file (`isFile: true`, empty `children`).\n */\nexport type BuildTree = {\n /**\n * Absolute filesystem path of this directory or file.\n */\n path: string\n /**\n * Sub-directories and files contained within this directory.\n * Always empty for file nodes.\n */\n children: Array<BuildTree>\n /**\n * `true` when this node represents a file (leaf), `false` for directory nodes.\n */\n isFile: boolean\n}\n\n/**\n * Builds a directory tree rooted at `rootPath` from a list of absolute file paths.\n * Paths outside `rootPath` are silently ignored.\n *\n * @example\n * ```ts\n * buildTree('/src/gen/types', [\n * '/src/gen/types/pet.ts',\n * '/src/gen/types/pets/listPets.ts',\n * ])\n * ```\n */\nexport function buildTree(rootPath: string, filePaths: ReadonlyArray<string>): BuildTree {\n const root: BuildTree = { path: rootPath, children: [], isFile: false }\n\n for (const filePath of filePaths) {\n // Only include files inside rootPath\n if (!filePath.startsWith(rootPath + posix.sep) && !filePath.startsWith(rootPath + '/')) {\n continue\n }\n\n const relative = filePath.slice(rootPath.length).replace(/^\\//g, '').replace(/^\\\\/g, '')\n const parts = relative.split(/[/\\\\]/).filter(Boolean)\n\n let current = root\n for (let i = 0; i < parts.length; i++) {\n const isLast = i === parts.length - 1\n const part = parts[i]!\n const childPath = `${current.path}/${part}`\n\n let child = current.children.find((c) => c.path === childPath)\n if (!child) {\n child = { path: childPath, children: [], isFile: isLast }\n current.children.push(child)\n }\n current = child\n }\n }\n\n return root\n}\n","import { createExport, createFile } from '@kubb/ast'\nimport type { FileNode } from '@kubb/ast'\nimport { BARREL_FILENAME } from '../constants.ts'\nimport type { BarrelType } from '../types.ts'\nimport { buildTree, type BuildTree } from './buildTree.ts'\n\nconst SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\n\n/**\n * Derives a relative module specifier from `filePath` relative to `fromDir`.\n * The source extension is preserved so `@kubb/parser-ts` can apply its `extNames` mapping.\n *\n * @example\n * ```ts\n * toRelativeModulePath('/src/gen/types', '/src/gen/types/pet.ts') // './pet.ts'\n * toRelativeModulePath('/src/gen/types', '/src/gen/types/tags/tag.ts') // './tags/tag.ts'\n * ```\n */\nfunction toRelativeModulePath(fromDir: string, filePath: string): string {\n const relative = filePath.slice(fromDir.length).replace(/^[/\\\\]/g, '')\n return `./${relative}`\n}\n\ntype BarrelFilesParams = {\n treeNode: BuildTree\n sourceFiles: ReadonlyArray<FileNode>\n recursive?: boolean\n}\n\nfunction getBarrelFilesAll({ treeNode, sourceFiles, recursive = false }: BarrelFilesParams): Array<FileNode> {\n const leafPaths = collectLeafPaths(treeNode).filter((p) => !p.endsWith(`/${BARREL_FILENAME}`))\n\n if (leafPaths.length === 0) return []\n\n const exports: ReturnType<typeof createExport>[] = []\n\n for (const filePath of leafPaths) {\n const sourceFile = sourceFiles.find((f) => f.path === filePath)\n if (sourceFile && sourceFile.sources.length > 0 && sourceFile.sources.every((s) => !s.isIndexable)) {\n continue\n }\n exports.push(createExport({ path: toRelativeModulePath(treeNode.path, filePath) }))\n }\n\n const result: Array<FileNode> = []\n\n if (recursive) {\n for (const child of treeNode.children) {\n if (!child.isFile) {\n result.push(...getBarrelFilesAll({ treeNode: child, sourceFiles, recursive: true }))\n }\n }\n }\n\n if (exports.length === 0) return result\n\n result.push(\n createFile({\n baseName: BARREL_FILENAME,\n path: `${treeNode.path}/${BARREL_FILENAME}`,\n exports,\n sources: [],\n imports: [],\n }),\n )\n\n return result\n}\n\nfunction getBarrelFilesNamed({ treeNode, sourceFiles, recursive = false }: BarrelFilesParams): Array<FileNode> {\n const leafPaths = collectLeafPaths(treeNode).filter((p) => !p.endsWith(`/${BARREL_FILENAME}`))\n\n if (leafPaths.length === 0) return []\n\n const exports: ReturnType<typeof createExport>[] = []\n\n for (const filePath of leafPaths) {\n const sourceFile = sourceFiles.find((f) => f.path === filePath)\n if (!sourceFile) {\n exports.push(createExport({ path: toRelativeModulePath(treeNode.path, filePath) }))\n continue\n }\n\n const indexableSources = sourceFile.sources.filter((s) => s.isIndexable && s.name)\n if (indexableSources.length === 0) {\n if (sourceFile.sources.length > 0) continue\n exports.push(createExport({ path: toRelativeModulePath(treeNode.path, filePath) }))\n continue\n }\n\n const valueNames = indexableSources.filter((s) => !s.isTypeOnly).map((s) => s.name as string)\n const typeNames = indexableSources.filter((s) => s.isTypeOnly).map((s) => s.name as string)\n const modulePath = toRelativeModulePath(treeNode.path, filePath)\n\n if (valueNames.length > 0) {\n exports.push(createExport({ name: valueNames, path: modulePath }))\n }\n if (typeNames.length > 0) {\n exports.push(createExport({ name: typeNames, path: modulePath, isTypeOnly: true }))\n }\n }\n\n const result: Array<FileNode> = []\n\n if (recursive) {\n for (const child of treeNode.children) {\n if (!child.isFile) {\n result.push(...getBarrelFilesNamed({ treeNode: child, sourceFiles, recursive: true }))\n }\n }\n }\n\n if (exports.length > 0) {\n result.push(\n createFile({\n baseName: BARREL_FILENAME,\n path: `${treeNode.path}/${BARREL_FILENAME}`,\n exports,\n sources: [],\n imports: [],\n }),\n )\n }\n\n return result\n}\n\nfunction getBarrelFilesPropagate({ treeNode }: Pick<BarrelFilesParams, 'treeNode'>): Array<FileNode> {\n return collectPropagatedBarrels(treeNode)\n}\n\nfunction collectPropagatedBarrels(node: BuildTree): Array<FileNode> {\n const result: Array<FileNode> = []\n const barrelExports: ReturnType<typeof createExport>[] = []\n\n for (const child of node.children) {\n if (child.isFile) {\n if (!child.path.endsWith(`/${BARREL_FILENAME}`)) {\n barrelExports.push(createExport({ path: toRelativeModulePath(node.path, child.path) }))\n }\n } else {\n const subBarrels = collectPropagatedBarrels(child)\n result.push(...subBarrels)\n\n const subBarrelPath = `${child.path}/${BARREL_FILENAME}`\n barrelExports.push(createExport({ path: toRelativeModulePath(node.path, subBarrelPath) }))\n }\n }\n\n if (barrelExports.length > 0) {\n result.push(\n createFile({\n baseName: BARREL_FILENAME,\n path: `${node.path}/${BARREL_FILENAME}`,\n exports: barrelExports,\n sources: [],\n imports: [],\n }),\n )\n }\n\n return result\n}\n\nfunction collectLeafPaths(node: BuildTree): Array<string> {\n if (node.isFile) return [node.path]\n return node.children.flatMap((c) => collectLeafPaths(c))\n}\n\nexport type GetBarrelFilesParams = {\n /**\n * Absolute path to the directory the barrel(s) should be rooted at.\n * Files outside this directory are ignored.\n */\n outputPath: string\n /**\n * Full set of generated files across all plugins.\n * Used both to discover what to re-export and to read each file's indexable sources.\n */\n files: ReadonlyArray<FileNode>\n /**\n * Re-export style used in the generated barrel(s).\n */\n barrelType: BarrelType\n /**\n * When `true`, also generate a barrel for each sub-directory of `outputPath`.\n * Used by per-plugin barrels so that grouped output (e.g. `petController/`) gets its own `index.ts`.\n *\n * Has no effect for `barrelType: 'propagate'`, which always recurses by design.\n *\n * @default false\n */\n recursive?: boolean\n}\n\n/**\n * Generates barrel `FileNode`s for the directory rooted at `outputPath`.\n *\n * Files outside `outputPath`, existing barrel files, and non-source extensions are filtered out\n * before the tree is built.\n */\nexport function getBarrelFiles({ outputPath, files, barrelType, recursive = false }: GetBarrelFilesParams): Array<FileNode> {\n const relevantFiles = files.filter((f) => {\n const normalizedFilePath = f.path.replace(/\\\\/g, '/')\n const normalizedOutputPath = outputPath.replace(/\\\\/g, '/')\n if (!normalizedFilePath.startsWith(normalizedOutputPath + '/')) return false\n if (normalizedFilePath.endsWith(`/${BARREL_FILENAME}`)) return false\n const dotIndex = normalizedFilePath.lastIndexOf('.')\n const ext = dotIndex === -1 ? '' : normalizedFilePath.slice(dotIndex)\n return SOURCE_EXTENSIONS.has(ext)\n })\n\n if (relevantFiles.length === 0) return []\n\n const tree = buildTree(\n outputPath,\n relevantFiles.map((f) => f.path),\n )\n\n switch (barrelType) {\n case 'all':\n return getBarrelFilesAll({ treeNode: tree, sourceFiles: relevantFiles, recursive })\n case 'named':\n return getBarrelFilesNamed({ treeNode: tree, sourceFiles: relevantFiles, recursive })\n case 'propagate':\n return getBarrelFilesPropagate({ treeNode: tree })\n default:\n return []\n }\n}\n","import { resolve } from 'node:path'\nimport type { FileNode } from '@kubb/ast'\nimport type { Config, NormalizedPlugin } from '@kubb/core'\nimport type { BarrelType } from '../types.ts'\nimport { getBarrelFiles } from './getBarrelFiles.ts'\n\nexport type GeneratePerPluginBarrelParams = {\n /**\n * Re-export style used in the plugin's barrel file(s).\n */\n barrelType: BarrelType\n /**\n * Plugin whose `output.path` determines the barrel directory.\n */\n plugin: NormalizedPlugin\n /**\n * Full set of generated files across all plugins.\n * Files outside the plugin's output directory are filtered out automatically.\n */\n files: ReadonlyArray<FileNode>\n /**\n * Resolved Kubb config; used to compute the absolute output directory.\n */\n config: Config\n}\n\n/**\n * Generates barrel files for a single plugin's output directory.\n *\n * The barrel is placed at `<config.root>/<config.output.path>/<plugin.options.output.path>/index.ts`.\n * When the plugin uses `group`, additional sub-directory barrels are generated so that grouped\n * output (e.g. `petController/index.ts`) gets its own re-export entry point.\n */\nexport function generatePerPluginBarrel({ barrelType, plugin, files, config }: GeneratePerPluginBarrelParams): Array<FileNode> {\n const outputPath = resolve(config.root, config.output.path, plugin.options.output.path)\n\n return getBarrelFiles({ outputPath, files, barrelType, recursive: true })\n}\n","import { resolve } from 'node:path'\nimport type { FileNode } from '@kubb/ast'\nimport type { Config } from '@kubb/core'\nimport type { BarrelType } from '../types.ts'\nimport { getBarrelFiles } from './getBarrelFiles.ts'\n\nexport type GenerateRootBarrelParams = {\n /**\n * Re-export style used in the root barrel file.\n */\n barrelType: BarrelType\n /**\n * Files eligible for re-export. The middleware filters out files belonging to plugins\n * with `barrelType: false` before passing them in.\n */\n files: ReadonlyArray<FileNode>\n /**\n * Resolved Kubb config; used to compute the root output directory.\n */\n config: Config\n}\n\n/**\n * Generates the root barrel file at `<config.root>/<config.output.path>/index.ts`.\n *\n * Unlike `generatePerPluginBarrel`, this does not recurse into sub-directories — each\n * plugin is responsible for its own per-plugin barrels.\n */\nexport function generateRootBarrel({ barrelType, files, config }: GenerateRootBarrelParams): Array<FileNode> {\n const outputPath = resolve(config.root, config.output.path)\n\n return getBarrelFiles({ outputPath, files, barrelType })\n}\n","import { defineMiddleware } from '@kubb/core'\nimport type { KubbBuildStartContext } from '@kubb/core'\nimport type { BarrelType } from './types.ts'\nimport { generatePerPluginBarrel } from './utils/generatePerPluginBarrel.ts'\nimport { generateRootBarrel } from './utils/generateRootBarrel.ts'\nimport { resolve } from 'node:path'\n\ndeclare global {\n namespace Kubb {\n interface PluginOptionsRegistry {\n output: {\n /**\n * Re-export style for this plugin's barrel file.\n * Set to `false` to disable barrel generation for this plugin entirely; doing so also\n * excludes the plugin's files from the root barrel.\n *\n * Falls back to `config.output.barrelType` when omitted.\n */\n barrelType?: BarrelType | false\n }\n }\n interface ConfigOptionsRegistry {\n output: {\n /**\n * Re-export style for the root barrel file at `config.output.path/index.ts`.\n * Set to `false` to disable root barrel generation. Individual plugins can override\n * this via their own `output.barrelType`.\n *\n * @default 'named'\n */\n barrelType?: BarrelType | false\n }\n }\n }\n}\n\n/**\n * Generates `index.ts` barrel files for each plugin's output directory and one root barrel\n * at `config.output.path/index.ts`.\n *\n * Plugins inherit `output.barrelType` from `config.output.barrelType` (which itself defaults to `'named'`).\n * Setting `barrelType: false` on a plugin disables its barrel and excludes the plugin's files from the\n * root barrel as well.\n *\n * @example\n * ```ts\n * import { defineConfig } from '@kubb/core'\n * import { middlewareBarrel } from '@kubb/middleware-barrel'\n *\n * export default defineConfig({\n * output: { path: 'src/gen', barrelType: 'named' },\n * plugins: [\n * pluginTs({ output: { path: 'types', barrelType: 'all' } }),\n * pluginZod({ output: { path: 'schemas' } }),\n * ],\n * middleware: [middlewareBarrel],\n * })\n * ```\n */\nexport const middlewareBarrel = defineMiddleware({\n name: 'middleware-barrel',\n install(hooks) {\n let ctx: KubbBuildStartContext\n const excludedPaths = new Set<string>()\n\n hooks.on('kubb:build:start', (buildCtx) => {\n ctx = buildCtx\n })\n\n hooks.on('kubb:plugin:end', ({ plugin }) => {\n if (!ctx) return\n\n const barrelType = plugin.options.output?.barrelType ?? ctx.config.output.barrelType ?? 'all'\n\n if (!barrelType) {\n excludedPaths.add(resolve(ctx.config.root, ctx.config.output.path, plugin.options.output.path))\n return\n }\n\n const barrelFiles = generatePerPluginBarrel({\n barrelType,\n plugin,\n files: ctx.files,\n config: ctx.config,\n })\n\n if (barrelFiles.length > 0) {\n ctx.upsertFile(...barrelFiles)\n }\n })\n\n hooks.on('kubb:plugins:end', ({ files, config, upsertFile }) => {\n const rootBarrelType = config.output.barrelType ?? 'named'\n if (!rootBarrelType) return\n\n const filteredFiles = excludedPaths.size > 0 ? files.filter((f) => ![...excludedPaths].some((excluded) => f.path.startsWith(excluded + '/'))) : files\n\n const rootBarrelFiles = generateRootBarrel({\n barrelType: rootBarrelType,\n files: filteredFiles,\n config,\n })\n\n if (rootBarrelFiles.length > 0) {\n upsertFile(...rootBarrelFiles)\n }\n })\n },\n})\n"],"mappings":";;;;;;;;;AAGA,MAAa,kBAAkB;;;;;;;;;;;;;;;A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W,IAAI,CAAC,CAAC,GAAG;IAK9I;IACD,CAAC;AAEF,OAAI,gBAAgB,SAAS,EAC3B,YAAW,GAAG,gBAAgB;IAEhC;;CAEL,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/constants.ts","../../../internals/utils/src/buildTree.ts","../src/utils/getBarrelFiles.ts","../src/utils/generatePerPluginBarrel.ts","../src/utils/generateRootBarrel.ts","../src/utils/excludedPaths.ts","../src/utils/resolveBarrelType.ts","../src/middleware.ts"],"sourcesContent":["/**\n * Full file name for barrel files (with extension).\n */\nexport const BARREL_FILENAME = 'index.ts' as const\n","/**\n * A node in the directory tree used to compute barrel file exports.\n * Either represents a directory (with `children`) or a file (`isFile: true`, empty `children`).\n */\nexport type BuildTree = {\n /**\n * Absolute filesystem path of this directory or file.\n */\n path: string\n /**\n * Sub-directories and files contained within this directory.\n * Always empty for file nodes.\n */\n children: Array<BuildTree>\n /**\n * `true` when this node represents a file (leaf), `false` for directory nodes.\n */\n isFile: boolean\n}\n\n/**\n * Builds a directory tree rooted at `rootPath` from a list of absolute file paths.\n * Paths outside `rootPath` are silently ignored. Children are sorted alphabetically\n * by path so consumers (barrel exports, propagated indexes) emit a deterministic order.\n *\n * Both POSIX (`/`) and Windows (`\\`) separators are accepted in input paths.\n *\n * @example\n * ```ts\n * buildTree('/src/gen/types', [\n * '/src/gen/types/pet.ts',\n * '/src/gen/types/pets/listPets.ts',\n * ])\n * ```\n */\nexport function buildTree(rootPath: string, filePaths: ReadonlyArray<string>): BuildTree {\n const root: BuildTree = { path: rootPath, children: [], isFile: false }\n // Per-directory child lookup avoids the O(N) `Array.find` scan during insertion.\n const childIndex = new Map<BuildTree, Map<string, BuildTree>>()\n childIndex.set(root, new Map())\n\n const normalizedRoot = rootPath.replaceAll('\\\\', '/')\n const rootPrefix = `${normalizedRoot}/`\n\n for (const filePath of filePaths) {\n const normalized = filePath.replaceAll('\\\\', '/')\n if (!normalized.startsWith(rootPrefix)) continue\n\n const parts = normalized.slice(rootPrefix.length).split('/')\n if (parts.length === 0) continue\n\n let current = root\n const lastIndex = parts.length - 1\n for (const [i, part] of parts.entries()) {\n if (!part) continue\n\n const isLast = i === lastIndex\n const siblings = childIndex.get(current)!\n let child = siblings.get(part)\n if (!child) {\n child = { path: `${current.path}/${part}`, children: [], isFile: isLast }\n current.children.push(child)\n siblings.set(part, child)\n if (!isLast) childIndex.set(child, new Map())\n }\n current = child\n }\n }\n\n sortTree(root)\n\n return root\n}\n\nfunction sortTree(node: BuildTree): void {\n if (node.children.length === 0) return\n node.children.sort(compareByPath)\n for (const child of node.children) {\n if (!child.isFile) sortTree(child)\n }\n}\n\nfunction compareByPath(a: BuildTree, b: BuildTree): number {\n return a.path < b.path ? -1 : a.path > b.path ? 1 : 0\n}\n","import { extname } from 'node:path'\nimport { createExport, createFile } from '@kubb/ast'\nimport type { ExportNode, FileNode, SourceNode } from '@kubb/ast'\nimport { BARREL_FILENAME } from '../constants.ts'\nimport type { BarrelType } from '../types.ts'\nimport { type BuildTree, buildTree } from '@internals/utils'\n\nconst SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx'])\nconst BARREL_SUFFIX = `/${BARREL_FILENAME}`\n\n/**\n * Derives a relative module specifier from `filePath` relative to `fromDir`.\n * The source extension is preserved so `@kubb/parser-ts` can apply its `extNames` mapping.\n *\n * @example\n * ```ts\n * toRelativeModulePath('/src/gen/types', '/src/gen/types/pet.ts') // './pet.ts'\n * toRelativeModulePath('/src/gen/types', '/src/gen/types/tags/tag.ts') // './tags/tag.ts'\n * ```\n */\nfunction toRelativeModulePath(fromDir: string, filePath: string): string {\n return `./${filePath.slice(fromDir.length + 1)}`\n}\n\nfunction isBarrelPath(path: string): boolean {\n return path.endsWith(BARREL_SUFFIX)\n}\n\nfunction makeBarrel(dirPath: string, exports: Array<ExportNode>): FileNode {\n return createFile({\n baseName: BARREL_FILENAME,\n path: `${dirPath}${BARREL_SUFFIX}`,\n exports,\n sources: [],\n imports: [],\n })\n}\n\ntype LeafContext = {\n dirPath: string\n leafPath: string\n sourceFile: FileNode | undefined\n}\n\ntype LeafStrategy = (ctx: LeafContext) => Array<ExportNode>\n\nfunction hasOnlyNonIndexableSources(sources: ReadonlyArray<SourceNode>): boolean {\n if (sources.length === 0) return false\n for (const source of sources) {\n if (source.isIndexable) return false\n }\n return true\n}\n\nfunction partitionIndexableNames(sources: ReadonlyArray<SourceNode>): Map<boolean, Set<string>> {\n const byTypeOnly = new Map<boolean, Set<string>>([\n [false, new Set()],\n [true, new Set()],\n ])\n for (const source of sources) {\n if (!source.isIndexable || !source.name) continue\n byTypeOnly.get(Boolean(source.isTypeOnly))!.add(source.name)\n }\n return byTypeOnly\n}\n\nconst allStrategy: LeafStrategy = ({ dirPath, leafPath, sourceFile }) => {\n if (sourceFile && hasOnlyNonIndexableSources(sourceFile.sources)) return []\n return [createExport({ path: toRelativeModulePath(dirPath, leafPath) })]\n}\n\nconst namedStrategy: LeafStrategy = ({ dirPath, leafPath, sourceFile }) => {\n const modulePath = toRelativeModulePath(dirPath, leafPath)\n\n if (!sourceFile) return [createExport({ path: modulePath })]\n\n const namesByTypeOnly = partitionIndexableNames(sourceFile.sources)\n const valueNames = namesByTypeOnly.get(false)!\n const typeNames = namesByTypeOnly.get(true)!\n\n if (valueNames.size === 0 && typeNames.size === 0) {\n if (sourceFile.sources.length > 0) return []\n return [createExport({ path: modulePath })]\n }\n\n const exports: Array<ExportNode> = []\n if (valueNames.size > 0) {\n exports.push(createExport({ name: [...valueNames].sort(), path: modulePath }))\n }\n if (typeNames.size > 0) {\n exports.push(createExport({ name: [...typeNames].sort(), path: modulePath, isTypeOnly: true }))\n }\n return exports\n}\n\nconst LEAF_STRATEGIES: ReadonlyMap<Exclude<BarrelType, 'propagate'>, LeafStrategy> = new Map([\n ['all', allStrategy],\n ['named', namedStrategy],\n])\n\ntype LeafWalkParams = {\n sourceFiles: ReadonlyMap<string, FileNode>\n strategy: LeafStrategy\n recursive: boolean\n}\n\n/**\n * Single-pass post-order traversal that emits a barrel for each visited directory and\n * returns its leaf paths so parents don't have to re-walk the subtree.\n */\nfunction walkAllOrNamed(node: BuildTree, params: LeafWalkParams, isRoot: boolean, out: Array<FileNode>): Array<string> {\n const subtreeLeaves: Array<string> = []\n\n for (const child of node.children) {\n if (child.isFile) {\n if (!isBarrelPath(child.path)) subtreeLeaves.push(child.path)\n continue\n }\n\n const childLeaves = walkAllOrNamed(child, params, false, out)\n for (const leaf of childLeaves) subtreeLeaves.push(leaf)\n }\n\n // Sub-directory barrels are only emitted when the caller asked for them.\n if (!isRoot && !params.recursive) return subtreeLeaves\n\n const exports = subtreeLeaves.flatMap((leafPath) => params.strategy({ dirPath: node.path, leafPath, sourceFile: params.sourceFiles.get(leafPath) }))\n\n if (exports.length > 0) {\n out.push(makeBarrel(node.path, exports))\n }\n\n return subtreeLeaves\n}\n\n/**\n * Emits one barrel per directory: every direct child file is re-exported and every\n * sub-directory is re-exported via its own barrel (recursive by design).\n */\nfunction walkPropagate(node: BuildTree, out: Array<FileNode>): void {\n const exports: Array<ExportNode> = []\n\n for (const child of node.children) {\n if (child.isFile) {\n if (isBarrelPath(child.path)) continue\n exports.push(createExport({ path: toRelativeModulePath(node.path, child.path) }))\n continue\n }\n\n walkPropagate(child, out)\n exports.push(createExport({ path: toRelativeModulePath(node.path, `${child.path}${BARREL_SUFFIX}`) }))\n }\n\n if (exports.length > 0) {\n out.push(makeBarrel(node.path, exports))\n }\n}\n\ntype IndexedFiles = {\n /**\n * `path → FileNode` lookup limited to files that participate in barrel generation.\n */\n sourceFiles: ReadonlyMap<string, FileNode>\n /**\n * Original (un-normalized) paths of `sourceFiles`, in input order — used as input for {@link buildTree}.\n */\n paths: ReadonlyArray<string>\n}\n\nfunction indexRelevantFiles(files: ReadonlyArray<FileNode>, outputPath: string): IndexedFiles {\n const outputPrefix = `${outputPath.replaceAll('\\\\', '/')}/`\n const sourceFiles = new Map<string, FileNode>()\n const paths: Array<string> = []\n\n for (const file of files) {\n const normalized = file.path.replaceAll('\\\\', '/')\n if (!normalized.startsWith(outputPrefix)) continue\n if (isBarrelPath(normalized)) continue\n if (!SOURCE_EXTENSIONS.has(extname(normalized))) continue\n\n sourceFiles.set(file.path, file)\n paths.push(file.path)\n }\n\n return { sourceFiles, paths }\n}\n\nexport type GetBarrelFilesParams = {\n /**\n * Absolute path to the directory the barrel(s) should be rooted at.\n * Files outside this directory are ignored.\n */\n outputPath: string\n /**\n * Full set of generated files across all plugins.\n * Used both to discover what to re-export and to read each file's indexable sources.\n */\n files: ReadonlyArray<FileNode>\n /**\n * Re-export style used in the generated barrel(s).\n */\n barrelType: BarrelType\n /**\n * When `true`, also generate a barrel for each sub-directory of `outputPath`.\n * Used by per-plugin barrels so that grouped output (e.g. `petController/`) gets its own `index.ts`.\n *\n * Has no effect for `barrelType: 'propagate'`, which always recurses by design.\n *\n * @default false\n */\n recursive?: boolean\n}\n\n/**\n * Generates barrel `FileNode`s for the directory rooted at `outputPath`.\n *\n * Files outside `outputPath`, existing barrel files, and non-source extensions are filtered out\n * before the tree is built.\n */\nexport function getBarrelFiles({ outputPath, files, barrelType, recursive = false }: GetBarrelFilesParams): Array<FileNode> {\n const { sourceFiles, paths } = indexRelevantFiles(files, outputPath)\n if (paths.length === 0) return []\n\n const tree = buildTree(outputPath, paths)\n const result: Array<FileNode> = []\n\n if (barrelType === 'propagate') {\n walkPropagate(tree, result)\n return result\n }\n\n const strategy = LEAF_STRATEGIES.get(barrelType)\n if (!strategy) return result\n\n walkAllOrNamed(tree, { sourceFiles, strategy, recursive }, true, result)\n return result\n}\n","import { resolve } from 'node:path'\nimport type { FileNode } from '@kubb/ast'\nimport type { Config, NormalizedPlugin } from '@kubb/core'\nimport type { BarrelType } from '../types.ts'\nimport { getBarrelFiles } from './getBarrelFiles.ts'\n\nexport type GeneratePerPluginBarrelParams = {\n /**\n * Re-export style used in the plugin's barrel file(s).\n */\n barrelType: BarrelType\n /**\n * Plugin whose `output.path` determines the barrel directory.\n */\n plugin: NormalizedPlugin\n /**\n * Full set of generated files across all plugins.\n * Files outside the plugin's output directory are filtered out automatically.\n */\n files: ReadonlyArray<FileNode>\n /**\n * Resolved Kubb config; used to compute the absolute output directory.\n */\n config: Config\n}\n\n/**\n * Generates barrel files for a single plugin's output directory.\n *\n * The barrel is placed at `<config.root>/<config.output.path>/<plugin.options.output.path>/index.ts`.\n * When the plugin uses `group`, additional sub-directory barrels are generated so that grouped\n * output (e.g. `petController/index.ts`) gets its own re-export entry point.\n */\nexport function generatePerPluginBarrel({ barrelType, plugin, files, config }: GeneratePerPluginBarrelParams): Array<FileNode> {\n const outputPath = resolve(config.root, config.output.path, plugin.options.output.path)\n\n return getBarrelFiles({ outputPath, files, barrelType, recursive: true })\n}\n","import { resolve } from 'node:path'\nimport type { FileNode } from '@kubb/ast'\nimport type { Config } from '@kubb/core'\nimport type { BarrelType } from '../types.ts'\nimport { getBarrelFiles } from './getBarrelFiles.ts'\n\nexport type GenerateRootBarrelParams = {\n /**\n * Re-export style used in the root barrel file.\n */\n barrelType: BarrelType\n /**\n * Files eligible for re-export. The middleware filters out files belonging to plugins\n * with `barrelType: false` before passing them in.\n */\n files: ReadonlyArray<FileNode>\n /**\n * Resolved Kubb config; used to compute the root output directory.\n */\n config: Config\n}\n\n/**\n * Generates the root barrel file at `<config.root>/<config.output.path>/index.ts`.\n *\n * Unlike `generatePerPluginBarrel`, this does not recurse into sub-directories — each\n * plugin is responsible for its own per-plugin barrels.\n */\nexport function generateRootBarrel({ barrelType, files, config }: GenerateRootBarrelParams): Array<FileNode> {\n const outputPath = resolve(config.root, config.output.path)\n\n return getBarrelFiles({ outputPath, files, barrelType })\n}\n","import { resolve } from 'node:path'\nimport type { Config, NormalizedPlugin } from '@kubb/core'\n\n/**\n * Returns the absolute output directory of `plugin` with a trailing separator,\n * suitable for prefix-based exclusion checks via {@link isExcludedPath}.\n *\n * The trailing `/` ensures `startsWith` does not match unrelated siblings\n * (e.g. `/foo/bar` vs `/foo/barbaz/x.ts`).\n */\nexport function getPluginOutputPrefix(plugin: NormalizedPlugin, config: Config): string {\n return `${resolve(config.root, config.output.path, plugin.options.output.path)}/`\n}\n\n/**\n * Returns `true` when `filePath` lies under any of the directory prefixes in `prefixes`.\n * Prefixes must already include a trailing separator (see {@link getPluginOutputPrefix}).\n *\n * Uses Node 22 iterator helpers (`Iterator.prototype.some`) to avoid materializing the set.\n */\nexport function isExcludedPath(filePath: string, prefixes: ReadonlySet<string>): boolean {\n return prefixes.values().some((prefix) => filePath.startsWith(prefix))\n}\n","import type { Config, NormalizedPlugin } from '@kubb/core'\nimport type { BarrelType } from '../types.ts'\n\nconst DEFAULT_BARREL_TYPE: BarrelType = 'named'\n\n/**\n * Resolves the effective barrel style for a single plugin: explicit plugin option →\n * root config option → `'named'` default. Returns `false` when barrel generation is disabled.\n */\nexport function resolvePluginBarrelType(plugin: NormalizedPlugin, config: Config): BarrelType | false {\n return plugin.options.output?.barrelType ?? config.output.barrelType ?? DEFAULT_BARREL_TYPE\n}\n\n/**\n * Resolves the effective barrel style for the root `index.ts`: root config option → `'named'` default.\n * Returns `false` when the root barrel is disabled.\n */\nexport function resolveRootBarrelType(config: Config): BarrelType | false {\n return config.output.barrelType ?? DEFAULT_BARREL_TYPE\n}\n","import { defineMiddleware } from '@kubb/core'\nimport type { KubbBuildStartContext } from '@kubb/core'\nimport type { BarrelType } from './types.ts'\nimport { generatePerPluginBarrel } from './utils/generatePerPluginBarrel.ts'\nimport { generateRootBarrel } from './utils/generateRootBarrel.ts'\nimport { getPluginOutputPrefix, isExcludedPath } from './utils/excludedPaths.ts'\nimport { resolvePluginBarrelType, resolveRootBarrelType } from './utils/resolveBarrelType.ts'\n\ndeclare global {\n namespace Kubb {\n interface PluginOptionsRegistry {\n output: {\n /**\n * Re-export style for this plugin's barrel file.\n * Set to `false` to disable barrel generation for this plugin entirely; doing so also\n * excludes the plugin's files from the root barrel.\n *\n * Falls back to `config.output.barrelType` when omitted.\n *\n * @default 'named'\n */\n barrelType?: BarrelType | false\n }\n }\n interface ConfigOptionsRegistry {\n output: {\n /**\n * Re-export style for the root barrel file at `config.output.path/index.ts`.\n * Set to `false` to disable root barrel generation. Individual plugins can override\n * this via their own `output.barrelType`.\n *\n * @default 'named'\n */\n barrelType?: BarrelType | false\n }\n }\n }\n}\n\n/**\n * Generates `index.ts` barrel files for each plugin's output directory and one root barrel\n * at `config.output.path/index.ts`.\n *\n * Plugins inherit `output.barrelType` from `config.output.barrelType` (which itself defaults to `'named'`).\n * Setting `barrelType: false` on a plugin disables its barrel and excludes the plugin's files from the\n * root barrel as well.\n *\n * @example\n * ```ts\n * import { defineConfig } from '@kubb/core'\n * import { middlewareBarrel } from '@kubb/middleware-barrel'\n *\n * export default defineConfig({\n * output: { path: 'src/gen', barrelType: 'named' },\n * plugins: [\n * pluginTs({ output: { path: 'types', barrelType: 'all' } }),\n * pluginZod({ output: { path: 'schemas' } }),\n * ],\n * middleware: [middlewareBarrel],\n * })\n * ```\n */\nexport const middlewareBarrel = defineMiddleware({\n name: 'middleware-barrel',\n install(hooks) {\n let ctx: KubbBuildStartContext | undefined\n const excludedPrefixes = new Set<string>()\n\n hooks.on('kubb:build:start', (buildCtx) => {\n ctx = buildCtx\n })\n\n hooks.on('kubb:plugin:end', ({ plugin }) => {\n if (!ctx) return\n\n const barrelType = resolvePluginBarrelType(plugin, ctx.config)\n\n if (!barrelType) {\n excludedPrefixes.add(getPluginOutputPrefix(plugin, ctx.config))\n return\n }\n\n const barrelFiles = generatePerPluginBarrel({\n barrelType,\n plugin,\n files: ctx.files,\n config: ctx.config,\n })\n\n if (barrelFiles.length > 0) {\n ctx.upsertFile(...barrelFiles)\n }\n })\n\n hooks.on('kubb:plugins:end', ({ files, config, upsertFile }) => {\n const rootBarrelType = resolveRootBarrelType(config)\n if (!rootBarrelType) return\n\n const filteredFiles = excludedPrefixes.size === 0 ? files : files.filter((f) => !isExcludedPath(f.path, excludedPrefixes))\n\n const rootBarrelFiles = generateRootBarrel({\n barrelType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A,GAAA,WAAA,kBAAoC;CAC/C,MAAM;CACN,QAAQ,OAAO;EACb,IAAI;EACJ,MAAM,mCAAmB,IAAI,KAAa;AAE1C,QAAM,GAAG,qBAAqB,aAAa;AACzC,SAAM;IACN;AAEF,QAAM,GAAG,oBAAoB,EAAE,aAAa;AAC1C,OAAI,CAAC,IAAK;GAEV,MAAM,aAAa,wBAAwB,QAAQ,IAAI,OAAO;AAE9D,OAAI,CAAC,YAAY;AACf,qBAAiB,IAAI,sBAAsB,QAAQ,IAAI,OAAO,CAAC;AAC/D;;GAGF,MAAM,cAAc,wBAAwB;IAC1C;IACA;IACA,OAAO,IAAI;IACX,QAAQ,IAAI;IACb,CAAC;AAEF,OAAI,YAAY,SAAS,EACvB,KAAI,WAAW,GAAG,YAAY;IAEhC;AAEF,QAAM,GAAG,qBAAqB,EAAE,OAAO,QAAQ,iBAAiB;GAC9D,MAAM,iBAAiB,sBAAsB,OAAO;AACpD,OAAI,CAAC,eAAgB;GAIrB,MAAM,kBAAkB,mBAAmB;IACzC,YAAY;IACZ,OAJoB,iBAAiB,SAAS,IAAI,QAAQ,MAAM,QAAQ,MAAM,CAAC,eAAe,EAAE,MAAM,iBAAiB,CAAC;IAKxH;IACD,CAAC;AAEF,OAAI,gBAAgB,SAAS,EAC3B,YAAW,GAAG,gBAAgB;IAEhC;;CAEL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ declare global {
22
22
  * excludes the plugin's files from the root barrel.
23
23
  *
24
24
  * Falls back to `config.output.barrelType` when omitted.
25
+ *
26
+ * @default 'named'
25
27
  */
26
28
  barrelType?: BarrelType | false;
27
29
  };