unplugin-kubb 4.0.2 → 5.0.0-alpha.35

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.
Files changed (89) hide show
  1. package/LICENSE +10 -17
  2. package/dist/astro.cjs +7 -8
  3. package/dist/astro.cjs.map +1 -1
  4. package/dist/astro.d.ts +3 -8
  5. package/dist/astro.js +7 -9
  6. package/dist/astro.js.map +1 -1
  7. package/dist/{chunk-CIm-hhu7.js → chunk--u3MIqq1.js} +2 -3
  8. package/dist/esbuild.cjs +3 -5
  9. package/dist/esbuild.cjs.map +1 -1
  10. package/dist/esbuild.d.ts +4 -4
  11. package/dist/esbuild.js +2 -3
  12. package/dist/esbuild.js.map +1 -1
  13. package/dist/farm.cjs +7 -0
  14. package/dist/farm.cjs.map +1 -0
  15. package/dist/farm.d.ts +9 -0
  16. package/dist/farm.js +8 -0
  17. package/dist/farm.js.map +1 -0
  18. package/dist/index.cjs +12 -5
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.ts +6 -7
  21. package/dist/index.js +7 -2
  22. package/dist/index.js.map +1 -0
  23. package/dist/nuxt.cjs +8 -9
  24. package/dist/nuxt.cjs.map +1 -1
  25. package/dist/nuxt.d.ts +4 -4
  26. package/dist/nuxt.js +4 -5
  27. package/dist/nuxt.js.map +1 -1
  28. package/dist/rolldown.cjs +7 -0
  29. package/dist/rolldown.cjs.map +1 -0
  30. package/dist/rolldown.d.ts +9 -0
  31. package/dist/rolldown.js +8 -0
  32. package/dist/rolldown.js.map +1 -0
  33. package/dist/rollup.cjs +3 -5
  34. package/dist/rollup.cjs.map +1 -1
  35. package/dist/rollup.d.ts +4 -4
  36. package/dist/rollup.js +2 -3
  37. package/dist/rollup.js.map +1 -1
  38. package/dist/rspack.cjs +3 -5
  39. package/dist/rspack.cjs.map +1 -1
  40. package/dist/rspack.d.ts +2 -2
  41. package/dist/rspack.js +2 -3
  42. package/dist/rspack.js.map +1 -1
  43. package/dist/types.d.ts +13 -2
  44. package/dist/types.js +1 -1
  45. package/dist/unpluginFactory-TMEwHLb9.js +220 -0
  46. package/dist/unpluginFactory-TMEwHLb9.js.map +1 -0
  47. package/dist/unpluginFactory-USz7K71q.cjs +263 -0
  48. package/dist/unpluginFactory-USz7K71q.cjs.map +1 -0
  49. package/dist/unpluginFactory.cjs +3 -0
  50. package/dist/unpluginFactory.d.ts +9 -0
  51. package/dist/unpluginFactory.js +2 -0
  52. package/dist/vite.cjs +3 -5
  53. package/dist/vite.cjs.map +1 -1
  54. package/dist/vite.d.ts +4 -4
  55. package/dist/vite.js +2 -3
  56. package/dist/vite.js.map +1 -1
  57. package/dist/webpack.cjs +3 -5
  58. package/dist/webpack.cjs.map +1 -1
  59. package/dist/webpack.d.ts +2 -2
  60. package/dist/webpack.js +2 -3
  61. package/dist/webpack.js.map +1 -1
  62. package/package.json +74 -45
  63. package/src/astro.ts +4 -5
  64. package/src/esbuild.ts +1 -1
  65. package/src/farm.ts +5 -0
  66. package/src/index.ts +5 -133
  67. package/src/nuxt.ts +2 -2
  68. package/src/rolldown.ts +5 -0
  69. package/src/rollup.ts +1 -1
  70. package/src/rspack.ts +1 -1
  71. package/src/types.ts +2 -2
  72. package/src/unpluginFactory.ts +140 -0
  73. package/src/vite.ts +1 -1
  74. package/src/webpack.ts +1 -2
  75. package/dist/astro.d.cts +0 -11
  76. package/dist/esbuild.d.cts +0 -7
  77. package/dist/index.d.cts +0 -10
  78. package/dist/nuxt.d.cts +0 -9
  79. package/dist/rollup.d.cts +0 -7
  80. package/dist/rspack.d.cts +0 -6
  81. package/dist/src-BiN2tznZ.cjs +0 -155
  82. package/dist/src-BiN2tznZ.cjs.map +0 -1
  83. package/dist/src-CiUcBKSs.js +0 -95
  84. package/dist/src-CiUcBKSs.js.map +0 -1
  85. package/dist/types-C-ZTDGdJ.d.cts +0 -650
  86. package/dist/types-CUVJ-CBJ.d.ts +0 -649
  87. package/dist/types.d.cts +0 -2
  88. package/dist/vite.d.cts +0 -7
  89. package/dist/webpack.d.cts +0 -8
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.js","names":[],"sources":["../src/webpack.ts"],"sourcesContent":["import type { UnpluginFactoryOutput } from 'unplugin'\nimport { createWebpackPlugin } from 'unplugin'\nimport type { WebpackPluginInstance } from 'webpack'\nimport { unpluginFactory } from './index.ts'\nimport type { Options } from './types.ts'\n\n// resolves issue for: The inferred type of 'default' cannot be named without a reference to 'node_modules/webpack'. This is likely not portable. A type annotation is necessary.\nexport default createWebpackPlugin(unpluginFactory) as unknown as UnpluginFactoryOutput<Options, WebpackPluginInstance>\n"],"mappings":";;;;AAOA,sBAAe,oBAAoB,gBAAgB"}
1
+ {"version":3,"file":"webpack.js","names":[],"sources":["../src/webpack.ts"],"sourcesContent":["import type { UnpluginFactoryOutput } from 'unplugin'\nimport { createWebpackPlugin } from 'unplugin'\nimport type { WebpackPluginInstance } from 'webpack'\nimport type { Options } from './types.ts'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createWebpackPlugin(unpluginFactory) as unknown as UnpluginFactoryOutput<Options, WebpackPluginInstance>\n"],"mappings":";;;AAMA,IAAA,kBAAe,oBAAoB,gBAAgB"}
package/package.json CHANGED
@@ -1,24 +1,28 @@
1
1
  {
2
2
  "name": "unplugin-kubb",
3
- "version": "4.0.2",
4
- "description": "Unplugin for Kubb",
3
+ "version": "5.0.0-alpha.35",
4
+ "description": "Universal build plugin for Kubb, integrating OpenAPI code generation into Vite, Webpack, Rollup, esbuild, Rspack, Nuxt, and Astro build processes.",
5
5
  "keywords": [
6
6
  "unplugin",
7
7
  "vite",
8
8
  "webpack",
9
9
  "rollup",
10
- "transform",
11
- "astro",
12
- "kubb",
13
- "swagger",
14
- "OpenAPI",
10
+ "esbuild",
15
11
  "rspack",
16
12
  "nuxt",
17
- "esbuild"
13
+ "astro",
14
+ "build-tool",
15
+ "bundler",
16
+ "transform",
17
+ "openapi",
18
+ "swagger",
19
+ "code-generator",
20
+ "typescript",
21
+ "kubb"
18
22
  ],
19
23
  "repository": {
20
24
  "type": "git",
21
- "url": "https://github.com/kubb-labs/kubb.git",
25
+ "url": "git+https://github.com/kubb-labs/kubb.git",
22
26
  "directory": "packages/unplugin"
23
27
  },
24
28
  "license": "MIT",
@@ -27,46 +31,56 @@
27
31
  "type": "module",
28
32
  "exports": {
29
33
  ".": {
30
- "require": "./dist/index.cjs",
31
- "import": "./dist/index.js"
34
+ "import": "./dist/index.js",
35
+ "require": "./dist/index.cjs"
32
36
  },
33
37
  "./astro": {
34
- "require": "./dist/astro.cjs",
35
- "import": "./dist/astro.js"
38
+ "import": "./dist/astro.js",
39
+ "require": "./dist/astro.cjs"
36
40
  },
37
41
  "./esbuild": {
38
- "require": "./dist/esbuild.cjs",
39
- "import": "./dist/esbuild.js"
42
+ "import": "./dist/esbuild.js",
43
+ "require": "./dist/esbuild.cjs"
44
+ },
45
+ "./farm": {
46
+ "import": "./dist/farm.js",
47
+ "require": "./dist/farm.cjs"
40
48
  },
41
49
  "./nuxt": {
42
- "require": "./dist/nuxt.cjs",
43
- "import": "./dist/nuxt.js"
50
+ "import": "./dist/nuxt.js",
51
+ "require": "./dist/nuxt.cjs"
52
+ },
53
+ "./rolldown": {
54
+ "import": "./dist/rolldown.js",
55
+ "require": "./dist/rolldown.cjs"
44
56
  },
45
57
  "./rollup": {
46
- "require": "./dist/rollup.cjs",
47
- "import": "./dist/rollup.js"
58
+ "import": "./dist/rollup.js",
59
+ "require": "./dist/rollup.cjs"
48
60
  },
49
61
  "./rspack": {
50
- "require": "./dist/rspack.cjs",
51
- "import": "./dist/rspack.js"
62
+ "import": "./dist/rspack.js",
63
+ "require": "./dist/rspack.cjs"
52
64
  },
53
65
  "./types": {
54
- "require": "./dist/types.cjs",
55
- "import": "./dist/types.js"
66
+ "import": "./dist/types.js",
67
+ "require": "./dist/types.cjs"
68
+ },
69
+ "./unpluginFactory": {
70
+ "import": "./dist/unpluginFactory.js",
71
+ "require": "./dist/unpluginFactory.cjs"
56
72
  },
57
73
  "./vite": {
58
- "require": "./dist/vite.cjs",
59
- "import": "./dist/vite.js"
74
+ "import": "./dist/vite.js",
75
+ "require": "./dist/vite.cjs"
60
76
  },
61
77
  "./webpack": {
62
- "require": "./dist/webpack.cjs",
63
- "import": "./dist/webpack.js"
78
+ "import": "./dist/webpack.js",
79
+ "require": "./dist/webpack.cjs"
64
80
  },
65
81
  "./package.json": "./package.json"
66
82
  },
67
- "main": "./dist/index.cjs",
68
- "module": "./dist/index.js",
69
- "types": "./dist/index.d.cts",
83
+ "types": "./dist/index.d.ts",
70
84
  "typesVersions": {
71
85
  "*": {
72
86
  "*": [
@@ -79,31 +93,41 @@
79
93
  "src",
80
94
  "dist",
81
95
  "!/**/**.test.**",
82
- "!/**/__tests__/**"
96
+ "!/**/__tests__/**",
97
+ "!/**/__snapshots__/**"
83
98
  ],
84
99
  "dependencies": {
85
- "unplugin": "^2.3.11"
100
+ "unplugin": "^3.0.0",
101
+ "@kubb/adapter-oas": "5.0.0-alpha.35",
102
+ "@kubb/core": "5.0.0-alpha.35",
103
+ "@kubb/parser-ts": "5.0.0-alpha.35"
86
104
  },
87
105
  "devDependencies": {
88
- "@nuxt/kit": "^4.2.2",
89
- "@nuxt/schema": "^4.2.2",
106
+ "@farmfe/core": "^1.7.11",
107
+ "@nuxt/kit": "^4.4.2",
108
+ "@nuxt/schema": "^4.4.2",
90
109
  "esbuild": "*",
91
- "rimraf": "^6.1.2",
92
- "rollup": "^4.55.2",
93
- "vite": "^7.3.1",
94
- "webpack": "^5.104.1",
95
- "@kubb/core": "4.18.0"
110
+ "rolldown": "~1.0.0-rc.16",
111
+ "rollup": "^4.60.1",
112
+ "vite": "^7.3.2",
113
+ "webpack": "^5.106.2",
114
+ "@internals/utils": "0.0.0"
96
115
  },
97
116
  "peerDependencies": {
98
- "@kubb/core": "^4.0.0",
99
- "@nuxt/kit": "^3",
100
- "@nuxt/schema": "^3",
117
+ "@farmfe/core": "^1.7.0",
118
+ "@kubb/core": "^5.0.0-alpha.0",
119
+ "@nuxt/kit": "^3 || ^4",
120
+ "@nuxt/schema": "^3 || ^4",
101
121
  "esbuild": "*",
102
- "rollup": "^3",
122
+ "rolldown": ">=1",
123
+ "rollup": "^3 || ^4",
103
124
  "vite": ">=3",
104
125
  "webpack": "^5"
105
126
  },
106
127
  "peerDependenciesMeta": {
128
+ "@farmfe/core": {
129
+ "optional": true
130
+ },
107
131
  "@nuxt/kit": {
108
132
  "optional": true
109
133
  },
@@ -113,6 +137,9 @@
113
137
  "esbuild": {
114
138
  "optional": true
115
139
  },
140
+ "rolldown": {
141
+ "optional": true
142
+ },
116
143
  "rollup": {
117
144
  "optional": true
118
145
  },
@@ -124,15 +151,17 @@
124
151
  }
125
152
  },
126
153
  "engines": {
127
- "node": ">=20"
154
+ "node": ">=22"
128
155
  },
129
156
  "publishConfig": {
130
157
  "access": "public",
131
158
  "registry": "https://registry.npmjs.org/"
132
159
  },
160
+ "main": "./dist/index.cjs",
161
+ "module": "./dist/index.js",
133
162
  "scripts": {
134
163
  "build": "tsdown",
135
- "clean": "npx rimraf ./dist",
164
+ "clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
136
165
  "lint": "bun biome lint .",
137
166
  "lint:fix": "bun biome lint --fix --unsafe .",
138
167
  "release": "pnpm publish --no-git-check",
package/src/astro.ts CHANGED
@@ -1,13 +1,12 @@
1
- import unplugin from './index.ts'
2
-
3
1
  import type { Options } from './types.ts'
2
+ import vitePlugin from './vite.ts'
4
3
 
5
- export default (options: Options) => ({
6
- name: 'unplugin-starter',
4
+ export default (options: Options): any => ({
5
+ name: 'unplugin-kubb',
7
6
  hooks: {
8
7
  'astro:config:setup': async (astro: any) => {
9
8
  astro.config.vite.plugins ||= []
10
- astro.config.vite.plugins.push(unplugin.vite(options))
9
+ astro.config.vite.plugins.push(vitePlugin(options))
11
10
  },
12
11
  },
13
12
  })
package/src/esbuild.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createEsbuildPlugin } from 'unplugin'
2
2
 
3
- import { unpluginFactory } from './index.ts'
3
+ import { unpluginFactory } from './unpluginFactory.ts'
4
4
 
5
5
  export default createEsbuildPlugin(unpluginFactory)
package/src/farm.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { createFarmPlugin } from 'unplugin'
2
+
3
+ import { unpluginFactory } from './unpluginFactory.ts'
4
+
5
+ export default createFarmPlugin(unpluginFactory)
package/src/index.ts CHANGED
@@ -1,137 +1,9 @@
1
- import process from 'node:process'
2
- import { type Config, type KubbEvents, safeBuild } from '@kubb/core'
3
- import { AsyncEventEmitter } from '@kubb/core/utils'
4
- import type { UnpluginFactory } from 'unplugin'
5
1
  import { createUnplugin } from 'unplugin'
6
- import { version as unpluginVersion } from '../package.json'
7
- import type { Options } from './types.ts'
2
+ import { unpluginFactory } from './unpluginFactory.ts'
8
3
 
9
- type RollupContext = {
10
- info?: (message: string) => void
11
- warn?: (message: string) => void
12
- error?: (message: string) => void
13
- }
4
+ export type { Options } from './types.ts'
5
+ export { unpluginFactory } from './unpluginFactory.ts'
14
6
 
15
- export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {
16
- const name = 'unplugin-kubb' as const
17
- const events = new AsyncEventEmitter<KubbEvents>()
18
- const isVite = meta.framework === 'vite'
19
- const hrStart = process.hrtime()
7
+ const plugin = /* #__PURE__ */ createUnplugin(unpluginFactory)
20
8
 
21
- async function runBuild(ctx: RollupContext) {
22
- if (!options?.config) {
23
- if (ctx.error) {
24
- ctx.error?.(`[${name}] Config is not set`)
25
- } else {
26
- console.error(`[${name}] Config is not set`)
27
- }
28
- return
29
- }
30
-
31
- events.on('lifecycle:start', (version) => {
32
- console.log(`Kubb Unplugin ${version} 🧩`)
33
- })
34
-
35
- events.on('error', (error) => {
36
- console.error(`✗ ${error?.message || 'failed'}`)
37
- })
38
-
39
- events.on('warn', (message) => {
40
- console.warn(`⚠ ${message}`)
41
- })
42
-
43
- events.on('info', (message) => {
44
- console.info(`ℹ ${message}`)
45
- })
46
-
47
- events.on('success', (message) => {
48
- console.log(`✓ ${message}`)
49
- })
50
-
51
- events.on('plugin:end', (plugin, { duration }) => {
52
- const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`
53
-
54
- console.log(`✓ ${plugin.name} completed in ${durationStr}`)
55
- })
56
-
57
- events.on('files:processing:end', () => {
58
- const text = '✓ Files written successfully'
59
-
60
- console.log(text)
61
- })
62
-
63
- events.on('generation:end', (config) => {
64
- console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')
65
- })
66
-
67
- events.on('generation:summary', (config, { status, failedPlugins }) => {
68
- const pluginsCount = config.plugins?.length || 0
69
- const successCount = pluginsCount - failedPlugins.size
70
-
71
- console.log(
72
- status === 'success'
73
- ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`
74
- : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,
75
- )
76
- })
77
-
78
- await events.emit('lifecycle:start', unpluginVersion)
79
-
80
- const { root: _root, ...userConfig } = options.config as Config
81
-
82
- await events.emit('generation:start', options.config as Config)
83
-
84
- const { error, failedPlugins, pluginTimings, files } = await safeBuild({
85
- config: {
86
- root: process.cwd(),
87
- ...userConfig,
88
- output: {
89
- write: true,
90
- ...userConfig.output,
91
- },
92
- },
93
- events,
94
- })
95
-
96
- const hasFailures = failedPlugins.size > 0 || error
97
- if (hasFailures) {
98
- // Collect all errors from failed plugins and general error
99
- const allErrors: Error[] = [
100
- error,
101
- ...Array.from(failedPlugins)
102
- .filter((it) => it.error)
103
- .map((it) => it.error),
104
- ].filter(Boolean)
105
-
106
- allErrors.forEach((err) => {
107
- events.emit('error', err)
108
- })
109
- }
110
-
111
- await events.emit('generation:end', options.config as Config)
112
- await events.emit('generation:summary', options.config as Config, {
113
- failedPlugins,
114
- filesCreated: files.length,
115
- status: failedPlugins.size > 0 || error ? 'failed' : 'success',
116
- hrStart,
117
- pluginTimings,
118
- })
119
-
120
- await events.emit('lifecycle:end')
121
- }
122
-
123
- return {
124
- name,
125
- enforce: 'pre',
126
- apply: isVite ? 'build' : undefined,
127
- async buildStart() {
128
- await runBuild(this as unknown as RollupContext)
129
- },
130
-
131
- vite: {},
132
- }
133
- }
134
-
135
- export const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory)
136
-
137
- export default unplugin
9
+ export { plugin as unplugin, plugin as default }
package/src/nuxt.ts CHANGED
@@ -9,8 +9,8 @@ export interface ModuleOptions extends Options {}
9
9
 
10
10
  export default defineNuxtModule<ModuleOptions>({
11
11
  meta: {
12
- name: 'nuxt-unplugin-starter',
13
- configKey: 'unpluginStarter',
12
+ name: 'nuxt-unplugin-kubb',
13
+ configKey: 'unpluginKubb',
14
14
  },
15
15
  defaults: undefined,
16
16
  setup(options, _nuxt) {
@@ -0,0 +1,5 @@
1
+ import { createRolldownPlugin } from 'unplugin'
2
+
3
+ import { unpluginFactory } from './unpluginFactory.ts'
4
+
5
+ export default createRolldownPlugin(unpluginFactory)
package/src/rollup.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRollupPlugin } from 'unplugin'
2
2
 
3
- import { unpluginFactory } from './index.ts'
3
+ import { unpluginFactory } from './unpluginFactory.ts'
4
4
 
5
5
  export default createRollupPlugin(unpluginFactory)
package/src/rspack.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRspackPlugin } from 'unplugin'
2
2
 
3
- import { unpluginFactory } from './index.ts'
3
+ import { unpluginFactory } from './unpluginFactory.ts'
4
4
 
5
5
  export default createRspackPlugin(unpluginFactory)
package/src/types.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { UserConfig } from '@kubb/core'
1
+ import type { Config } from '@kubb/core'
2
2
 
3
3
  export type Options = {
4
4
  /**
5
5
  * Kubb config without the Hooks.
6
6
  */
7
- config?: Omit<UserConfig, 'hooks'>
7
+ config?: Omit<Config, 'hooks'>
8
8
  }
@@ -0,0 +1,140 @@
1
+ import process from 'node:process'
2
+ import { AsyncEventEmitter } from '@internals/utils'
3
+ import { adapterOas } from '@kubb/adapter-oas'
4
+ import { type Config, createKubb, type KubbHooks } from '@kubb/core'
5
+ import { parserTs } from '@kubb/parser-ts'
6
+ import type { UnpluginFactory } from 'unplugin'
7
+ import { version as unpluginVersion } from '../package.json'
8
+ import type { Options } from './types.ts'
9
+
10
+ type RollupContext = {
11
+ info?: (message: string) => void
12
+ warn?: (message: string) => void
13
+ error?: (message: string) => void
14
+ }
15
+
16
+ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {
17
+ const name = 'unplugin-kubb' as const
18
+ const hooks = new AsyncEventEmitter<KubbHooks>()
19
+ const isVite = meta.framework === 'vite'
20
+ const hrStart = process.hrtime()
21
+
22
+ async function runBuild(ctx: RollupContext) {
23
+ if (!options?.config) {
24
+ if (ctx.error) {
25
+ ctx.error?.(`[${name}] Config is not set`)
26
+ } else {
27
+ console.error(`[${name}] Config is not set`)
28
+ }
29
+ return
30
+ }
31
+
32
+ const config = {
33
+ ...options.config,
34
+ adapter: options.config.adapter ?? adapterOas(),
35
+ parsers: options.config.parsers?.length ? options.config.parsers : [parserTs],
36
+ }
37
+
38
+ hooks.on('kubb:lifecycle:start', (version) => {
39
+ console.log(`Kubb Unplugin ${version} 🧩`)
40
+ })
41
+
42
+ hooks.on('kubb:error', (error) => {
43
+ console.error(`✗ ${error?.message || 'failed'}`)
44
+ })
45
+
46
+ hooks.on('kubb:warn', (message) => {
47
+ console.warn(`⚠ ${message}`)
48
+ })
49
+
50
+ hooks.on('kubb:info', (message) => {
51
+ console.info(`ℹ ${message}`)
52
+ })
53
+
54
+ hooks.on('kubb:success', (message) => {
55
+ console.log(`✓ ${message}`)
56
+ })
57
+
58
+ hooks.on('kubb:plugin:end', (plugin, { duration }) => {
59
+ const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`
60
+
61
+ console.log(`✓ ${plugin.name} completed in ${durationStr}`)
62
+ })
63
+
64
+ hooks.on('kubb:files:processing:end', () => {
65
+ const text = '✓ Files written successfully'
66
+
67
+ console.log(text)
68
+ })
69
+
70
+ hooks.on('kubb:generation:end', (config) => {
71
+ console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')
72
+ })
73
+
74
+ hooks.on('kubb:generation:summary', (config, { status, failedPlugins }) => {
75
+ const pluginsCount = config.plugins.length
76
+ const successCount = pluginsCount - failedPlugins.size
77
+
78
+ console.log(
79
+ status === 'success'
80
+ ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`
81
+ : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,
82
+ )
83
+ })
84
+
85
+ await hooks.emit('kubb:lifecycle:start', unpluginVersion)
86
+
87
+ const { root: _root, ...userConfig } = config as Config
88
+
89
+ await hooks.emit('kubb:generation:start', config as Config)
90
+
91
+ const { error, failedPlugins, pluginTimings, files, sources } = await createKubb({
92
+ config: {
93
+ root: process.cwd(),
94
+ ...userConfig,
95
+ output: {
96
+ write: true,
97
+ ...userConfig.output,
98
+ },
99
+ },
100
+ hooks,
101
+ }).safeBuild()
102
+
103
+ const hasFailures = failedPlugins.size > 0 || error
104
+ if (hasFailures) {
105
+ // Collect all errors from failed plugins and general error
106
+ const allErrors: Error[] = [
107
+ error,
108
+ ...Array.from(failedPlugins)
109
+ .filter((it) => it.error)
110
+ .map((it) => it.error),
111
+ ].filter(Boolean)
112
+
113
+ allErrors.forEach((err) => {
114
+ hooks.emit('kubb:error', err)
115
+ })
116
+ }
117
+
118
+ await hooks.emit('kubb:generation:end', config as Config, files, sources)
119
+ await hooks.emit('kubb:generation:summary', config as Config, {
120
+ failedPlugins,
121
+ filesCreated: files.length,
122
+ status: failedPlugins.size > 0 || error ? 'failed' : 'success',
123
+ hrStart,
124
+ pluginTimings,
125
+ })
126
+
127
+ await hooks.emit('kubb:lifecycle:end')
128
+ }
129
+
130
+ return {
131
+ name,
132
+ enforce: 'pre',
133
+ apply: isVite ? 'build' : undefined,
134
+ async buildStart() {
135
+ await runBuild(this as unknown as RollupContext)
136
+ },
137
+
138
+ vite: {},
139
+ }
140
+ }
package/src/vite.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createVitePlugin } from 'unplugin'
2
2
 
3
- import { unpluginFactory } from './index.ts'
3
+ import { unpluginFactory } from './unpluginFactory.ts'
4
4
 
5
5
  export default createVitePlugin(unpluginFactory)
package/src/webpack.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import type { UnpluginFactoryOutput } from 'unplugin'
2
2
  import { createWebpackPlugin } from 'unplugin'
3
3
  import type { WebpackPluginInstance } from 'webpack'
4
- import { unpluginFactory } from './index.ts'
5
4
  import type { Options } from './types.ts'
5
+ import { unpluginFactory } from './unpluginFactory.ts'
6
6
 
7
- // resolves issue for: The inferred type of 'default' cannot be named without a reference to 'node_modules/webpack'. This is likely not portable. A type annotation is necessary.
8
7
  export default createWebpackPlugin(unpluginFactory) as unknown as UnpluginFactoryOutput<Options, WebpackPluginInstance>
package/dist/astro.d.cts DELETED
@@ -1,11 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
-
3
- //#region src/astro.d.ts
4
- declare const _default: (options: Options) => {
5
- name: string;
6
- hooks: {
7
- 'astro:config:setup': (astro: any) => Promise<void>;
8
- };
9
- };
10
- export = _default;
11
- //# sourceMappingURL=astro.d.cts.map
@@ -1,7 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as esbuild0 from "esbuild";
3
-
4
- //#region src/esbuild.d.ts
5
- declare const _default: (options?: Options | undefined) => esbuild0.Plugin;
6
- export = _default;
7
- //# sourceMappingURL=esbuild.d.cts.map
package/dist/index.d.cts DELETED
@@ -1,10 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as unplugin0 from "unplugin";
3
- import { UnpluginFactory } from "unplugin";
4
-
5
- //#region src/index.d.ts
6
- declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
- declare const unplugin: unplugin0.UnpluginInstance<Options | undefined, boolean>;
8
- //#endregion
9
- export { unplugin as default, unplugin, unpluginFactory };
10
- //# sourceMappingURL=index.d.cts.map
package/dist/nuxt.d.cts DELETED
@@ -1,9 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as _nuxt_schema0 from "@nuxt/schema";
3
-
4
- //#region src/nuxt.d.ts
5
- interface ModuleOptions extends Options {}
6
- declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
- //#endregion
8
- export { ModuleOptions, _default as default };
9
- //# sourceMappingURL=nuxt.d.cts.map
package/dist/rollup.d.cts DELETED
@@ -1,7 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as rollup0 from "rollup";
3
-
4
- //#region src/rollup.d.ts
5
- declare const _default: (options?: Options | undefined) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
6
- export = _default;
7
- //# sourceMappingURL=rollup.d.cts.map
package/dist/rspack.d.cts DELETED
@@ -1,6 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
-
3
- //#region src/rspack.d.ts
4
- declare const _default: (options?: Options | undefined) => RspackPluginInstance;
5
- export = _default;
6
- //# sourceMappingURL=rspack.d.cts.map