unplugin-kubb 5.10.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-kubb",
3
- "version": "5.10.3",
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
  "*": {
@@ -60,104 +59,44 @@
60
59
  },
61
60
  "exports": {
62
61
  ".": {
63
- "import": {
64
- "types": "./dist/index.d.ts",
65
- "default": "./dist/index.js"
66
- },
67
- "require": {
68
- "types": "./dist/index.d.cts",
69
- "default": "./dist/index.cjs"
70
- }
62
+ "types": "./dist/index.d.ts",
63
+ "default": "./dist/index.js"
71
64
  },
72
65
  "./astro": {
73
- "import": {
74
- "types": "./dist/astro.d.ts",
75
- "default": "./dist/astro.js"
76
- },
77
- "require": {
78
- "types": "./dist/astro.d.cts",
79
- "default": "./dist/astro.cjs"
80
- }
66
+ "types": "./dist/astro.d.ts",
67
+ "default": "./dist/astro.js"
81
68
  },
82
69
  "./esbuild": {
83
- "import": {
84
- "types": "./dist/esbuild.d.ts",
85
- "default": "./dist/esbuild.js"
86
- },
87
- "require": {
88
- "types": "./dist/esbuild.d.cts",
89
- "default": "./dist/esbuild.cjs"
90
- }
70
+ "types": "./dist/esbuild.d.ts",
71
+ "default": "./dist/esbuild.js"
91
72
  },
92
73
  "./farm": {
93
- "import": {
94
- "types": "./dist/farm.d.ts",
95
- "default": "./dist/farm.js"
96
- },
97
- "require": {
98
- "types": "./dist/farm.d.cts",
99
- "default": "./dist/farm.cjs"
100
- }
74
+ "types": "./dist/farm.d.ts",
75
+ "default": "./dist/farm.js"
101
76
  },
102
77
  "./nuxt": {
103
- "import": {
104
- "types": "./dist/nuxt.d.ts",
105
- "default": "./dist/nuxt.js"
106
- },
107
- "require": {
108
- "types": "./dist/nuxt.d.cts",
109
- "default": "./dist/nuxt.cjs"
110
- }
78
+ "types": "./dist/nuxt.d.ts",
79
+ "default": "./dist/nuxt.js"
111
80
  },
112
81
  "./rolldown": {
113
- "import": {
114
- "types": "./dist/rolldown.d.ts",
115
- "default": "./dist/rolldown.js"
116
- },
117
- "require": {
118
- "types": "./dist/rolldown.d.cts",
119
- "default": "./dist/rolldown.cjs"
120
- }
82
+ "types": "./dist/rolldown.d.ts",
83
+ "default": "./dist/rolldown.js"
121
84
  },
122
85
  "./rollup": {
123
- "import": {
124
- "types": "./dist/rollup.d.ts",
125
- "default": "./dist/rollup.js"
126
- },
127
- "require": {
128
- "types": "./dist/rollup.d.cts",
129
- "default": "./dist/rollup.cjs"
130
- }
86
+ "types": "./dist/rollup.d.ts",
87
+ "default": "./dist/rollup.js"
131
88
  },
132
89
  "./rspack": {
133
- "import": {
134
- "types": "./dist/rspack.d.ts",
135
- "default": "./dist/rspack.js"
136
- },
137
- "require": {
138
- "types": "./dist/rspack.d.cts",
139
- "default": "./dist/rspack.cjs"
140
- }
90
+ "types": "./dist/rspack.d.ts",
91
+ "default": "./dist/rspack.js"
141
92
  },
142
93
  "./vite": {
143
- "import": {
144
- "types": "./dist/vite.d.ts",
145
- "default": "./dist/vite.js"
146
- },
147
- "require": {
148
- "types": "./dist/vite.d.cts",
149
- "default": "./dist/vite.cjs"
150
- }
94
+ "types": "./dist/vite.d.ts",
95
+ "default": "./dist/vite.js"
151
96
  },
152
97
  "./webpack": {
153
- "import": {
154
- "types": "./dist/webpack.d.ts",
155
- "default": "./dist/webpack.js"
156
- },
157
- "require": {
158
- "types": "./dist/webpack.d.cts",
159
- "default": "./dist/webpack.cjs"
160
- }
98
+ "types": "./dist/webpack.d.ts",
99
+ "default": "./dist/webpack.js"
161
100
  },
162
101
  "./package.json": "./package.json"
163
102
  },
@@ -166,16 +105,16 @@
166
105
  "registry": "https://registry.npmjs.org/"
167
106
  },
168
107
  "dependencies": {
169
- "@kubb/adapter-oas": "5.10.3",
170
- "@kubb/core": "5.10.3",
171
- "@kubb/parser-md": "5.10.3",
172
- "@kubb/parser-ts": "5.10.3",
173
- "@kubb/plugin-barrel": "5.10.3",
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",
174
113
  "unplugin": "^3.4.0"
175
114
  },
