@stacksjs/dtsx
Version:
A modern, fast .d.ts generation tool, powered by Bun.
64 lines (63 loc) • 1.54 kB
TypeScript
import type { DtsGenerationConfig, GenerationStats } from '../types';
/**
* Create an esbuild plugin for dtsx
*
* @example
* ```ts
* // build.ts
* import { dtsx } from '@stacksjs/dtsx/plugins/esbuild'
* import * as esbuild from 'esbuild'
*
* await esbuild.build({
* entryPoints: ['./src/index.ts'],
* outdir: './dist',
* plugins: [
* dtsx({
* root: './src',
* outdir: './dist',
* }),
* ],
* })
* ```
*/
export declare function dtsx(options?: EsbuildPluginOptions): EsbuildPlugin;
/**
* Alias for dtsx
*/
export declare const esbuildDts: typeof dtsx;
/**
* Alias matching common naming convention
*/
export declare const dts: typeof dtsx;
/**
* esbuild plugin options
*/
export declare interface EsbuildPluginOptions extends Partial<DtsGenerationConfig> {
onStart?: boolean
onEnd?: boolean
onGenerated?: (stats: GenerationStats) => void
onError?: (error: Error) => void
}
/**
* esbuild plugin interface
*/
declare interface EsbuildPlugin {
name: string
setup: (build: EsbuildBuild) => void | Promise<void>
}
/**
* esbuild build interface (minimal type)
*/
declare interface EsbuildBuild {
onStart: (callback: () => { errors?: Array<{ text: string }> } | Promise<{ errors?: Array<{ text: string }> } | void> | void) => void
onEnd: (callback: (result: { errors: unknown[] }) => void | Promise<void>) => void
initialOptions: {
entryPoints?: string[] | Record<string, string>
outdir?: string
outfile?: string
}
}
/**
* Default export
*/
export default dtsx;