diff --git a/README.md b/README.md index 3113c58..0336a0e 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,10 @@ resolve: { No logging from the checker. Please note that this option disables async error reporting because this option bans `console.log()` usage. +### verbose *(boolean) (default=false)* + +Enable verbose logging. Log more than just errors (e.g. typescript path, execution time). + ### compiler *(string) (default='typescript')* Allows use of TypeScript compilers other than the official one. Must be diff --git a/src/checker/runtime.ts b/src/checker/runtime.ts index 8bb3c10..c8a4c3b 100644 --- a/src/checker/runtime.ts +++ b/src/checker/runtime.ts @@ -420,9 +420,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re } function processDiagnostics({ seq }: Diagnostics.Request) { - let silent = !!loaderConfig.silent; - - if (!silent) { + if (loaderConfig.verbose) { console.log(colors.cyan(`\n[${instanceName}] Checking started in a separate process...`)); } diff --git a/src/instance.ts b/src/instance.ts index 769331e..e0194f7 100644 --- a/src/instance.ts +++ b/src/instance.ts @@ -112,7 +112,7 @@ export function ensureInstance( context ); - if (!loaderConfig.silent) { + if (loaderConfig.verbose) { const sync = watching === WatchMode.Enabled ? ' (in a forked process)' : ''; console.log(`\n[${instanceName}] Using typescript@${compilerInfo.compilerVersion} from ${compilerInfo.compilerPath} and ` + `"tsconfig.json" from ${configFilePath}${sync}.\n`); @@ -437,6 +437,7 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) { const watchMode = isWatching(compilation.compiler); const instance: Instance = resolveInstance(compilation.compiler, instanceName); const silent = instance.loaderConfig.silent; + const verbose = instance.loaderConfig.verbose; const asyncErrors = watchMode === WatchMode.Enabled && !silent; let emitError = (msg) => { @@ -462,7 +463,7 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) { ? Promise.resolve() : instance.checker.getDiagnostics() .then(diags => { - if (!silent) { + if (verbose) { if (diags.length) { console.error(colors.red(`\n[${instanceName}] Checking finished with ${diags.length} errors`)); } else { diff --git a/src/interfaces.ts b/src/interfaces.ts index 511db6d..ebc49af 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -20,6 +20,7 @@ export interface LoaderConfig { babelOptions?: any; usePrecompiledFiles?: boolean; silent?: boolean; + verbose?: boolean; useCache?: boolean; cacheDirectory?: string; entryFileIsJs?: boolean;