Skip to content

Commit f008641

Browse files
authored
feat: print DTS generation time (#58)
1 parent 17ad185 commit f008641

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/plugin-dts/src/dts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { emitDts } from './tsc';
66
import { ensureTempDeclarationDir, loadTsconfig } from './utils';
77

88
export async function generateDts(data: DtsGenOptions) {
9-
logger.info('Generating DTS...');
9+
logger.start('Generating DTS...');
1010
const { options: pluginOptions, cwd, isWatch } = data;
1111
const { tsconfigPath, distPath, bundle, entryPath } = pluginOptions;
1212
const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, tsconfigPath);

packages/plugin-dts/src/tsc.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export function emitDts(
1414
onComplete: (isSuccess: boolean) => void,
1515
isWatch = false,
1616
) {
17+
const start = Date.now();
18+
const getTimeCost = () => {
19+
return `${Math.floor(Date.now() - start)}ms`;
20+
};
1721
const { configPath, declarationDir } = options;
1822
const { options: rawCompilerOptions, fileNames } = loadTsconfig(configPath);
1923

@@ -58,10 +62,10 @@ export function emitDts(
5862
logger.error(message);
5963
}
6064

61-
throw new Error('TypeScript compilation failed');
65+
throw new Error('DTS generation failed');
6266
}
6367

64-
logger.info('TypeScript compilation succeeded\n');
68+
logger.info(`DTS generation succeeded in ${getTimeCost()}`);
6569
} else {
6670
const createProgram = ts.createSemanticDiagnosticsBuilderProgram;
6771
const formatHost: ts.FormatDiagnosticsHost = {

0 commit comments

Comments
 (0)