unplugin-kubb 4.0.2 → 5.0.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/LICENSE +10 -17
- package/dist/astro.cjs +7 -8
- package/dist/astro.cjs.map +1 -1
- package/dist/astro.d.ts +3 -8
- package/dist/astro.js +7 -9
- package/dist/astro.js.map +1 -1
- package/dist/{chunk-CIm-hhu7.js → chunk--u3MIqq1.js} +2 -3
- package/dist/esbuild.cjs +3 -5
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.d.ts +4 -4
- package/dist/esbuild.js +2 -3
- package/dist/esbuild.js.map +1 -1
- package/dist/farm.cjs +7 -0
- package/dist/farm.cjs.map +1 -0
- package/dist/farm.d.ts +9 -0
- package/dist/farm.js +8 -0
- package/dist/farm.js.map +1 -0
- package/dist/index.cjs +12 -5
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -7
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -0
- package/dist/nuxt.cjs +8 -9
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.ts +2 -2
- package/dist/nuxt.js +4 -5
- package/dist/nuxt.js.map +1 -1
- package/dist/rolldown.cjs +7 -0
- package/dist/rolldown.cjs.map +1 -0
- package/dist/rolldown.d.ts +9 -0
- package/dist/rolldown.js +8 -0
- package/dist/rolldown.js.map +1 -0
- package/dist/rollup.cjs +3 -5
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.ts +4 -4
- package/dist/rollup.js +2 -3
- package/dist/rollup.js.map +1 -1
- package/dist/rspack.cjs +3 -5
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.d.ts +2 -2
- package/dist/rspack.js +2 -3
- package/dist/rspack.js.map +1 -1
- package/dist/types.d.ts +13 -2
- package/dist/types.js +1 -1
- package/dist/unpluginFactory-0sYXb5x6.js +157 -0
- package/dist/unpluginFactory-0sYXb5x6.js.map +1 -0
- package/dist/unpluginFactory-BpZ2psBF.cjs +200 -0
- package/dist/unpluginFactory-BpZ2psBF.cjs.map +1 -0
- package/dist/unpluginFactory.cjs +3 -0
- package/dist/unpluginFactory.d.ts +9 -0
- package/dist/unpluginFactory.js +2 -0
- package/dist/vite.cjs +3 -5
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +4 -4
- package/dist/vite.js +2 -3
- package/dist/vite.js.map +1 -1
- package/dist/webpack.cjs +3 -5
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.d.ts +2 -2
- package/dist/webpack.js +2 -3
- package/dist/webpack.js.map +1 -1
- package/package.json +69 -42
- package/src/astro.ts +4 -5
- package/src/esbuild.ts +1 -1
- package/src/farm.ts +5 -0
- package/src/index.ts +6 -133
- package/src/nuxt.ts +2 -2
- package/src/rolldown.ts +5 -0
- package/src/rollup.ts +1 -1
- package/src/rspack.ts +1 -1
- package/src/unpluginFactory.ts +132 -0
- package/src/vite.ts +1 -1
- package/src/webpack.ts +1 -2
- package/dist/astro.d.cts +0 -11
- package/dist/esbuild.d.cts +0 -7
- package/dist/index.d.cts +0 -10
- package/dist/nuxt.d.cts +0 -9
- package/dist/rollup.d.cts +0 -7
- package/dist/rspack.d.cts +0 -6
- package/dist/src-BiN2tznZ.cjs +0 -155
- package/dist/src-BiN2tznZ.cjs.map +0 -1
- package/dist/src-CiUcBKSs.js +0 -95
- package/dist/src-CiUcBKSs.js.map +0 -1
- package/dist/types-C-ZTDGdJ.d.cts +0 -650
- package/dist/types-CUVJ-CBJ.d.ts +0 -649
- package/dist/types.d.cts +0 -2
- package/dist/vite.d.cts +0 -7
- package/dist/webpack.d.cts +0 -8
package/package.json
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-kubb",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.0.1",
|
|
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
|
-
"
|
|
11
|
-
"astro",
|
|
12
|
-
"kubb",
|
|
13
|
-
"swagger",
|
|
14
|
-
"OpenAPI",
|
|
10
|
+
"esbuild",
|
|
15
11
|
"rspack",
|
|
16
12
|
"nuxt",
|
|
17
|
-
"
|
|
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
|
-
"
|
|
31
|
-
"
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
32
36
|
},
|
|
33
37
|
"./astro": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
38
|
+
"import": "./dist/astro.js",
|
|
39
|
+
"require": "./dist/astro.cjs"
|
|
36
40
|
},
|
|
37
41
|
"./esbuild": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
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
|
-
"
|
|
43
|
-
"
|
|
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
|
-
"
|
|
47
|
-
"
|
|
58
|
+
"import": "./dist/rollup.js",
|
|
59
|
+
"require": "./dist/rollup.cjs"
|
|
48
60
|
},
|
|
49
61
|
"./rspack": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
62
|
+
"import": "./dist/rspack.js",
|
|
63
|
+
"require": "./dist/rspack.cjs"
|
|
52
64
|
},
|
|
53
65
|
"./types": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
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
|
-
"
|
|
59
|
-
"
|
|
74
|
+
"import": "./dist/vite.js",
|
|
75
|
+
"require": "./dist/vite.cjs"
|
|
60
76
|
},
|
|
61
77
|
"./webpack": {
|
|
62
|
-
"
|
|
63
|
-
"
|
|
78
|
+
"import": "./dist/webpack.js",
|
|
79
|
+
"require": "./dist/webpack.cjs"
|
|
64
80
|
},
|
|
65
81
|
"./package.json": "./package.json"
|
|
66
82
|
},
|
|
67
|
-
"
|
|
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,39 @@
|
|
|
79
93
|
"src",
|
|
80
94
|
"dist",
|
|
81
95
|
"!/**/**.test.**",
|
|
82
|
-
"!/**/__tests__/**"
|
|
96
|
+
"!/**/__tests__/**",
|
|
97
|
+
"!/**/__snapshots__/**"
|
|
83
98
|
],
|
|
84
99
|
"dependencies": {
|
|
85
|
-
"unplugin": "^
|
|
100
|
+
"unplugin": "^3.0.0",
|
|
101
|
+
"@kubb/core": "4.33.4"
|
|
86
102
|
},
|
|
87
103
|
"devDependencies": {
|
|
88
|
-
"@
|
|
89
|
-
"@nuxt/
|
|
104
|
+
"@farmfe/core": "^1.7.11",
|
|
105
|
+
"@nuxt/kit": "^4.4.2",
|
|
106
|
+
"@nuxt/schema": "^4.4.2",
|
|
90
107
|
"esbuild": "*",
|
|
91
|
-
"
|
|
92
|
-
"rollup": "^4.
|
|
108
|
+
"rolldown": "~1.0.0-rc.9",
|
|
109
|
+
"rollup": "^4.59.0",
|
|
93
110
|
"vite": "^7.3.1",
|
|
94
|
-
"webpack": "^5.
|
|
95
|
-
"@
|
|
111
|
+
"webpack": "^5.105.4",
|
|
112
|
+
"@internals/utils": "0.0.0"
|
|
96
113
|
},
|
|
97
114
|
"peerDependencies": {
|
|
115
|
+
"@farmfe/core": "^1.7.0",
|
|
98
116
|
"@kubb/core": "^4.0.0",
|
|
99
|
-
"@nuxt/kit": "^3",
|
|
100
|
-
"@nuxt/schema": "^3",
|
|
117
|
+
"@nuxt/kit": "^3 || ^4",
|
|
118
|
+
"@nuxt/schema": "^3 || ^4",
|
|
101
119
|
"esbuild": "*",
|
|
102
|
-
"
|
|
120
|
+
"rolldown": ">=1",
|
|
121
|
+
"rollup": "^3 || ^4",
|
|
103
122
|
"vite": ">=3",
|
|
104
123
|
"webpack": "^5"
|
|
105
124
|
},
|
|
106
125
|
"peerDependenciesMeta": {
|
|
126
|
+
"@farmfe/core": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
107
129
|
"@nuxt/kit": {
|
|
108
130
|
"optional": true
|
|
109
131
|
},
|
|
@@ -113,6 +135,9 @@
|
|
|
113
135
|
"esbuild": {
|
|
114
136
|
"optional": true
|
|
115
137
|
},
|
|
138
|
+
"rolldown": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
116
141
|
"rollup": {
|
|
117
142
|
"optional": true
|
|
118
143
|
},
|
|
@@ -130,9 +155,11 @@
|
|
|
130
155
|
"access": "public",
|
|
131
156
|
"registry": "https://registry.npmjs.org/"
|
|
132
157
|
},
|
|
158
|
+
"main": "./dist/index.cjs",
|
|
159
|
+
"module": "./dist/index.js",
|
|
133
160
|
"scripts": {
|
|
134
161
|
"build": "tsdown",
|
|
135
|
-
"clean": "
|
|
162
|
+
"clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
|
|
136
163
|
"lint": "bun biome lint .",
|
|
137
164
|
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
138
165
|
"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-
|
|
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(
|
|
9
|
+
astro.config.vite.plugins.push(vitePlugin(options))
|
|
11
10
|
},
|
|
12
11
|
},
|
|
13
12
|
})
|
package/src/esbuild.ts
CHANGED
package/src/farm.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -1,137 +1,10 @@
|
|
|
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 {
|
|
7
|
-
import type { Options } from './types.ts'
|
|
2
|
+
import { unpluginFactory } from './unpluginFactory.ts'
|
|
8
3
|
|
|
9
|
-
type
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
22
|
-
|
|
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 }
|
|
10
|
+
export { 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-
|
|
13
|
-
configKey: '
|
|
12
|
+
name: 'nuxt-unplugin-kubb',
|
|
13
|
+
configKey: 'unpluginKubb',
|
|
14
14
|
},
|
|
15
15
|
defaults: undefined,
|
|
16
16
|
setup(options, _nuxt) {
|
package/src/rolldown.ts
ADDED
package/src/rollup.ts
CHANGED
package/src/rspack.ts
CHANGED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { AsyncEventEmitter } from '@internals/utils'
|
|
3
|
+
import { type Config, type KubbEvents, safeBuild } from '@kubb/core'
|
|
4
|
+
import type { UnpluginFactory } from 'unplugin'
|
|
5
|
+
import { version as unpluginVersion } from '../package.json'
|
|
6
|
+
import type { Options } from './types.ts'
|
|
7
|
+
|
|
8
|
+
type RollupContext = {
|
|
9
|
+
info?: (message: string) => void
|
|
10
|
+
warn?: (message: string) => void
|
|
11
|
+
error?: (message: string) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {
|
|
15
|
+
const name = 'unplugin-kubb' as const
|
|
16
|
+
const events = new AsyncEventEmitter<KubbEvents>()
|
|
17
|
+
const isVite = meta.framework === 'vite'
|
|
18
|
+
const hrStart = process.hrtime()
|
|
19
|
+
|
|
20
|
+
async function runBuild(ctx: RollupContext) {
|
|
21
|
+
if (!options?.config) {
|
|
22
|
+
if (ctx.error) {
|
|
23
|
+
ctx.error?.(`[${name}] Config is not set`)
|
|
24
|
+
} else {
|
|
25
|
+
console.error(`[${name}] Config is not set`)
|
|
26
|
+
}
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
events.on('lifecycle:start', (version) => {
|
|
31
|
+
console.log(`Kubb Unplugin ${version} 🧩`)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
events.on('error', (error) => {
|
|
35
|
+
console.error(`✗ ${error?.message || 'failed'}`)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
events.on('warn', (message) => {
|
|
39
|
+
console.warn(`⚠ ${message}`)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
events.on('info', (message) => {
|
|
43
|
+
console.info(`ℹ ${message}`)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
events.on('success', (message) => {
|
|
47
|
+
console.log(`✓ ${message}`)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
events.on('plugin:end', (plugin, { duration }) => {
|
|
51
|
+
const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`
|
|
52
|
+
|
|
53
|
+
console.log(`✓ ${plugin.name} completed in ${durationStr}`)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
events.on('files:processing:end', () => {
|
|
57
|
+
const text = '✓ Files written successfully'
|
|
58
|
+
|
|
59
|
+
console.log(text)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
events.on('generation:end', (config) => {
|
|
63
|
+
console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
events.on('generation:summary', (config, { status, failedPlugins }) => {
|
|
67
|
+
const pluginsCount = config.plugins?.length || 0
|
|
68
|
+
const successCount = pluginsCount - failedPlugins.size
|
|
69
|
+
|
|
70
|
+
console.log(
|
|
71
|
+
status === 'success'
|
|
72
|
+
? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`
|
|
73
|
+
: `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
await events.emit('lifecycle:start', unpluginVersion)
|
|
78
|
+
|
|
79
|
+
const { root: _root, ...userConfig } = options.config as Config
|
|
80
|
+
|
|
81
|
+
await events.emit('generation:start', options.config as Config)
|
|
82
|
+
|
|
83
|
+
const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({
|
|
84
|
+
config: {
|
|
85
|
+
root: process.cwd(),
|
|
86
|
+
...userConfig,
|
|
87
|
+
output: {
|
|
88
|
+
write: true,
|
|
89
|
+
...userConfig.output,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
events,
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const hasFailures = failedPlugins.size > 0 || error
|
|
96
|
+
if (hasFailures) {
|
|
97
|
+
// Collect all errors from failed plugins and general error
|
|
98
|
+
const allErrors: Error[] = [
|
|
99
|
+
error,
|
|
100
|
+
...Array.from(failedPlugins)
|
|
101
|
+
.filter((it) => it.error)
|
|
102
|
+
.map((it) => it.error),
|
|
103
|
+
].filter(Boolean)
|
|
104
|
+
|
|
105
|
+
allErrors.forEach((err) => {
|
|
106
|
+
events.emit('error', err)
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await events.emit('generation:end', options.config as Config, files, sources)
|
|
111
|
+
await events.emit('generation:summary', options.config as Config, {
|
|
112
|
+
failedPlugins,
|
|
113
|
+
filesCreated: files.length,
|
|
114
|
+
status: failedPlugins.size > 0 || error ? 'failed' : 'success',
|
|
115
|
+
hrStart,
|
|
116
|
+
pluginTimings,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
await events.emit('lifecycle:end')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
name,
|
|
124
|
+
enforce: 'pre',
|
|
125
|
+
apply: isVite ? 'build' : undefined,
|
|
126
|
+
async buildStart() {
|
|
127
|
+
await runBuild(this as unknown as RollupContext)
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
vite: {},
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/vite.ts
CHANGED
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
|
package/dist/esbuild.d.cts
DELETED
|
@@ -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