176
115
  "devDependencies": {
177
116
  "@farmfe/core": "^1.7.11",
178
- "@kubb/ast": "5.10.3",
117
+ "@kubb/ast": "5.10.4",
179
118
  "@nuxt/kit": "^4.6.1",
180
119
  "@nuxt/schema": "^4.6.1",
181
120
  "@rspack/core": "^2.2.8",
@@ -222,7 +161,7 @@
222
161
  }
223
162
  },
224
163
  "engines": {
225
- "node": ">=22"
164
+ "node": ">=22.12"
226
165
  },
227
166
  "scripts": {
228
167
  "build": "tsdown",
package/dist/astro.cjs DELETED
@@ -1,19 +0,0 @@
1
- const require_vite = require("./vite.cjs");
2
- //#region src/astro.ts
3
- var astro_default = (options) => ({
4
- name: "unplugin-kubb",
5
- hooks: { "astro:config:setup": (astro) => {
6
- astro.config.vite.plugins ||= [];
7
- astro.config.vite.plugins.push(require_vite(options));
8
- } }
9
- });
10
- //#endregion
11
- module.exports = astro_default;
12
-
13
- //# sourceMappingURL=astro.cjs.maplugins.push(require_vite(options));
14
- } }
15
- }), "default");
16
- //#endregion
17
- module.exports = astro_default;
18
-
19
- //# 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,iBAAgB,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"}
package/dist/astro.d.cts DELETED
@@ -1,16 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/astro.d.ts
3
- declare const _default: (options: Options) => {
4
- name: string;
5
- hooks: {
6
- 'astro:config:setup': (astro: {
7
- config: {
8
- vite: {
9
- plugins?: Array<unknown>;
10
- };
11
- };
12
- }) => void;
13
- };
14
- };
15
- export = _default;
16
- //# sourceMappingURL=astro.d.cts.map
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"}
@@ -1,5 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/esbuild.d.ts
3
- declare const _default: (options?: Options | undefined) => import("esbuild").Plugin;
4
- export = _default;
5
- //# sourceMappingURL=esbuild.d.cts.map
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/farm.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/farm.d.ts
3
- declare const _default: (options?: Options | undefined) => import("@farmfe/core").JsPlugin;
4
- export = _default;
5
- //# sourceMappingURL=farm.d.cts.map
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/index.d.cts DELETED
@@ -1,6 +0,0 @@
1
- import { Options, applyDefaults, unpluginFactory } from "./unpluginFactory.cjs";
2
- //#region src/index.d.ts
3
- declare const plugin: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
4
- //#endregion
5
- export { type Options, applyDefaults, plugin as default, plugin as unplugin, unpluginFactory };
6
- //# sourceMappingURL=index.d.cts.map
package/dist/nuxt.cjs DELETED
@@ -1,26 +0,0 @@
1
- const require_vite = require("./vite.cjs");
2
- const require_rspack = require("./rspack.cjs");
3
- const require_webpack = require("./webpack.cjs");
4
- let _nuxt_kit = require("@nuxt/kit");
5
- require("@nuxt/schema");
6
- //#region src/nuxt.ts
7
- var nuxt_default = (0, _nuxt_kit.defineNuxtModule)({
8
- meta: {
9
- name: "nuxt-unplugin-kubb",
10
- configKey: "unpluginKubb"
11
- },
12
- defaults: void 0,
13
- setup(options, _nuxt) {
14
- const buildOptions = {
15
- dev: false,
16
- server: false
17
- };
18
- (0, _nuxt_kit.addVitePlugin)(() => require_vite(options), buildOptions);
19
- (0, _nuxt_kit.addWebpackPlugin)(() => require_webpack(options), buildOptions);
20
- (0, _nuxt_kit.addRspackPlugin)(() => require_rspack(options), buildOptions);
21
- }
22
- });
23
- //#endregion
24
- module.exports = nuxt_default;
25
-
26
- //# 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"}
package/dist/nuxt.d.cts DELETED
@@ -1,8 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- import "@nuxt/schema";
3
- //#region src/nuxt.d.ts
4
- export type ModuleOptions = Options;
5
- declare const _default: import("@nuxt/schema").NuxtModule<Options, Options, false>;
6
- //#endregion
7
- export { _default as default };
8
- //# sourceMappingURL=nuxt.d.cts.map
@@ -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"}
@@ -1,5 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/rolldown.d.ts
3
- declare const _default: (options?: Options | undefined) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
4
- export = _default;
5
- //# sourceMappingURL=rolldown.d.cts.map
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/rollup.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/rollup.d.ts
3
- declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
4
- export = _default;
5
- //# sourceMappingURL=rollup.d.cts.map
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"}
package/dist/rspack.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/rspack.d.ts
3
- declare const _default: (options?: Options | undefined) => import("unplugin").RspackPluginInstance;
4
- export = _default;
5
- //# sourceMappingURL=rspack.d.cts.map
@@ -1,103 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let _kubb_adapter_oas = require("@kubb/adapter-oas");
3
- let _kubb_core = require("@kubb/core");
4
- let _kubb_parser_md = require("@kubb/parser-md");
5
- let _kubb_parser_ts = require("@kubb/parser-ts");
6
- let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
7
- //#region src/unpluginFactory.ts
8
- /**
9
- * Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.
10
- *
11
- * - `root` defaults to `process.cwd()`
12
- * - `adapter` defaults to `adapterOas()`
13
- * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`
14
- * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`
15
- * - `plugins` gets `pluginBarrel()` appended when none is already present
16
- * - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)
17
- * - `output.format` and `output.lint` default to `false`
18
- */
19
- function applyDefaults(config) {
20
- const plugins = config.plugins ?? [];
21
- return {
22
- ...config,
23
- root: config.root || process.cwd(),
24
- adapter: config.adapter ?? (0, _kubb_adapter_oas.adapterOas)(),
25
- parsers: config.parsers?.length ? config.parsers : [
26
- (0, _kubb_parser_ts.parserTs)(),
27
- (0, _kubb_parser_ts.parserTsx)(),
28
- (0, _kubb_parser_md.parserMd)()
29
- ],
30
- reporters: config.reporters?.length ? config.reporters : [
31
- _kubb_core.cliReporter,
32
- _kubb_core.jsonReporter,
33
- _kubb_core.fileReporter,
34
- _kubb_core.htmlReporter
35
- ],
36
- plugins: plugins.some((plugin) => plugin.name === _kubb_plugin_barrel.pluginBarrelName) ? plugins : [...plugins, (0, _kubb_plugin_barrel.pluginBarrel)()],
37
- output: {
38
- barrel: false,
39
- format: false,
40
- lint: false,
41
- ...config.output
42
- }
43
- };
44
- }
45
- /**
46
- * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
47
- *
48
- * Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the
49
- * config and prints the same summary `kubb generate` does. Under Vite it only applies during
50
- * `build`. A missing config or a failed generation fails the host build.
51
- */
52
- const unpluginFactory = (options, meta) => {
53
- const name = "unplugin-kubb";
54
- const hooks = new _kubb_core.Hookable();
55
- const reporter = (0, _kubb_core.createCliReporter)();
56
- hooks.hook("kubb:generation:end", ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => reporter.report({
57
- config,
58
- diagnostics,
59
- filesCreated,
60
- status,
61
- hrStart
62
- }, { logLevel: _kubb_core.logLevel.info }));
63
- async function runBuild() {
64
- if (!options?.config) throw new _kubb_core.Diagnostics.Error({
65
- code: _kubb_core.Diagnostics.code.inputRequired,
66
- severity: "error",
67
- message: `[${name}] Config is not set`,
68
- help: "Pass your Kubb config as the `config` option of the plugin.",
69
- location: { kind: "config" }
70
- });
71
- const result = await (0, _kubb_core.createKubb)(applyDefaults(options.config), { hooks }).generate();
72
- if (!result.success) {
73
- const failedCount = _kubb_core.Diagnostics.failedPlugins(result.diagnostics).length;
74
- const firstError = result.diagnostics.filter(_kubb_core.Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
75
- const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
76
- throw new _kubb_core.Diagnostics.Error({
77
- ...firstError ?? {
78
- code: _kubb_core.Diagnostics.code.unknown,
79
- severity: "error"
80
- },
81
- message: `[${name}] ${message}`
82
- });
83
- }
84
- }
85
- let generation;
86
- return {
87
- name,
88
- enforce: "pre",
89
- apply: meta.framework === "vite" ? "build" : void 0,
90
- async buildStart() {
91
- generation ??= runBuild().catch((error) => {
92
- generation = void 0;
93
- throw error;
94
- });
95
- await generation;
96
- }
97
- };
98
- };
99
- //#endregion
100
- exports.applyDefaults = applyDefaults;
101
- exports.unpluginFactory = unpluginFactory;
102
-
103
- //# 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"}
@@ -1,31 +0,0 @@
1
- import { UserConfig } from "@kubb/core";
2
- import { UnpluginFactory } from "unplugin";
3
- //#region src/unpluginFactory.d.ts
4
- export type Options = {
5
- /**
6
- * Kubb config passed to the unplugin entry point.
7
- */
8
- config?: UserConfig;
9
- };
10
- /**
11
- * Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.
12
- *
13
- * - `root` defaults to `process.cwd()`
14
- * - `adapter` defaults to `adapterOas()`
15
- * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`
16
- * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`
17
- * - `plugins` gets `pluginBarrel()` appended when none is already present
18
- * - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)
19
- * - `output.format` and `output.lint` default to `false`
20
- */
21
- export declare function applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput>;
22
- /**
23
- * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
24
- *
25
- * Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the
26
- * config and prints the same summary `kubb generate` does. Under Vite it only applies during
27
- * `build`. A missing config or a failed generation fails the host build.
28
- */
29
- export declare const unpluginFactory: UnpluginFactory<Options | undefined>;
30
- //#endregion
31
- //# sourceMappingURL=unpluginFactory.d.cts.map
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/vite.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/vite.d.ts
3
- declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
4
- export = _default;
5
- //# sourceMappingURL=vite.d.cts.map
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"}
@@ -1,5 +0,0 @@
1
- import { Options } from "./unpluginFactory.cjs";
2
- //#region src/webpack.d.ts
3
- declare const _default: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
4
- export = _default;
5
- //# sourceMappingURL=webpack.d.cts.map