@kubb/core 4.38.1 → 4.39.1

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/hooks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { N as PluginManager, _ as PluginFactoryOptions, h as Plugin } from "./types-BwL2CHjl.js";
2
+ import { P as PluginManager, g as Plugin, v as PluginFactoryOptions } from "./types-DsJhzsHG.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/hooks/useMode.d.ts
package/dist/index.cjs CHANGED
@@ -1483,7 +1483,7 @@ const fsStorage = defineStorage(() => ({
1483
1483
  }));
1484
1484
  //#endregion
1485
1485
  //#region package.json
1486
- var version = "4.38.1";
1486
+ var version = "4.39.1";
1487
1487
  //#endregion
1488
1488
  //#region src/utils/diagnostics.ts
1489
1489
  /**
@@ -1499,6 +1499,25 @@ function getDiagnosticInfo() {
1499
1499
  };
1500
1500
  }
1501
1501
  //#endregion
1502
+ //#region src/utils/resolveBarrelType.ts
1503
+ /**
1504
+ * Resolve the effective barrel strategy from an output config.
1505
+ *
1506
+ * Prefers the object `barrel` option and falls back to the legacy `barrelType`.
1507
+ * `barrel: { nested: true }` maps to the legacy `'propagate'` value, and
1508
+ * `barrel: false` disables the barrel file.
1509
+ */
1510
+ function resolveBarrelType(output) {
1511
+ if (!output) return;
1512
+ const { barrel } = output;
1513
+ if (barrel !== void 0) {
1514
+ if (barrel === false) return false;
1515
+ if (barrel.nested) return "propagate";
1516
+ return barrel.type ?? "named";
1517
+ }
1518
+ return output.barrelType;
1519
+ }
1520
+ //#endregion
1502
1521
  //#region src/build.ts
1503
1522
  async function setup(options) {
1504
1523
  const { config: userConfig, events = new AsyncEventEmitter() } = options;
@@ -1594,7 +1613,7 @@ async function setup(options) {
1594
1613
  logs: [
1595
1614
  "✓ Fabric initialized",
1596
1615
  ` • Storage: ${storage ? storage.name : "disabled (dry-run)"}`,
1597
- ` • Barrel type: ${definedConfig.output.barrelType || "none"}`
1616
+ ` • Barrel type: ${resolveBarrelType(definedConfig.output) || "none"}`
1598
1617
  ]
1599
1618
  });
1600
1619
  const pluginManager = new PluginManager(definedConfig, {
@@ -1695,14 +1714,15 @@ async function safeBuild(options, overrides) {
1695
1714
  });
1696
1715
  }
1697
1716
  }
1698
- if (config.output.barrelType) {
1717
+ const rootBarrelType = resolveBarrelType(config.output);
1718
+ if (rootBarrelType) {
1699
1719
  const rootPath = (0, node_path.resolve)((0, node_path.resolve)(config.root), config.output.path, BARREL_FILENAME);
1700
1720
  const rootDir = (0, node_path.dirname)(rootPath);
1701
1721
  await events.emit("debug", {
1702
1722
  date: /* @__PURE__ */ new Date(),
1703
1723
  logs: [
1704
1724
  "Generating barrel file",
1705
- ` • Type: ${config.output.barrelType}`,
1725
+ ` • Type: ${rootBarrelType}`,
1706
1726
  ` • Path: ${rootPath}`
1707
1727
  ]
1708
1728
  });
@@ -1757,6 +1777,7 @@ async function safeBuild(options, overrides) {
1757
1777
  }
1758
1778
  }
1759
1779
  function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, pluginManager }) {
1780
+ const rootBarrelType = resolveBarrelType(config.output);
1760
1781
  const pluginKeyMap = /* @__PURE__ */ new Map();
1761
1782
  for (const plugin of pluginManager.plugins) pluginKeyMap.set(JSON.stringify(plugin.key), plugin);
1762
1783
  return barrelFiles.flatMap((file) => {
@@ -1765,13 +1786,13 @@ function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, plu
1765
1786
  if (!file.path || !source.isIndexable) return [];
1766
1787
  const meta = file.meta;
1767
1788
  const pluginOptions = (meta?.pluginKey ? pluginKeyMap.get(JSON.stringify(meta.pluginKey)) : void 0)?.options;
1768
- if (!pluginOptions || pluginOptions.output?.barrelType === false) return [];
1769
- const exportName = config.output.barrelType === "all" ? void 0 : source.name ? [source.name] : void 0;
1789
+ if (!pluginOptions || resolveBarrelType(pluginOptions.output) === false) return [];
1790
+ const exportName = rootBarrelType === "all" ? void 0 : source.name ? [source.name] : void 0;
1770
1791
  if (exportName?.some((n) => existingExports.has(n))) return [];
1771
1792
  return [{
1772
1793
  name: exportName,
1773
1794
  path: getRelativePath(rootDir, file.path),
1774
- isTypeOnly: config.output.barrelType === "all" ? containsOnlyTypes : source.isTypeOnly
1795
+ isTypeOnly: rootBarrelType === "all" ? containsOnlyTypes : source.isTypeOnly
1775
1796
  }];
1776
1797
  });
1777
1798
  });
@@ -2252,7 +2273,8 @@ function trimExtName(text) {
2252
2273
  return text;
2253
2274
  }
2254
2275
  async function getBarrelFiles(files, { type, meta = {}, root, output }) {
2255
- if (!type || type === "propagate") return [];
2276
+ const resolvedType = type ?? resolveBarrelType(output) ?? "named";
2277
+ if (!resolvedType || resolvedType === "propagate") return [];
2256
2278
  const barrelManager = new BarrelManager();
2257
2279
  const pathToBuildFrom = (0, node_path.join)(root, output.path);
2258
2280
  if (trimExtName(pathToBuildFrom).endsWith("index")) return [];
@@ -2261,7 +2283,7 @@ async function getBarrelFiles(files, { type, meta = {}, root, output }) {
2261
2283
  root: pathToBuildFrom,
2262
2284
  meta
2263
2285
  });
2264
- if (type === "all") return barrelFiles.map((file) => {
2286
+ if (resolvedType === "all") return barrelFiles.map((file) => {
2265
2287
  return {
2266
2288
  ...file,
2267
2289
  exports: file.exports?.map((exportItem) => {
@@ -2358,6 +2380,7 @@ exports.isInputPath = isInputPath;
2358
2380
  exports.linters = linters;
2359
2381
  exports.logLevel = logLevel;
2360
2382
  exports.memoryStorage = memoryStorage;
2383
+ exports.resolveBarrelType = resolveBarrelType;
2361
2384
  exports.safeBuild = safeBuild;
2362
2385
  exports.setup = setup;
2363
2386