Skip to content

Commit b1515d4

Browse files
FauxFauxmrjoelkemp
authored andcommitted
feat: pre-compile the typescript config
This compilation step, currently done inside filing-cabinet, causes a significant slowdown for large trees. Closes gh-114
1 parent 7f0f241 commit b1515d4

File tree

4 files changed

+198
-45
lines changed

4 files changed

+198
-45
lines changed

lib/Config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class Config {
2222
if (!this.directory) { throw new Error('directory not given'); }
2323
if (this.filter && typeof this.filter !== 'function') { throw new Error('filter must be a function'); }
2424

25+
if ('string' === typeof this.tsConfig) {
26+
debug('preparsing the ts config into an object for performance');
27+
const ts = require('typescript');
28+
const tsParsedConfig = ts.readJsonConfigFile(this.tsConfig, ts.sys.readFile);
29+
const obj = ts.parseJsonSourceFileConfigFileContent(tsParsedConfig, ts.sys, path.dirname(this.tsConfig));
30+
this.tsConfig = obj.raw;
31+
}
32+
2533
debug('given filename: ' + this.filename);
2634

2735
this.filename = path.resolve(process.cwd(), this.filename);

0 commit comments

Comments
 (0)