unplugin-kubb 5.8.4 → 5.9.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/README.md +53 -12
- package/dist/astro.cjs +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +9 -3
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.js +9 -3
- package/dist/nuxt.js.map +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{unpluginFactory-vl_Yrcf4.cjs → unpluginFactory-BKFFFN9W.cjs} +19 -19
- package/dist/unpluginFactory-BKFFFN9W.cjs.map +1 -0
- package/dist/{unpluginFactory-Cdw7v8K3.js → unpluginFactory-BMmC0zzB.js} +19 -19
- package/dist/unpluginFactory-BMmC0zzB.js.map +1 -0
- package/dist/unpluginFactory.cjs +1 -1
- package/dist/unpluginFactory.d.ts +3 -2
- package/dist/unpluginFactory.js +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +10 -9
- package/dist/unpluginFactory-Cdw7v8K3.js.map +0 -1
- package/dist/unpluginFactory-vl_Yrcf4.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
|
|
25
25
|
### Universal build integration for Kubb
|
|
26
26
|
|
|
27
|
-
Integration of Kubb for Vite,
|
|
27
|
+
Integration of Kubb for Vite, webpack, Rollup, Rolldown, Rspack, esbuild, Farm, Nuxt, and Astro powered by [unplugin](https://github.com/unjs/unplugin).
|
|
28
|
+
|
|
29
|
+
Kubb generates once, when the first build starts. Watch rebuilds and later builds that share the plugin reuse that output, so restart the build after you change your spec. Vite, Nuxt, and Astro generate during builds only, not in their development servers. A missing `config` or a failed generation fails the build.
|
|
28
30
|
|
|
29
31
|
## Installation
|
|
30
32
|
|
|
@@ -37,40 +39,79 @@ npm install -D unplugin-kubb @kubb/core
|
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
```typescript
|
|
42
|
+
// vite.config.ts
|
|
40
43
|
import kubb from 'unplugin-kubb/vite'
|
|
44
|
+
import { defineConfig } from 'vite'
|
|
45
|
+
import config from './kubb.config'
|
|
41
46
|
|
|
42
47
|
export default defineConfig({
|
|
43
|
-
plugins: [kubb({
|
|
48
|
+
plugins: [kubb({ config })],
|
|
44
49
|
})
|
|
45
50
|
```
|
|
46
51
|
|
|
47
52
|
```typescript
|
|
48
|
-
|
|
53
|
+
// rollup.config.ts, rolldown.config.ts
|
|
54
|
+
import kubb from 'unplugin-kubb/rollup' // or 'unplugin-kubb/rolldown'
|
|
55
|
+
import config from './kubb.config'
|
|
49
56
|
|
|
50
57
|
export default {
|
|
51
|
-
|
|
58
|
+
input: 'src/index.ts',
|
|
59
|
+
plugins: [kubb({ config })],
|
|
52
60
|
}
|
|
53
61
|
```
|
|
54
62
|
|
|
55
63
|
```typescript
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
// webpack.config.ts, rspack.config.ts
|
|
65
|
+
import kubb from 'unplugin-kubb/webpack' // or 'unplugin-kubb/rspack'
|
|
66
|
+
import config from './kubb.config'
|
|
67
|
+
|
|
68
|
+
export default {
|
|
69
|
+
plugins: [kubb({ config })],
|
|
59
70
|
}
|
|
60
71
|
```
|
|
61
72
|
|
|
62
73
|
```typescript
|
|
74
|
+
// build.ts
|
|
75
|
+
import { build } from 'esbuild'
|
|
76
|
+
import kubb from 'unplugin-kubb/esbuild'
|
|
77
|
+
import config from './kubb.config'
|
|
78
|
+
|
|
79
|
+
await build({
|
|
80
|
+
entryPoints: ['src/index.ts'],
|
|
81
|
+
bundle: true,
|
|
82
|
+
outfile: 'dist/bundle.js',
|
|
83
|
+
plugins: [kubb({ config })],
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// farm.config.ts
|
|
89
|
+
import { defineConfig } from '@farmfe/core'
|
|
90
|
+
import kubb from 'unplugin-kubb/farm'
|
|
91
|
+
import config from './kubb.config'
|
|
92
|
+
|
|
93
|
+
export default defineConfig({
|
|
94
|
+
plugins: [kubb({ config })],
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// nuxt.config.ts: works with the Vite, webpack, and Rspack builders
|
|
100
|
+
import config from './kubb.config'
|
|
101
|
+
|
|
63
102
|
export default defineNuxtConfig({
|
|
64
|
-
modules: [['unplugin-kubb/nuxt', {
|
|
103
|
+
modules: [['unplugin-kubb/nuxt', { config }]],
|
|
65
104
|
})
|
|
66
105
|
```
|
|
67
106
|
|
|
68
107
|
```typescript
|
|
69
|
-
|
|
70
|
-
import
|
|
108
|
+
// astro.config.mjs
|
|
109
|
+
import { defineConfig } from 'astro/config'
|
|
110
|
+
import kubb from 'unplugin-kubb/astro'
|
|
111
|
+
import config from './kubb.config'
|
|
71
112
|
|
|
72
|
-
|
|
73
|
-
|
|
113
|
+
export default defineConfig({
|
|
114
|
+
integrations: [kubb({ config })],
|
|
74
115
|
})
|
|
75
116
|
```
|
|
76
117
|
|
package/dist/astro.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
const require_vite = require("./vite.cjs");
|
|
3
3
|
//#region src/astro.ts
|
|
4
4
|
var astro_default = /* @__PURE__ */ require_unpluginFactory.__name((options) => ({
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
//#region src/esbuild.ts
|
|
3
3
|
var esbuild_default = (0, require("unplugin").createEsbuildPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/esbuild.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BMmC0zzB.js";
|
|
2
2
|
import { createEsbuildPlugin } from "unplugin";
|
|
3
3
|
//#region src/esbuild.ts
|
|
4
4
|
var esbuild_default = createEsbuildPlugin(unpluginFactory);
|
package/dist/farm.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
//#region src/farm.ts
|
|
3
3
|
var farm_default = (0, require("unplugin").createFarmPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/farm.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
5
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
6
6
|
//#region src/index.ts
|
|
7
7
|
const plugin = /* #__PURE__ */ (0, require("unplugin").createUnplugin)(require_unpluginFactory.unpluginFactory);
|
|
8
8
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BMmC0zzB.js";
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
const plugin = /* #__PURE__ */ createUnplugin(unpluginFactory);
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
require("./unpluginFactory-
|
|
1
|
+
require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
const require_vite = require("./vite.cjs");
|
|
3
|
+
const require_rspack = require("./rspack.cjs");
|
|
3
4
|
const require_webpack = require("./webpack.cjs");
|
|
4
5
|
let _nuxt_kit = require("@nuxt/kit");
|
|
5
6
|
require("@nuxt/schema");
|
|
@@ -11,8 +12,13 @@ var nuxt_default = (0, _nuxt_kit.defineNuxtModule)({
|
|
|
11
12
|
},
|
|
12
13
|
defaults: void 0,
|
|
13
14
|
setup(options, _nuxt) {
|
|
14
|
-
|
|
15
|
-
|
|
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);
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
24
|
//#endregion
|
package/dist/nuxt.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.cjs","names":["defineNuxtModule","vite","webpack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport type { Options } from './types.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 addVitePlugin(() => vite(options))\n addWebpackPlugin(() => webpack(options))\n },\n})\n"],"mappings":"
|
|
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 './types.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.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import vite_default from "./vite.js";
|
|
3
|
+
import rspack_default from "./rspack.js";
|
|
3
4
|
import webpack_default from "./webpack.js";
|
|
4
|
-
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
5
|
+
import { addRspackPlugin, addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
5
6
|
import "@nuxt/schema";
|
|
6
7
|
//#region src/nuxt.ts
|
|
7
8
|
var nuxt_default = defineNuxtModule({
|
|
@@ -11,8 +12,13 @@ var nuxt_default = defineNuxtModule({
|
|
|
11
12
|
},
|
|
12
13
|
defaults: void 0,
|
|
13
14
|
setup(options, _nuxt) {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const buildOptions = {
|
|
16
|
+
dev: false,
|
|
17
|
+
server: false
|
|
18
|
+
};
|
|
19
|
+
addVitePlugin(() => vite_default(options), buildOptions);
|
|
20
|
+
addWebpackPlugin(() => webpack_default(options), buildOptions);
|
|
21
|
+
addRspackPlugin(() => rspack_default(options), buildOptions);
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
24
|
//#endregion
|
package/dist/nuxt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.js","names":["vite","webpack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport type { Options } from './types.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 addVitePlugin(() => vite(options))\n addWebpackPlugin(() => webpack(options))\n },\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"nuxt.js","names":["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 './types.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,eAAe,iBAAgC;CAC7C,MAAM;EACJ,MAAM;EACN,WAAW;CACb;CACA,UAAU,KAAA;CACV,MAAM,SAAS,OAAO;EAGpB,MAAM,eAAe;GAAE,KAAK;GAAO,QAAQ;EAAM;EAEjD,oBAAoBA,aAAK,OAAO,GAAG,YAAY;EAC/C,uBAAuBC,gBAAQ,OAAO,GAAG,YAAY;EACrD,sBAAsBC,eAAO,OAAO,GAAG,YAAY;CACrD;AACF,CAAC"}
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
//#region src/rolldown.ts
|
|
3
3
|
var rolldown_default = (0, require("unplugin").createRolldownPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rolldown.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BMmC0zzB.js";
|
|
2
2
|
import { createRolldownPlugin } from "unplugin";
|
|
3
3
|
//#region src/rolldown.ts
|
|
4
4
|
var rolldown_default = createRolldownPlugin(unpluginFactory);
|
package/dist/rollup.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
//#region src/rollup.ts
|
|
3
3
|
var rollup_default = (0, require("unplugin").createRollupPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rollup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BMmC0zzB.js";
|
|
2
2
|
import { createRollupPlugin } from "unplugin";
|
|
3
3
|
//#region src/rollup.ts
|
|
4
4
|
var rollup_default = createRollupPlugin(unpluginFactory);
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
//#region src/rspack.ts
|
|
3
3
|
var rspack_default = (0, require("unplugin").createRspackPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rspack.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
3
|
//#region src/rspack.d.ts
|
|
4
|
-
declare const _default: (options?: Options | undefined) => RspackPluginInstance;
|
|
4
|
+
declare const _default: (options?: Options | undefined) => import("unplugin").RspackPluginInstance;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
7
7
|
//# sourceMappingURL=rspack.d.ts.map
|
package/dist/rspack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BMmC0zzB.js";
|
|
2
2
|
import { createRspackPlugin } from "unplugin";
|
|
3
3
|
//#region src/rspack.ts
|
|
4
4
|
var rspack_default = createRspackPlugin(unpluginFactory);
|
|
@@ -10,15 +10,16 @@ let _kubb_core = require("@kubb/core");
|
|
|
10
10
|
let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
|
|
11
11
|
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "5.
|
|
13
|
+
var version = "5.9.1";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/unpluginFactory.ts
|
|
16
16
|
/**
|
|
17
17
|
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
18
18
|
*
|
|
19
19
|
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
20
|
-
* the Kubb build during `buildStart`. When the config omits them, it fills in defaults:
|
|
21
|
-
* adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
20
|
+
* the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:
|
|
21
|
+
* the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
22
|
+
* `build`. A missing config or a failed generation fails the host build.
|
|
22
23
|
*/
|
|
23
24
|
const unpluginFactory = (options, meta) => {
|
|
24
25
|
const name = "unplugin-kubb";
|
|
@@ -52,18 +53,17 @@ const unpluginFactory = (options, meta) => {
|
|
|
52
53
|
console.log("✓ Files written successfully");
|
|
53
54
|
});
|
|
54
55
|
hooks.hook("kubb:generation:end", ({ config, status, diagnostics }) => {
|
|
55
|
-
|
|
56
|
+
const result = status === "failed" ? "✗ Generation failed" : "✓ Generation succeeded";
|
|
57
|
+
console.log(config.name ? `${result} for ${config.name}` : result);
|
|
56
58
|
if (!diagnostics || !status) return;
|
|
57
59
|
const failedCount = _kubb_core.Diagnostics.failedPlugins(diagnostics).length;
|
|
58
60
|
const pluginsCount = config.plugins.length;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
+
const passedCount = pluginsCount - failedCount;
|
|
62
|
+
const { errors } = _kubb_core.Diagnostics.count(diagnostics);
|
|
63
|
+
console.log(status === "success" ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})` : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? "error" : "errors"}`);
|
|
61
64
|
});
|
|
62
|
-
async function runBuild(
|
|
63
|
-
if (!options?.config) {
|
|
64
|
-
(ctx.error ?? console.error)(`[${name}] Config is not set`);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
65
|
+
async function runBuild() {
|
|
66
|
+
if (!options?.config) throw new Error(`[${name}] Config is not set`);
|
|
67
67
|
const { adapter, output, plugins } = (0, _kubb_core.applyConfigDefaults)(options.config, {
|
|
68
68
|
defaultAdapter: (0, _kubb_adapter_oas.adapterOas)(),
|
|
69
69
|
barrelPlugin: (0, _kubb_plugin_barrel.pluginBarrel)(),
|
|
@@ -88,21 +88,21 @@ const unpluginFactory = (options, meta) => {
|
|
|
88
88
|
const failedCount = _kubb_core.Diagnostics.failedPlugins(result.diagnostics).length;
|
|
89
89
|
const firstError = result.diagnostics.filter(_kubb_core.Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
90
90
|
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
91
|
-
if (ctx.error) {
|
|
92
|
-
ctx.error(`[${name}] ${message}`);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
91
|
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
96
92
|
}
|
|
97
93
|
}
|
|
94
|
+
let generation;
|
|
98
95
|
return {
|
|
99
96
|
name,
|
|
100
97
|
enforce: "pre",
|
|
101
98
|
apply: isVite ? "build" : void 0,
|
|
102
99
|
async buildStart() {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
generation ??= runBuild().catch((error) => {
|
|
101
|
+
generation = void 0;
|
|
102
|
+
throw error;
|
|
103
|
+
});
|
|
104
|
+
await generation;
|
|
105
|
+
}
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
108
|
//#endregion
|
|
@@ -119,4 +119,4 @@ Object.defineProperty(exports, "unpluginFactory", {
|
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
//# sourceMappingURL=unpluginFactory-
|
|
122
|
+
//# sourceMappingURL=unpluginFactory-BKFFFN9W.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-BKFFFN9W.cjs","names":["Hookable","Diagnostics","applyConfigDefaults","adapterOas","pluginBarrel","pluginBarrelName","parserTs","parserTsx","unpluginVersion","createKubb"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import { adapterOas } from '@kubb/adapter-oas'\nimport { applyConfigDefaults, type Config, createKubb, Diagnostics, type KubbHooks, Hookable } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:\n * the OAS adapter, the TS and TSX parsers, and a barrel plugin. 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 isVite = meta.framework === 'vite'\n\n hooks.hook('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.hook('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.hook('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.hook('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n // Unplugin has no diagnostic renderer, so route each problem by severity to a channel it logs on.\n hooks.hook('kubb:diagnostic', ({ diagnostic }) => {\n if (diagnostic.severity === 'error') return hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n if (diagnostic.severity === 'warning') return hooks.callHook('kubb:warn', { message: diagnostic.message })\n return hooks.callHook('kubb:info', { message: diagnostic.message })\n })\n\n hooks.hook('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n hooks.hook('kubb:files:processing:end', () => {\n console.log('✓ Files written successfully')\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n const result = status === 'failed' ? '✗ Generation failed' : '✓ Generation succeeded'\n console.log(config.name ? `${result} for ${config.name}` : result)\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const passedCount = pluginsCount - failedCount\n const { errors } = Diagnostics.count(diagnostics)\n\n // A run that fails before any plugin runs has 0 failed plugins, so show the error count.\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})`\n : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? 'error' : 'errors'}`,\n )\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 Error(`[${name}] Config is not set`)\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: false, format: false, lint: false },\n })\n\n const config = {\n ...options.config,\n adapter,\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],\n plugins,\n output,\n }\n const userConfig = config as Config\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const kubb = createKubb(userConfig, { hooks })\n const result = await kubb.generate()\n\n await hooks.callHook('kubb:lifecycle:end')\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 throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\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: isVite ? '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":";;;;;;;;;;;;;;;;;;;;;;;ACgBA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAIA,WAAAA,SAAoB;CACtC,MAAM,SAAS,KAAK,cAAc;CAElC,MAAM,KAAK,yBAAyB,EAAE,cAAc;EAClD,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;CAC3C,CAAC;CAED,MAAM,KAAK,eAAe,EAAE,YAAY;EACtC,QAAQ,MAAM,KAAK,OAAO,WAAW,UAAU;CACjD,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAGD,MAAM,KAAK,oBAAoB,EAA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applyConfigDefaults, createKubb } from "@kubb/co
|
|
|
4
4
|
import { pluginBarrel, pluginBarrelName } from "@kubb/plugin-barrel";
|
|
5
5
|
import { parserTs, parserTsx } from "@kubb/parser-ts";
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version = "5.
|
|
7
|
+
var version = "5.9.1";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/unpluginFactory.ts
|
|
10
10
|
/**
|
|
11
11
|
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
12
12
|
*
|
|
13
13
|
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
14
|
-
* the Kubb build during `buildStart`. When the config omits them, it fills in defaults:
|
|
15
|
-
* adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
14
|
+
* the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:
|
|
15
|
+
* the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
16
|
+
* `build`. A missing config or a failed generation fails the host build.
|
|
16
17
|
*/
|
|
17
18
|
const unpluginFactory = (options, meta) => {
|
|
18
19
|
const name = "unplugin-kubb";
|
|
@@ -46,18 +47,17 @@ const unpluginFactory = (options, meta) => {
|
|
|
46
47
|
console.log("✓ Files written successfully");
|
|
47
48
|
});
|
|
48
49
|
hooks.hook("kubb:generation:end", ({ config, status, diagnostics }) => {
|
|
49
|
-
|
|
50
|
+
const result = status === "failed" ? "✗ Generation failed" : "✓ Generation succeeded";
|
|
51
|
+
console.log(config.name ? `${result} for ${config.name}` : result);
|
|
50
52
|
if (!diagnostics || !status) return;
|
|
51
53
|
const failedCount = Diagnostics.failedPlugins(diagnostics).length;
|
|
52
54
|
const pluginsCount = config.plugins.length;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
+
const passedCount = pluginsCount - failedCount;
|
|
56
|
+
const { errors } = Diagnostics.count(diagnostics);
|
|
57
|
+
console.log(status === "success" ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})` : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? "error" : "errors"}`);
|
|
55
58
|
});
|
|
56
|
-
async function runBuild(
|
|
57
|
-
if (!options?.config) {
|
|
58
|
-
(ctx.error ?? console.error)(`[${name}] Config is not set`);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
59
|
+
async function runBuild() {
|
|
60
|
+
if (!options?.config) throw new Error(`[${name}] Config is not set`);
|
|
61
61
|
const { adapter, output, plugins } = applyConfigDefaults(options.config, {
|
|
62
62
|
defaultAdapter: adapterOas(),
|
|
63
63
|
barrelPlugin: pluginBarrel(),
|
|
@@ -82,24 +82,24 @@ const unpluginFactory = (options, meta) => {
|
|
|
82
82
|
const failedCount = Diagnostics.failedPlugins(result.diagnostics).length;
|
|
83
83
|
const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
84
84
|
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
85
|
-
if (ctx.error) {
|
|
86
|
-
ctx.error(`[${name}] ${message}`);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
85
|
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
90
86
|
}
|
|
91
87
|
}
|
|
88
|
+
let generation;
|
|
92
89
|
return {
|
|
93
90
|
name,
|
|
94
91
|
enforce: "pre",
|
|
95
92
|
apply: isVite ? "build" : void 0,
|
|
96
93
|
async buildStart() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
generation ??= runBuild().catch((error) => {
|
|
95
|
+
generation = void 0;
|
|
96
|
+
throw error;
|
|
97
|
+
});
|
|
98
|
+
await generation;
|
|
99
|
+
}
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
102
|
//#endregion
|
|
103
103
|
export { unpluginFactory as t };
|
|
104
104
|
|
|
105
|
-
//# sourceMappingURL=unpluginFactory-
|
|
105
|
+
//# sourceMappingURL=unpluginFactory-BMmC0zzB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-BMmC0zzB.js","names":["unpluginVersion"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import { adapterOas } from '@kubb/adapter-oas'\nimport { applyConfigDefaults, type Config, createKubb, Diagnostics, type KubbHooks, Hookable } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:\n * the OAS adapter, the TS and TSX parsers, and a barrel plugin. 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 isVite = meta.framework === 'vite'\n\n hooks.hook('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.hook('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.hook('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.hook('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n // Unplugin has no diagnostic renderer, so route each problem by severity to a channel it logs on.\n hooks.hook('kubb:diagnostic', ({ diagnostic }) => {\n if (diagnostic.severity === 'error') return hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n if (diagnostic.severity === 'warning') return hooks.callHook('kubb:warn', { message: diagnostic.message })\n return hooks.callHook('kubb:info', { message: diagnostic.message })\n })\n\n hooks.hook('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n hooks.hook('kubb:files:processing:end', () => {\n console.log('✓ Files written successfully')\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n const result = status === 'failed' ? '✗ Generation failed' : '✓ Generation succeeded'\n console.log(config.name ? `${result} for ${config.name}` : result)\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const passedCount = pluginsCount - failedCount\n const { errors } = Diagnostics.count(diagnostics)\n\n // A run that fails before any plugin runs has 0 failed plugins, so show the error count.\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})`\n : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? 'error' : 'errors'}`,\n )\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 Error(`[${name}] Config is not set`)\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: false, format: false, lint: false },\n })\n\n const config = {\n ...options.config,\n adapter,\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],\n plugins,\n output,\n }\n const userConfig = config as Config\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const kubb = createKubb(userConfig, { hooks })\n const result = await kubb.generate()\n\n await hooks.callHook('kubb:lifecycle:end')\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 throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\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: isVite ? '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":";;;;;;;;;;;;;;;;;ACgBA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAI,SAAoB;CACtC,MAAM,SAAS,KAAK,cAAc;CAElC,MAAM,KAAK,yBAAyB,EAAE,cAAc;EAClD,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;CAC3C,CAAC;CAED,MAAM,KAAK,eAAe,EAAE,YAAY;EACtC,QAAQ,MAAM,KAAK,OAAO,WAAW,UAAU;CACjD,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAGD,MAAM,KAAK,oBAAoB,EAAE,iBAAiB;EAChD,IAAI,WAAW,aAAa,SAAS,OAAO,MAAM,SAAS,cAAc,EAAE,OAAO,WAAW,SAAS,IAAI,MAAM,WAAW,OAAO,EAAE,CAAC;EACrI,IAAI,WAAW,aAAa,WAAW,OAAO,MAAM,SAAS,aAAa,EAAE,SAAS,WAAW,QAAQ,CAAC;EACzG,OAAO,MAAM,SAAS,aAAa,EAAE,SAAS,WAAW,QAAQ,CAAC;CACpE,CAAC;CAED,MAAM,KAAK,iBAAiB,EAAE,cAAc;EAC1C,QAAQ,IAAI,K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SAAS,wBAAwB,EAAWA,QAAgB,CAAC;EAGzE,MAAM,SAAS,MADF,WAAW,YAAY,EAAE,MAAM,CACpB,CAAC,CAAC,SAAS;EAEnC,MAAM,MAAM,SAAS,oBAAoB;EAEzC,IAAI,CAAC,OAAO,SAAS;GACnB,MAAM,cAAc,YAAY,cAAc,OAAO,WAAW,CAAC,CAAC;GAClE,MAAM,aAAa,OAAO,YAAY,OAAO,YAAY,SAAS,CAAC,CAAC,MAAM,eAAe,WAAW,aAAa,OAAO;GACxH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAE7G,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAGA,IAAI;CAEJ,OAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;GACjB,eAAe,SAAS,CAAC,CAAC,OAAO,UAAmB;IAClD,aAAa,KAAA;IACb,MAAM;GACR,CAAC;GACD,MAAM;EACR;CACF;AACF"}
|
package/dist/unpluginFactory.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
2
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
3
3
|
exports.unpluginFactory = require_unpluginFactory.unpluginFactory;
|
|
@@ -6,8 +6,9 @@ import { UnpluginFactory } from "unplugin";
|
|
|
6
6
|
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
7
7
|
*
|
|
8
8
|
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
9
|
-
* the Kubb build during `buildStart`. When the config omits them, it fills in defaults:
|
|
10
|
-
* adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
9
|
+
* the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:
|
|
10
|
+
* the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
11
|
+
* `build`. A missing config or a failed generation fails the host build.
|
|
11
12
|
*/
|
|
12
13
|
export declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
|
13
14
|
//#endregion
|
package/dist/unpluginFactory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
export { t as unpluginFactory } from "./unpluginFactory-BMmC0zzB.js";
|
package/dist/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
//#region src/vite.ts
|
|
3
3
|
var vite_default = (0, require("unplugin").createVitePlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-BKFFFN9W.cjs");
|
|
2
2
|
//#region src/webpack.ts
|
|
3
3
|
var webpack_default = (0, require("unplugin").createWebpackPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/webpack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BMmC0zzB.js";
|
|
2
2
|
import { createWebpackPlugin } from "unplugin";
|
|
3
3
|
//#region src/webpack.ts
|
|
4
4
|
var webpack_default = createWebpackPlugin(unpluginFactory);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-kubb",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"description": "Integration of Kubb for Vite,
|
|
3
|
+
"version": "5.9.1",
|
|
4
|
+
"description": "Integration of Kubb for Vite, webpack, Rollup, Rolldown, Rspack, esbuild, Farm, Nuxt, and Astro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
7
7
|
"codegen",
|
|
@@ -126,17 +126,18 @@
|
|
|
126
126
|
"registry": "https://registry.npmjs.org/"
|
|
127
127
|
},
|
|
128
128
|
"dependencies": {
|
|
129
|
-
"@kubb/adapter-oas": "5.
|
|
130
|
-
"@kubb/core": "5.
|
|
131
|
-
"@kubb/parser-ts": "5.
|
|
132
|
-
"@kubb/plugin-barrel": "5.
|
|
129
|
+
"@kubb/adapter-oas": "5.9.1",
|
|
130
|
+
"@kubb/core": "5.9.1",
|
|
131
|
+
"@kubb/parser-ts": "5.9.1",
|
|
132
|
+
"@kubb/plugin-barrel": "5.9.1",
|
|
133
133
|
"unplugin": "^3.4.0"
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
136
|
"@farmfe/core": "^1.7.11",
|
|
137
|
-
"@kubb/ast": "5.
|
|
137
|
+
"@kubb/ast": "5.9.1",
|
|
138
138
|
"@nuxt/kit": "^4.6.1",
|
|
139
139
|
"@nuxt/schema": "^4.6.1",
|
|
140
|
+
"@rspack/core": "^2.2.8",
|
|
140
141
|
"esbuild": "^0.28.2",
|
|
141
142
|
"rolldown": "^1.2.13",
|
|
142
143
|
"rollup": "^4.64.5",
|
|
@@ -145,8 +146,8 @@
|
|
|
145
146
|
},
|
|
146
147
|
"peerDependencies": {
|
|
147
148
|
"@farmfe/core": "^1.7.0",
|
|
148
|
-
"@nuxt/kit": "^3 || ^4",
|
|
149
|
-
"@nuxt/schema": "^3 || ^4",
|
|
149
|
+
"@nuxt/kit": "^3.14.0 || ^4",
|
|
150
|
+
"@nuxt/schema": "^3.14.0 || ^4",
|
|
150
151
|
"esbuild": "*",
|
|
151
152
|
"rolldown": ">=1",
|
|
152
153
|
"rollup": "^3 || ^4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpluginFactory-Cdw7v8K3.js","names":["unpluginVersion"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import { adapterOas } from '@kubb/adapter-oas'\nimport { applyConfigDefaults, type Config, createKubb, Diagnostics, type KubbHooks, Hookable } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `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 isVite = meta.framework === 'vite'\n\n hooks.hook('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.hook('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.hook('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.hook('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n // Unplugin has no diagnostic renderer, so route each problem by severity to a channel it logs on.\n hooks.hook('kubb:diagnostic', ({ diagnostic }) => {\n if (diagnostic.severity === 'error') return hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n if (diagnostic.severity === 'warning') return hooks.callHook('kubb:warn', { message: diagnostic.message })\n return hooks.callHook('kubb:info', { message: diagnostic.message })\n })\n\n hooks.hook('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n hooks.hook('kubb:files:processing:end', () => {\n console.log('✓ Files written successfully')\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${successCount} successful, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${successCount} successful, ✗ ${failedCount} failed, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: false, format: false, lint: false },\n })\n\n const config = {\n ...options.config,\n adapter,\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],\n plugins,\n output,\n }\n const userConfig = config as Config\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const kubb = createKubb(userConfig, { hooks })\n const result = await kubb.generate()\n\n await hooks.callHook('kubb:lifecycle:end')\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 if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;ACqBA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAI,SAAoB;CACtC,MAAM,SAAS,KAAK,cAAc;CAElC,MAAM,KAAK,yBAAyB,EAAE,cAAc;EAClD,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;CAC3C,CAAC;CAED,MAAM,KAAK,eAAe,EAAE,YAAY;EACtC,QAAQ,MAAM,KAAK,OAAO,WAAW,UAAU;CACjD,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAGD,MAAM,KAAK,oBAAoB,EAAE,iBAAiB;EAChD,IAAI,WAAW,aAAa,SAAS,OAAO,MAAM,SAAS,cAAc,EAAE,OAAO,WAAW,SAAS,IAAI,MAAM,WAAW,OAAO,EAAE,CAAC;EACrI,IAAI,WAAW,aAAa,WAAW,OAAO,MAAM,SAAS,aAAa,EAAE,SAAS,WAAW,QAAQ,CAAC;EACzG,OAAO,MAAM,SAAS,aAAa,EAAE,SAAS,WAAW,QAAQ,CAAC;CACpE,CAAC;CAED,MAAM,KAAK,iBAAiB,EAAE,cAAc;EAC1C,QAAQ,IAAI,KAAK,SAAS;CAC5B,CAAC;CAED,MAAM,KAAK,oBAAoB,EAAE,QAAQ,eAAe;EACtD,MAAM,cAAc,YAAY,MAAO,IAAI,WAAW,IAAA,CAAM,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS;EAExF,QAAQ,IAAI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,OAAO,YAAY,SAAS,CAAC,CAAC,MAAM,eAAe,WAAW,aAAa,OAAO;GACxH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAC7G,IAAI,IAAI,OAAO;IACb,IAAI,MAAM,IAAI,KAAK,IAAI,SAAS;IAChC;GACF;GAEA,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAEA,OAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;GACjB,MAAM,SAAS,IAAgC;EACjD;EACA,MAAM,CAAC;CACT;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpluginFactory-vl_Yrcf4.cjs","names":["Hookable","Diagnostics","applyConfigDefaults","adapterOas","pluginBarrel","pluginBarrelName","parserTs","parserTsx","unpluginVersion","createKubb"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import { adapterOas } from '@kubb/adapter-oas'\nimport { applyConfigDefaults, type Config, createKubb, Diagnostics, type KubbHooks, Hookable } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `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 isVite = meta.framework === 'vite'\n\n hooks.hook('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.hook('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.hook('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.hook('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n // Unplugin has no diagnostic renderer, so route each problem by severity to a channel it logs on.\n hooks.hook('kubb:diagnostic', ({ diagnostic }) => {\n if (diagnostic.severity === 'error') return hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n if (diagnostic.severity === 'warning') return hooks.callHook('kubb:warn', { message: diagnostic.message })\n return hooks.callHook('kubb:info', { message: diagnostic.message })\n })\n\n hooks.hook('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n hooks.hook('kubb:files:processing:end', () => {\n console.log('✓ Files written successfully')\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${successCount} successful, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${successCount} successful, ✗ ${failedCount} failed, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: false, format: false, lint: false },\n })\n\n const config = {\n ...options.config,\n adapter,\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],\n plugins,\n output,\n }\n const userConfig = config as Config\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const kubb = createKubb(userConfig, { hooks })\n const result = await kubb.generate()\n\n await hooks.callHook('kubb:lifecycle:end')\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 if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;ACqBA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAIA,WAAAA,SAAoB;CACtC,MAAM,SAAS,KAAK,cAAc;CAElC,MAAM,KAAK,yBAAyB,EAAE,cAAc;EAClD,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;CAC3C,CAAC;CAED,MAAM,KAAK,eAAe,EAAE,YAAY;EACtC,QAAQ,MAAM,KAAK,OAAO,WAAW,UAAU;CACjD,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAGD,MAAM,KAAK,oBAAoB,EAAE,iBAAiB;EAChD,IAAI,WA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