-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Avoid writing files that are not changed while compiling incrementally. #6937
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
Changes from all commits
c7e80e1
63c6908
acf965a
0282c04
a481305
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ namespace ts { | |
getExecutingFilePath(): string; | ||
getCurrentDirectory(): string; | ||
readDirectory(path: string, extension?: string, exclude?: string[]): string[]; | ||
getModifiedTime?(path: string): Date; | ||
createHash?(data: string): string; | ||
getMemoryUsage?(): number; | ||
exit(exitCode?: number): void; | ||
} | ||
|
@@ -226,6 +228,7 @@ namespace ts { | |
const _fs = require("fs"); | ||
const _path = require("path"); | ||
const _os = require("os"); | ||
const _crypto = require("crypto"); | ||
|
||
// average async stat takes about 30 microseconds | ||
// set chunk size to do 30 files in < 1 millisecond | ||
|
@@ -556,6 +559,19 @@ namespace ts { | |
return process.cwd(); | ||
}, | ||
readDirectory, | ||
getModifiedTime(path) { | ||
try { | ||
return _fs.statSync(path).mtime; | ||
} | ||
catch (e) { | ||
return undefined; | ||
} | ||
}, | ||
createHash(data) { | ||
const hash = _crypto.createHash("md5"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we always want to use MD5 @mhegazy? Also, could you get away with a single call to if (!hash) {
hash = _crypto.createHash("md5");
}
hash.update(data);
return hash.digest("hex"); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DanielRosenwasser Seems that we need to |
||
hash.update(data); | ||
return hash.digest("hex"); | ||
}, | ||
getMemoryUsage() { | ||
if (global.gc) { | ||
global.gc(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark this
/* @internal */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielRosenwasser I am confused, it's not even exported, why does it need
/** @internal */
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Misread the code, forgive me. I was taking a quick glance at this PR again since it's been a bit.