Skip to content

Commit 0e42c1b

Browse files
committedDec 8, 2017
cache tsconfig.json
1 parent f6b8e23 commit 0e42c1b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎lib/utils.ts

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import * as ts from "typescript";
33
import * as fs from "fs";
44
import * as path from "path";
55

6+
declare type CONFIG_CACHE<T> = { [file: string]: T };
7+
const TSCONFIG_CACHE: CONFIG_CACHE<ts.ParsedCommandLine> = {};
8+
69
export function createDefaultFormatCodeSettings(): ts.FormatCodeSettings {
710

811
return {
@@ -49,6 +52,8 @@ export function readFilesFromTsconfig(configPath: string): string[] {
4952
}
5053

5154
export function readTsconfig(configPath: string): ts.ParsedCommandLine {
55+
if (TSCONFIG_CACHE[configPath]) return TSCONFIG_CACHE[configPath];
56+
5257
// for `extends` support. It supported from TypeScript 2.1.1.
5358
// `& { readFile(path: string): string; }` is backword compat for TypeScript compiler 2.0.3 support.
5459
const host: ts.ParseConfigHost & { readFile(path: string): string; } = {
@@ -63,6 +68,8 @@ export function readTsconfig(configPath: string): ts.ParsedCommandLine {
6368
throw new Error(parsed.errors.map(e => e.messageText).join("\n"));
6469
}
6570

71+
TSCONFIG_CACHE[configPath] = parsed;
72+
6673
return parsed;
6774
}
6875

0 commit comments

Comments
 (0)
Please sign in to comment.