diff --git a/.changeset/little-walls-drop.md b/.changeset/little-walls-drop.md
new file mode 100644
index 000000000..d039f9237
--- /dev/null
+++ b/.changeset/little-walls-drop.md
@@ -0,0 +1,6 @@
+---
+"@kubb/core": patch
+"@kubb/cli": patch
+---
+
+full support for Bun v1.1.0
diff --git a/docs/guide/cli.md b/docs/guide/cli.md
index 898dcd5cc..02cbd98d4 100644
--- a/docs/guide/cli.md
+++ b/docs/guide/cli.md
@@ -31,9 +31,16 @@ yarn add @kubb/cli
## Usage
-```sh
+::: code-group
+
+```shell [bun ]
+kubb --bun --config kubb.config.js
+bkubb --config kubb.config.js
+```
+```sh [node]
kubb --config kubb.config.js
```
+:::
```mdx
kubb/2.0.0
@@ -73,6 +80,7 @@ Options:
-l, --log-level Info, silent or debug
-w, --watch Watch mode based on the input file
-h, --help Display this message
+ -b, --bun Run Kubb with Bun
```
Path of the input file(overrides the one in `kubb.config.js`)
diff --git a/docs/plugins/cli/index.md b/docs/plugins/cli/index.md
index 9ac9854b6..01c4df06d 100644
--- a/docs/plugins/cli/index.md
+++ b/docs/plugins/cli/index.md
@@ -31,9 +31,16 @@ yarn add @kubb/cli
## Usage
-```sh
+::: code-group
+
+```shell [bun ]
+kubb --bun --config kubb.config.js
+bkubb --config kubb.config.js
+```
+```sh [node]
kubb --config kubb.config.js
```
+:::
```mdx
kubb/1.2.1
@@ -73,6 +80,7 @@ Options:
-l, --log-level Info, silent or debug
-w, --watch Watch mode based on the input file
-h, --help Display this message
+ -b, --bun Run Kubb with Bun
```
Path of the input file(overrides the one in `kubb.config.js`)
diff --git a/examples/advanced/package.json b/examples/advanced/package.json
index 950722958..334633aa9 100644
--- a/examples/advanced/package.json
+++ b/examples/advanced/package.json
@@ -15,7 +15,7 @@
"build": "tsup",
"clean": "npx rimraf ./dist",
"generate": "kubb generate",
- "generate:bun": "bun ./node_modules/@kubb/cli/bin/kubb.js generate --config .kubbrc.js",
+ "generate:bun": "kubb generate --bun",
"generate:js": "kubb generate --config .kubbrc.js",
"generate:json": "kubb generate --config kubb.json",
"generate:ts": "kubb generate --config configs/kubb.config.ts",
diff --git a/packages/cli/bin/bkubb.cjs b/packages/cli/bin/bkubb.cjs
new file mode 100755
index 000000000..e588c6379
--- /dev/null
+++ b/packages/cli/bin/bkubb.cjs
@@ -0,0 +1,6 @@
+#!/usr/bin/env bun
+
+import('../dist/index.js').then(({ run }) => {
+ process.title = 'Kubb'
+ run(process.argv)
+})
diff --git a/packages/cli/bin/kubb.cjs b/packages/cli/bin/kubb.cjs
index f0a5b5376..ec2f9390f 100755
--- a/packages/cli/bin/kubb.cjs
+++ b/packages/cli/bin/kubb.cjs
@@ -1,8 +1,14 @@
#!/usr/bin/env node
try {
+ const cachedSourceMaps = new Map()
+
require('source-map-support').install({
- environment: 'node',
- handleUncaughtExceptions: false,
+ retrieveSourceMap(source) {
+ if (cachedSourceMaps.has(source)) {
+ return cachedSourceMaps.get(source)
+ }
+ return null
+ },
})
} catch (err) {}
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 074e3df78..9e1e8ce38 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -23,7 +23,8 @@
}
},
"bin": {
- "kubb": "bin/kubb.cjs"
+ "kubb": "bin/kubb.cjs",
+ "bkubb": "bin/bkubb.cjs"
},
"files": ["src", "dist", "bin", "!/**/**.test.**", "!/**/__tests__/**"],
"scripts": {
@@ -40,6 +41,7 @@
"dependencies": {
"@kubb/core": "workspace:*",
"bundle-require": "^4.0.2",
+ "js-runtime": "^0.0.7",
"cac": "^6.7.14",
"chokidar": "^3.6.0",
"cosmiconfig": "^9.0.0",
diff --git a/packages/cli/src/generate.ts b/packages/cli/src/generate.ts
index 10d80789b..eed7ed63c 100644
--- a/packages/cli/src/generate.ts
+++ b/packages/cli/src/generate.ts
@@ -1,17 +1,16 @@
-import { safeBuild } from '@kubb/core'
import { LogLevel, createLogger, randomCliColour } from '@kubb/core/logger'
import { execa } from 'execa'
+import { get } from 'js-runtime'
import { parseArgsStringToArgv } from 'string-argv'
import c from 'tinyrainbow'
import { OraWritable } from './utils/OraWritable.ts'
-import { getSummary } from './utils/getSummary.ts'
import { spinner } from './utils/spinner.ts'
import type { Writable } from 'node:stream'
-import type { CLIOptions, Config } from '@kubb/core'
-import type { ExecaReturnValue } from 'execa'
+import { type CLIOptions, type Config, safeBuild } from '@kubb/core'
+import { getSummary } from './utils/getSummary.ts'
type GenerateProps = {
input?: string
@@ -24,11 +23,6 @@ type ExecutingHooksProps = {
logLevel: LogLevel
}
-type Executer = {
- subProcess: ExecaReturnValue
- abort: AbortController['abort']
-}
-
async function executeHooks({ hooks, logLevel }: ExecutingHooksProps): Promise {
if (!hooks?.done) {
return
@@ -109,7 +103,7 @@ export async function generate({ input, config, CLIOptions }: GenerateProps): Pr
const logLevel = logger.logLevel
const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)
- spinner.start(`🚀 Building ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
+ spinner.start(`🚀 Building with ${get()} ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
const definedConfig: Config = {
root: process.cwd(),
@@ -150,7 +144,7 @@ export async function generate({ input, config, CLIOptions }: GenerateProps): Pr
await executeHooks({ hooks: config.hooks, logLevel })
spinner.suffixText = ''
- spinner.succeed(`🚀 Build completed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
+ spinner.succeed(`🚀 Build completed with ${get()} ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
console.log(summary.join(''))
}
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index b44f636df..259e0c15d 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -15,6 +15,8 @@ import { spinner } from './utils/spinner.ts'
import { startWatcher } from './utils/watcher.ts'
import type { CLIOptions } from '@kubb/core'
+import { execa } from 'execa'
+import { OraWritable } from './utils/OraWritable.ts'
const moduleName = 'kubb'
@@ -31,6 +33,13 @@ function programCatcher(e: unknown, CLIOptions: CLIOptions): void {
}
async function generateAction(input: string, CLIOptions: CLIOptions) {
+ if (CLIOptions.bun) {
+ const command = process.argv.splice(2).filter((item) => item !== '--bun')
+
+ await execa('bkubb', command, { stdout: process.stdout, stderr: process.stderr })
+ return
+ }
+
spinner.start('🔍 Loading config')
const result = await getCosmiConfig(moduleName, CLIOptions.config)
spinner.succeed(`🔍 Config loaded(${c.dim(path.relative(process.cwd(), result.filepath))})`)
@@ -71,6 +80,7 @@ export async function run(argv?: string[]): Promise {
.option('-c, --config ', 'Path to the Kubb config')
.option('-l, --log-level ', 'Info, silent or debug')
.option('-w, --watch', 'Watch mode based on the input file')
+ .option('-b, --bun', 'Run Kubb with Bun')
.action(generateAction)
program
@@ -78,6 +88,7 @@ export async function run(argv?: string[]): Promise {
.option('-c, --config ', 'Path to the Kubb config')
.option('-l, --log-level ', 'Info, silent or debug')
.option('-w, --watch', 'Watch mode based on the input file')
+ .option('-b, --bun', 'Run Kubb with Bun')
.action(generateAction)
program.command('init', 'Init Kubb').action(async () => {
diff --git a/packages/cli/src/utils/getSummary.ts b/packages/cli/src/utils/getSummary.ts
index b3c78e65e..084da986d 100644
--- a/packages/cli/src/utils/getSummary.ts
+++ b/packages/cli/src/utils/getSummary.ts
@@ -1,6 +1,6 @@
import path from 'node:path'
-import { LogLevel, randomCliColour } from '@kubb/core/logger'
+import { randomCliColour } from '@kubb/core/logger'
import c from 'tinyrainbow'
diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts
index 9c9b58555..a07ac0b52 100644
--- a/packages/core/src/types.ts
+++ b/packages/core/src/types.ts
@@ -117,6 +117,10 @@ export type CLIOptions = {
* @default `silent`
*/
logLevel?: LogLevel
+ /**
+ * Run Kubb with Bun
+ */
+ bun?: boolean
}
// plugin
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f0bf3abd4..1d78bd815 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -996,6 +996,9 @@ importers:
execa:
specifier: ^8.0.1
version: 8.0.1
+ js-runtime:
+ specifier: ^0.0.7
+ version: 0.0.7
ora:
specifier: ^8.0.1
version: 8.0.1