diff --git a/packages/plugin-dts/src/dts.ts b/packages/plugin-dts/src/dts.ts index 8b6100ccc..7ccc5aa05 100644 --- a/packages/plugin-dts/src/dts.ts +++ b/packages/plugin-dts/src/dts.ts @@ -6,7 +6,7 @@ import { emitDts } from './tsc'; import { ensureTempDeclarationDir, loadTsconfig } from './utils'; export async function generateDts(data: DtsGenOptions) { - logger.info('Generating DTS...'); + logger.start('Generating DTS...'); const { options: pluginOptions, cwd, isWatch } = data; const { tsconfigPath, distPath, bundle, entryPath } = pluginOptions; const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, tsconfigPath); diff --git a/packages/plugin-dts/src/tsc.ts b/packages/plugin-dts/src/tsc.ts index fc718e4ed..289da7b50 100644 --- a/packages/plugin-dts/src/tsc.ts +++ b/packages/plugin-dts/src/tsc.ts @@ -14,6 +14,10 @@ export function emitDts( onComplete: (isSuccess: boolean) => void, isWatch = false, ) { + const start = Date.now(); + const getTimeCost = () => { + return `${Math.floor(Date.now() - start)}ms`; + }; const { configPath, declarationDir } = options; const { options: rawCompilerOptions, fileNames } = loadTsconfig(configPath); @@ -58,10 +62,10 @@ export function emitDts( logger.error(message); } - throw new Error('TypeScript compilation failed'); + throw new Error('DTS generation failed'); } - logger.info('TypeScript compilation succeeded\n'); + logger.info(`DTS generation succeeded in ${getTimeCost()}`); } else { const createProgram = ts.createSemanticDiagnosticsBuilderProgram; const formatHost: ts.FormatDiagnosticsHost = {