unplugin-kubb 5.10.2 → 5.10.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/dist/astro.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/astro.d.ts
4
3
  declare const _default: (options: Options) => {
package/dist/esbuild.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/esbuild.d.ts
4
3
  declare const _default: (options?: Options | undefined) => import("esbuild").Plugin;
package/dist/farm.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/farm.d.ts
4
3
  declare const _default: (options?: Options | undefined) => import("@farmfe/core").JsPlugin;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options, applyDefaults, unpluginFactory } from "./unpluginFactory.js";
3
2
  //#region src/index.d.ts
4
3
  declare const plugin: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
package/dist/nuxt.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  import "@nuxt/schema";
4
3
  //#region src/nuxt.d.ts
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/rolldown.d.ts
4
3
  declare const _default: (options?: Options | undefined) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
package/dist/rollup.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/rollup.d.ts
4
3
  declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
package/dist/rspack.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/rspack.d.ts
4
3
  declare const _default: (options?: Options | undefined) => import("unplugin").RspackPluginInstance;
@@ -1,6 +1,5 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { UnpluginFactory } from "unplugin";
3
1
  import { UserConfig } from "@kubb/core";
2
+ import { UnpluginFactory } from "unplugin";
4
3
  //#region src/unpluginFactory.d.ts
5
4
  export type Options = {
6
5
  /**
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/vite.d.ts
4
3
  declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
package/dist/webpack.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Options } from "./unpluginFactory.js";
3
2
  //#region src/webpack.d.ts
4
3
  declare const _default: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-kubb",
3
- "version": "5.10.2",
3
+ "version": "5.10.4",
4
4
  "description": "Integration of Kubb for Vite, webpack, Rollup, Rolldown, Rspack, esbuild, Farm, Nuxt, and Astro.",
5
5
  "keywords": [
6
6
  "astro",
@@ -47,8 +47,7 @@
47
47
  ],
48
48
  "type": "module",
49
49
  "sideEffects": false,
50
- "main": "./dist/index.cjs",
51
- "module": "./dist/index.js",
50
+ "main": "./dist/index.js",
52
51
  "types": "./dist/index.d.ts",
53
52
  "typesVersions": {
54
53
  "*": {
@@ -61,53 +60,43 @@
61
60
  "exports": {
62
61
  ".": {
63
62
  "types": "./dist/index.d.ts",
64
- "import": "./dist/index.js",
65
- "require": "./dist/index.cjs"
63
+ "default": "./dist/index.js"
66
64
  },
67
65
  "./astro": {
68
66
  "types": "./dist/astro.d.ts",
69
- "import": "./dist/astro.js",
70
- "require": "./dist/astro.cjs"
67
+ "default": "./dist/astro.js"
71
68
  },
72
69
  "./esbuild": {
73
70
  "types": "./dist/esbuild.d.ts",
74
- "import": "./dist/esbuild.js",
75
- "require": "./dist/esbuild.cjs"
71
+ "default": "./dist/esbuild.js"
76
72
  },
77
73
  "./farm": {
78
74
  "types": "./dist/farm.d.ts",
79
- "import": "./dist/farm.js",
80
- "require": "./dist/farm.cjs"
75
+ "default": "./dist/farm.js"
81
76
  },
82
77
  "./nuxt": {
83
78
  "types": "./dist/nuxt.d.ts",
84
- "import": "./dist/nuxt.js",
85
- "require": "./dist/nuxt.cjs"
79
+ "default": "./dist/nuxt.js"
86
80
  },
87
81
  "./rolldown": {
88
82
  "types": "./dist/rolldown.d.ts",
89
- "import": "./dist/rolldown.js",
90
- "require": "./dist/rolldown.cjs"
83
+ "default": "./dist/rolldown.js"
91
84
  },
92
85
  "./rollup": {
93
86
  "types": "./dist/rollup.d.ts",
94
- "import": "./dist/rollup.js",
95
- "require": "./dist/rollup.cjs"
87
+ "default": "./dist/rollup.js"
96
88
  },
97
89
  "./rspack": {
98
90
  "types": "./dist/rspack.d.ts",
99
- "import": "./dist/rspack.js",
100
- "require": "./dist/rspack.cjs"
91
+ "default": "./dist/rspack.js"
101
92
  },
102
93
  "./vite": {
103
94
  "types": "./dist/vite.d.ts",
104
- "import": "./dist/vite.js",
105
- "require": "./dist/vite.cjs"
95
+ "default": "./dist/vite.js"
106
96
  },
107
97
  "./webpack": {
108
98
  "types": "./dist/webpack.d.ts",
109
- "import": "./dist/webpack.js",
110
- "require": "./dist/webpack.cjs"
99
+ "default": "./dist/webpack.js"
111
100
  },
112
101
  "./package.json": "./package.json"
113
102
  },
@@ -116,16 +105,16 @@
116
105
  "registry": "https://registry.npmjs.org/"
117
106
  },
118
107
  "dependencies": {
119
- "@kubb/adapter-oas": "5.10.2",
120
- "@kubb/core": "5.10.2",
121
- "@kubb/parser-md": "5.10.2",
122
- "@kubb/parser-ts": "5.10.2",
123
- "@kubb/plugin-barrel": "5.10.2",
108
+ "@kubb/adapter-oas": "5.10.4",
109
+ "@kubb/core": "5.10.4",
110
+ "@kubb/parser-md": "5.10.4",
111
+ "@kubb/parser-ts": "5.10.4",
112
+ "@kubb/plugin-barrel": "5.10.4",
124
113
  "unplugin": "^3.4.0"
125
114
  },
126
115
  "devDependencies": {
127
116
  "@farmfe/core": "^1.7.11",
128
- "@kubb/ast": "5.10.2",
117
+ "@kubb/ast": "5.10.4",
129
118
  "@nuxt/kit": "^4.6.1",
130
119
  "@nuxt/schema": "^4.6.1",
131
120
  "@rspack/core": "^2.2.8",
@@ -172,7 +161,7 @@
172
161
  }
173
162
  },
174
163
  "engines": {
175
- "node": ">=22"
164
+ "node": ">=22.12"
176
165
  },
177
166
  "scripts": {
178
167
  "build": "tsdown",
package/dist/astro.cjs DELETED
@@ -1,14 +0,0 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-ClG-MNz_.cjs");
2
- const require_vite = require("./vite.cjs");
3
- //#region src/astro.ts
4
- var astro_default = /* @__PURE__ */ require_rolldown_runtime.__name((options) => ({
5
- name: "unplugin-kubb",
6
- hooks: { "astro:config:setup": (astro) => {
7
- astro.config.vite.plugins ||= [];
8
- astro.config.vite.plugins.push(require_vite(options));
9
- } }
10
- }), "default");
11
- //#endregion
12
- module.exports = astro_default;
13
-
14
- //# sourceMappingURL=astro.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"astro.cjs","names":["vitePlugin"],"sources":["../src/astro.ts"],"sourcesContent":["import type { Options } from './unpluginFactory.ts'\nimport vitePlugin from './vite.ts'\n\nexport default (options: Options) => ({\n name: 'unplugin-kubb',\n hooks: {\n // Only the slice of Astro's `astro:config:setup` params the integration touches, so `astro` is not a dependency.\n 'astro:config:setup': (astro: { config: { vite: { plugins?: Array<unknown> } } }) => {\n astro.config.vite.plugins ||= []\n astro.config.vite.plugins.push(vitePlugin(options))\n },\n },\n})\n"],"mappings":";;;AAGA,IAAA,gBAAA,yCAAA,QAAgB,aAAsB;CACpC,MAAM;CACN,OAAO,EAEL,uBAAuB,UAA8D;EACnF,MAAM,OAAO,KAAK,YAAY,CAAC;EAC/B,MAAM,OAAO,KAAK,QAAQ,KAAKA,aAAW,OAAO,CAAC;CACpD,EACF;AACF,IAAA,SAAA"}
package/dist/esbuild.cjs DELETED
@@ -1,7 +0,0 @@
1
- const require_unpluginFactory = require("./unpluginFactory.cjs");
2
- //#region src/esbuild.ts
3
- var esbuild_default = (0, require("unplugin").createEsbuildPlugin)(require_unpluginFactory.unpluginFactory);
4
- //#endregion
5
- module.exports = esbuild_default;
6
-
7
- //# sourceMappingURL=esbuild.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"esbuild.cjs","names":["createEsbuildPlugin","unpluginFactory"],"sources":["../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createEsbuildPlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,mBAAA,qBAAeA,CAAAA,CAAAA,oBAAAA,CAAoBC,wBAAAA,eAAe"}
package/dist/farm.cjs DELETED
@@ -1,7 +0,0 @@
1
- const require_unpluginFactory = require("./unpluginFactory.cjs");
2
- //#region src/farm.ts
3
- var farm_default = (0, require("unplugin").createFarmPlugin)(require_unpluginFactory.unpluginFactory);
4
- //#endregion
5
- module.exports = farm_default;
6
-
7
- //# sourceMappingURL=farm.cjs.map
package/dist/farm.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"farm.cjs","names":["createFarmPlugin","unpluginFactory"],"sources":["../src/farm.ts"],"sourcesContent":["import { createFarmPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createFarmPlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,gBAAA,qBAAeA,CAAAA,CAAAA,iBAAAA,CAAiBC,wBAAAA,eAAe"}
package/dist/index.cjs DELETED
@@ -1,14 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_unpluginFactory = require("./unpluginFactory.cjs");
6
- //#region src/index.ts
7
- const plugin = /* #__PURE__ */ (0, require("unplugin").createUnplugin)(require_unpluginFactory.unpluginFactory);
8
- //#endregion
9
- exports.applyDefaults = require_unpluginFactory.applyDefaults;
10
- exports.default = plugin;
11
- exports.unplugin = plugin;
12
- exports.unpluginFactory = require_unpluginFactory.unpluginFactory;
13
-
14
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["unpluginFactory"],"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport { applyDefaults, type Options, unpluginFactory } from './unpluginFactory.ts'\n\nconst plugin = /* #__PURE__ */ createUnplugin(unpluginFactory)\n\nexport { plugin as unplugin, plugin as default }\n"],"mappings":";;;;;;AAKA,MAAM,SAAyB,iBAAA,qBAAA,CAAA,CAAA,eAAA,CAAeA,wBAAAA,eAAe"}
package/dist/nuxt.cjs DELETED
@@ -1,27 +0,0 @@
1
- require("./rolldown-runtime-ClG-MNz_.cjs");
2
- const require_vite = require("./vite.cjs");
3
- const require_rspack = require("./rspack.cjs");
4
- const require_webpack = require("./webpack.cjs");
5
- let _nuxt_kit = require("@nuxt/kit");
6
- require("@nuxt/schema");
7
- //#region src/nuxt.ts
8
- var nuxt_default = (0, _nuxt_kit.defineNuxtModule)({
9
- meta: {
10
- name: "nuxt-unplugin-kubb",
11
- configKey: "unpluginKubb"
12
- },
13
- defaults: void 0,
14
- setup(options, _nuxt) {
15
- const buildOptions = {
16
- dev: false,
17
- server: false
18
- };
19
- (0, _nuxt_kit.addVitePlugin)(() => require_vite(options), buildOptions);
20
- (0, _nuxt_kit.addWebpackPlugin)(() => require_webpack(options), buildOptions);
21
- (0, _nuxt_kit.addRspackPlugin)(() => require_rspack(options), buildOptions);
22
- }
23
- });
24
- //#endregion
25
- module.exports = nuxt_default;
26
-
27
- //# sourceMappingURL=nuxt.cjs.map
package/dist/nuxt.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"nuxt.cjs","names":["defineNuxtModule","vite","webpack","rspack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addRspackPlugin, addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport rspack from './rspack.ts'\nimport type { Options } from './unpluginFactory.ts'\nimport vite from './vite.ts'\nimport webpack from './webpack.ts'\n\nexport type ModuleOptions = Options\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: 'nuxt-unplugin-kubb',\n configKey: 'unpluginKubb',\n },\n defaults: undefined,\n setup(options, _nuxt) {\n // Nuxt builds the client before the server, so generating in the client build alone gives\n // the server build the files too. Skip the dev server, as the Vite integration does.\n const buildOptions = { dev: false, server: false }\n\n addVitePlugin(() => vite(options), buildOptions)\n addWebpackPlugin(() => webpack(options), buildOptions)\n addRspackPlugin(() => rspack(options), buildOptions)\n },\n})\n"],"mappings":";;;;;;;AAUA,IAAA,gBAAA,GAAeA,UAAAA,iBAAAA,CAAgC;CAC7C,MAAM;EACJ,MAAM;EACN,WAAW;CACb;CACA,UAAU,KAAA;CACV,MAAM,SAAS,OAAO;EAGpB,MAAM,eAAe;GAAE,KAAK;GAAO,QAAQ;EAAM;EAEjD,CAAA,GAAA,UAAA,cAAA,OAAoBC,aAAK,OAAO,GAAG,YAAY;EAC/C,CAAA,GAAA,UAAA,iBAAA,OAAuBC,gBAAQ,OAAO,GAAG,YAAY;EACrD,CAAA,GAAA,UAAA,gBAAA,OAAsBC,eAAO,OAAO,GAAG,YAAY;CACrD;AACF,CAAC"}
@@ -1,13 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
- //#endregion
8
- Object.defineProperty(exports, "__name", {
9
- enumerable: true,
10
- get: function() {
11
- return __name;
12
- }
13
- });
package/dist/rolldown.cjs DELETED
@@ -1,7 +0,0 @@
1
- const require_unpluginFactory = require("./unpluginFactory.cjs");
2
- //#region src/rolldown.ts
3
- var rolldown_default = (0, require("unplugin").createRolldownPlugin)(require_unpluginFactory.unpluginFactory);
4
- //#endregion
5
- module.exports = rolldown_default;
6
-
7
- //# sourceMappingURL=rolldown.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rolldown.cjs","names":["createRolldownPlugin","unpluginFactory"],"sources":["../src/rolldown.ts"],"sourcesContent":["import { createRolldownPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createRolldownPlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,oBAAA,qBAAeA,CAAAA,CAAAA,qBAAAA,CAAqBC,wBAAAA,eAAe"}
package/dist/rollup.cjs DELETED
@@ -1,7 +0,0 @@
1
- const require_unpluginFactory = require("./unpluginFactory.cjs");
2
- //#region src/rollup.ts
3
- var rollup_default = (0, require("unplugin").createRollupPlugin)(require_unpluginFactory.unpluginFactory);
4
- //#endregion
5
- module.exports = rollup_default;
6
-
7
- //# sourceMappingURL=rollup.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rollup.cjs","names":["createRollupPlugin","unpluginFactory"],"sources":["../src/rollup.ts"],"sourcesContent":["import { createRollupPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createRollupPlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,kBAAA,qBAAeA,CAAAA,CAAAA,mBAAAA,CAAmBC,wBAAAA,eAAe"}
package/dist/rspack.cjs DELETED
@@ -1,7 +0,0 @@
1
- const require_unpluginFactory = require("./unpluginFactory.cjs");
2
- //#region src/rspack.ts
3
- var rspack_default = (0, require("unplugin").createRspackPlugin)(require_unpluginFactory.unpluginFactory);
4
- //#endregion
5
- module.exports = rspack_default;
6
-
7
- //# sourceMappingURL=rspack.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rspack.cjs","names":["createRspackPlugin","unpluginFactory"],"sources":["../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createRspackPlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,kBAAA,qBAAeA,CAAAA,CAAAA,mBAAAA,CAAmBC,wBAAAA,eAAe"}
@@ -1,104 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./rolldown-runtime-ClG-MNz_.cjs");
3
- let _kubb_adapter_oas = require("@kubb/adapter-oas");
4
- let _kubb_core = require("@kubb/core");
5
- let _kubb_parser_md = require("@kubb/parser-md");
6
- let _kubb_parser_ts = require("@kubb/parser-ts");
7
- let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
8
- //#region src/unpluginFactory.ts
9
- /**
10
- * Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.
11
- *
12
- * - `root` defaults to `process.cwd()`
13
- * - `adapter` defaults to `adapterOas()`
14
- * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`
15
- * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`
16
- * - `plugins` gets `pluginBarrel()` appended when none is already present
17
- * - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)
18
- * - `output.format` and `output.lint` default to `false`
19
- */
20
- function applyDefaults(config) {
21
- const plugins = config.plugins ?? [];
22
- return {
23
- ...config,
24
- root: config.root || process.cwd(),
25
- adapter: config.adapter ?? (0, _kubb_adapter_oas.adapterOas)(),
26
- parsers: config.parsers?.length ? config.parsers : [
27
- (0, _kubb_parser_ts.parserTs)(),
28
- (0, _kubb_parser_ts.parserTsx)(),
29
- (0, _kubb_parser_md.parserMd)()
30
- ],
31
- reporters: config.reporters?.length ? config.reporters : [
32
- _kubb_core.cliReporter,
33
- _kubb_core.jsonReporter,
34
- _kubb_core.fileReporter,
35
- _kubb_core.htmlReporter
36
- ],
37
- plugins: plugins.some((plugin) => plugin.name === _kubb_plugin_barrel.pluginBarrelName) ? plugins : [...plugins, (0, _kubb_plugin_barrel.pluginBarrel)()],
38
- output: {
39
- barrel: false,
40
- format: false,
41
- lint: false,
42
- ...config.output
43
- }
44
- };
45
- }
46
- /**
47
- * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
48
- *
49
- * Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the
50
- * config and prints the same summary `kubb generate` does. Under Vite it only applies during
51
- * `build`. A missing config or a failed generation fails the host build.
52
- */
53
- const unpluginFactory = (options, meta) => {
54
- const name = "unplugin-kubb";
55
- const hooks = new _kubb_core.Hookable();
56
- const reporter = (0, _kubb_core.createCliReporter)();
57
- hooks.hook("kubb:generation:end", ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => reporter.report({
58
- config,
59
- diagnostics,
60
- filesCreated,
61
- status,
62
- hrStart
63
- }, { logLevel: _kubb_core.logLevel.info }));
64
- async function runBuild() {
65
- if (!options?.config) throw new _kubb_core.Diagnostics.Error({
66
- code: _kubb_core.Diagnostics.code.inputRequired,
67
- severity: "error",
68
- message: `[${name}] Config is not set`,
69
- help: "Pass your Kubb config as the `config` option of the plugin.",
70
- location: { kind: "config" }
71
- });
72
- const result = await (0, _kubb_core.createKubb)(applyDefaults(options.config), { hooks }).generate();
73
- if (!result.success) {
74
- const failedCount = _kubb_core.Diagnostics.failedPlugins(result.diagnostics).length;
75
- const firstError = result.diagnostics.filter(_kubb_core.Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
76
- const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
77
- throw new _kubb_core.Diagnostics.Error({
78
- ...firstError ?? {
79
- code: _kubb_core.Diagnostics.code.unknown,
80
- severity: "error"
81
- },
82
- message: `[${name}] ${message}`
83
- });
84
- }
85
- }
86
- let generation;
87
- return {
88
- name,
89
- enforce: "pre",
90
- apply: meta.framework === "vite" ? "build" : void 0,
91
- async buildStart() {
92
- generation ??= runBuild().catch((error) => {
93
- generation = void 0;
94
- throw error;
95
- });
96
- await generation;
97
- }
98
- };
99
- };
100
- //#endregion
101
- exports.applyDefaults = applyDefaults;
102
- exports.unpluginFactory = unpluginFactory;
103
-
104
- //# sourceMappingURL=unpluginFactory.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unpluginFactory.cjs","names":["adapterOas","parserTs","parserTsx","parserMd","cliReporter","jsonReporter","fileReporter","htmlReporter","pluginBarrelName","pluginBarrel","Hookable","createCliReporter","logLevel","Diagnostics","createKubb"],"sources":["../src/unpluginFactory.ts"],"sourcesContent":["import { adapterOas } from '@kubb/adapter-oas'\nimport {\n cliReporter,\n type Config,\n createCliReporter,\n createKubb,\n Diagnostics,\n fileReporter,\n Hookable,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel,\n type UserConfig,\n} from '@kubb/core'\nimport { parserMd } from '@kubb/parser-md'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport type { UnpluginFactory } from 'unplugin'\n\nexport type Options = {\n /**\n * Kubb config passed to the unplugin entry point.\n */\n config?: UserConfig\n}\n\n/**\n * Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.\n *\n * - `root` defaults to `process.cwd()`\n * - `adapter` defaults to `adapterOas()`\n * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`\n * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`\n * - `plugins` gets `pluginBarrel()` appended when none is already present\n * - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)\n * - `output.format` and `output.lint` default to `false`\n */\nexport function applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {\n const plugins = config.plugins ?? []\n\n return {\n ...config,\n root: config.root || process.cwd(),\n adapter: config.adapter ?? adapterOas(),\n parsers: config.parsers?.length ? config.parsers : [parserTs(), parserTsx(), parserMd()],\n reporters: config.reporters?.length ? config.reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter],\n plugins: plugins.some((plugin) => plugin.name === pluginBarrelName) ? plugins : [...plugins, pluginBarrel()],\n output: { barrel: false, format: false, lint: false, ...config.output },\n }\n}\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the\n * config and prints the same summary `kubb generate` does. Under Vite it only applies during\n * `build`. A missing config or a failed generation fails the host build.\n */\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const hooks = new Hookable<KubbHooks>()\n const reporter = createCliReporter()\n\n hooks.hook('kubb:generation:end', ({ config, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) =>\n reporter.report({ config, diagnostics, filesCreated, status, hrStart }, { logLevel: logLevel.info }),\n )\n\n // Throw: webpack, Rspack, esbuild, and Farm contexts have no `this.error`.\n async function runBuild() {\n if (!options?.config) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.inputRequired,\n severity: 'error',\n message: `[${name}] Config is not set`,\n help: 'Pass your Kubb config as the `config` option of the plugin.',\n location: { kind: 'config' },\n })\n }\n\n const kubb = createKubb(applyDefaults(options.config) as Config, { hooks })\n const result = await kubb.generate()\n\n if (!result.success) {\n const failedCount = Diagnostics.failedPlugins(result.diagnostics).length\n const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === 'error')\n const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : (firstError?.message ?? 'Build failed')\n\n // Keep the first error's code, help, and location, so the bundler shows the same diagnostic.\n throw new Diagnostics.Error({\n ...(firstError ?? { code: Diagnostics.code.unknown, severity: 'error' }),\n message: `[${name}] ${message}`,\n })\n }\n }\n\n // A rerun with `output.clean` loops webpack and Rspack watchers, so generate once per instance.\n let generation: Promise<void> | undefined\n\n return {\n name,\n enforce: 'pre',\n apply: meta.framework === 'vite' ? 'build' : undefined,\n async buildStart() {\n generation ??= runBuild().catch((error: unknown) => {\n generation = undefined\n throw error\n })\n await generation\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,cAAsB,QAAgD;CACpF,MAAM,UAAU,OAAO,WAAW,CAAC;CAEnC,OAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ,QAAQ,IAAI;EACjC,SAAS,OAAO,YAAA,GAAWA,kBAAAA,WAAAA,CAAW;EACtC,SAAS,OAAO,SAAS,SAAS,OAAO,UAAU;IAACC,GAAAA,gBAAAA,SAAAA,CAAS;IAAGC,GAAAA,gBAAAA,UAAAA,CAAU;IAAGC,GAAAA,gBAAAA,SAAAA,CAAS;EAAC;EACvF,WAAW,OAAO,WAAW,SAAS,OAAO,YAAY;GAACC,WAAAA;GAAaC,WAAAA;GAAcC,WAAAA;GAAcC,WAAAA;EAAY;EAC/G,SAAS,QAAQ,MAAM,WAAW,OAAO,SAASC,oBAAAA,gBAAgB,IAAI,UAAU,CAAC,GAAG,UAAA,GAASC,oBAAAA,aAAAA,CAAa,CAAC;EAC3G,QAAQ;GAAE,QAAQ;GAAO,QAAQ;GAAO,MAAM;GAAO,GAAG,OAAO;EAAO;CACxE;AACF;;;;;;;;AASA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAIC,WAAAA,SAAoB;CACtC,MAAM,YAAA,GAAWC,WAAAA,kBAAAA,CAAkB;CAEnC,MAAM,KAAK,wBAAwB,EAAE,QAAQ,cAAc,CAAC,GAAG,eAAe,GAAG,SAAS,WAAW,UAAU,QAAQ,OAAO,QAC5H,SAAS,OAAO;EAAE;EAAQ;EAAa;EAAc;EAAQ;CAAQ,GAAG,EAAE,UAAUC,WAAAA,SAAS,KAAK,CAAC,CACrG;CAGA,eAAe,WAAW;EACxB,IAAI,CAAC,SAAS,QACZ,MAAM,IAAIC,WAAAA,YAAY,MAAM;GAC1B,MAAMA,WAAAA,YAAY,KAAK;GACvB,UAAU;GACV,SAAS,IAAI,KAAK;GAClB,MAAM;GACN,UAAU,EAAE,MAAM,SAAS;EAC7B,CAAC;EAIH,MAAM,SAAS,OAAA,GADFC,WAAAA,WAAAA,CAAW,cAAc,QAAQ,MAAM,GAAa,EAAE,MAAM,CACjD,CAAC,CAAC,SAAS;EAEnC,IAAI,CAAC,OAAO,SAAS;GACnB,MAAM,cAAcD,WAAAA,YAAY,cAAc,OAAO,WAAW,CAAC,CAAC;GAClE,MAAM,aAAa,OAAO,YAAY,OAAOA,WAAAA,YAAY,SAAS,CAAC,CAAC,MAAM,eAAe,WAAW,aAAa,OAAO;GACxH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAG7G,MAAM,IAAIA,WAAAA,YAAY,MAAM;IAC1B,GAAI,cAAc;KAAE,MAAMA,WAAAA,YAAY,KAAK;KAAS,UAAU;IAAQ;IACtE,SAAS,IAAI,KAAK,IAAI;GACxB,CAAC;EACH;CACF;CAGA,IAAI;CAEJ,OAAO;EACL;EACA,SAAS;EACT,OAAO,KAAK,cAAc,SAAS,UAAU,KAAA;EAC7C,MAAM,aAAa;GACjB,eAAe,SAAS,CAAC,CAAC,OAAO,UAAmB;IAClD,aAAa,KAAA;IACb,MAAM;GACR,CAAC;GACD,MAAM;EACR;CACF;AACF"}
package/dist/vite.cjs DELETED
@@ -1,7 +0,0 @@
1
- const require_unpluginFactory = require("./unpluginFactory.cjs");
2
- //#region src/vite.ts
3
- var vite_default = (0, require("unplugin").createVitePlugin)(require_unpluginFactory.unpluginFactory);
4
- //#endregion
5
- module.exports = vite_default;
6
-
7
- //# sourceMappingURL=vite.cjs.map
package/dist/vite.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.cjs","names":["createVitePlugin","unpluginFactory"],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createVitePlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,gBAAA,qBAAeA,CAAAA,CAAAA,iBAAAA,CAAiBC,wBAAAA,eAAe"}
package/dist/webpack.cjs DELETED
@@ -1,7 +0,0 @@
1
- const require_unpluginFactory = require("./unpluginFactory.cjs");
2
- //#region src/webpack.ts
3
- var webpack_default = (0, require("unplugin").createWebpackPlugin)(require_unpluginFactory.unpluginFactory);
4
- //#endregion
5
- module.exports = webpack_default;
6
-
7
- //# sourceMappingURL=webpack.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack.cjs","names":["createWebpackPlugin","unpluginFactory"],"sources":["../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createWebpackPlugin(unpluginFactory)\n"],"mappings":";;AAGA,IAAA,mBAAA,qBAAeA,CAAAA,CAAAA,oBAAAA,CAAoBC,wBAAAA,eAAe"}