UNPKG

rsbuild-plugin-dts

Version:

Rsbuild plugin that supports emitting declaration files for TypeScript.

53 lines (52 loc) 1.77 kB
import { type LogLevel, type RsbuildConfig, type RsbuildPlugin } from '@rsbuild/core'; import { type DtsGenerationBackend } from './backend.js'; import { type CompilerApiTsconfigResultForApi, type GetTsconfigTsconfigResultForExecutable } from './utils.js'; export type DtsRedirect = { path?: boolean; extension?: boolean; }; export type ApiExtractorOptions = { bundledPackages?: string[]; }; export type PluginDtsOptions = { bundle?: boolean | ApiExtractorOptions; distPath?: string; build?: boolean; abortOnError?: boolean; dtsExtension?: string; alias?: Record<string, string>; isolated?: boolean; autoExternal?: boolean | { dependencies?: boolean; optionalDependencies?: boolean; peerDependencies?: boolean; devDependencies?: boolean; }; banner?: string; footer?: string; redirect?: DtsRedirect; tsgo?: boolean; }; export type DtsEntry = { name: string; path: string; }; export type DtsGenOptions = Omit<PluginDtsOptions, 'bundle' | 'isolated' | 'tsgo'> & { bundle: boolean; name: string; cwd: string; isWatch: boolean; dtsEntry: DtsEntry[]; dtsEmitPath: string; build?: boolean; tsconfigPath: string; tsConfigResult: CompilerApiTsconfigResultForApi | GetTsconfigTsconfigResultForExecutable; userExternals?: NonNullable<RsbuildConfig['output']>['externals']; apiExtractorOptions?: ApiExtractorOptions; loggerLevel: LogLevel; dtsBackend: DtsGenerationBackend; }; export declare const PLUGIN_DTS_NAME = 'rsbuild:dts'; // use ts compiler API to generate bundleless dts // use ts compiler API and api-extractor to generate dts bundle export declare const pluginDts: (options?: PluginDtsOptions) => RsbuildPlugin;