Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: print DTS generation time #58

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/plugin-dts/src/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { emitDts } from './tsc';
import { ensureTempDeclarationDir, loadTsconfig } from './utils';

export async function generateDts(data: DtsGenOptions) {
logger.info('Generating DTS...');
logger.ready('Generating DTS...');
Timeless0911 marked this conversation as resolved.
Show resolved Hide resolved
const { options: pluginOptions, cwd, isWatch } = data;
const { tsconfigPath, distPath, bundle, entryPath } = pluginOptions;
const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, tsconfigPath);
Expand Down
8 changes: 6 additions & 2 deletions packages/plugin-dts/src/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -58,10 +62,10 @@ export function emitDts(
logger.error(message);
}

throw new Error('TypeScript compilation failed');
throw new Error('DTS generation failed');
Timeless0911 marked this conversation as resolved.
Show resolved Hide resolved
}

logger.info('TypeScript compilation succeeded\n');
logger.info(`DTS generation succeeded in ${getTimeCost()}`);
} else {
const createProgram = ts.createSemanticDiagnosticsBuilderProgram;
const formatHost: ts.FormatDiagnosticsHost = {
Expand Down
Loading