Skip to content

Commit

Permalink
fix(tsc): improve incremental build invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
fathyb committed Jan 7, 2018
1 parent be92c5e commit b4eab4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/backend/compiler/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class CompilerHost implements ts.CompilerHost {
}

public fileExists(path: string) {
return this.host.fileExists(path)
return this.store.exists(path) || this.host.fileExists(path)
}

private resolve(path: string) {
Expand Down
8 changes: 5 additions & 3 deletions src/backend/compiler/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class FileStore {
private readonly files: {[key: string]: string} = {}
private readonly sources: {[key: string]: ts.SourceFile} = {}

public exists(path: string): boolean {
return path in this.files
}

public readFile(path: string, onlyCache = false): string|undefined {
if(!/^\//.test(path)) {
throw new Error('Path should be absolute')
Expand Down Expand Up @@ -71,7 +75,7 @@ export class FileStore {
throw new Error(`Cannot find file ${path}`)
}

source = ts.createSourceFile(path, file, target)
source = ts.createSourceFile(path, file, target, true)

this.sources[path] = source

Expand Down Expand Up @@ -105,8 +109,6 @@ export class FileStore {
this.changedFiles.push(path)

delete this.sources[path]

this.files[path] = readFileSync(path, {encoding: 'utf-8'})
}
}

Expand Down

0 comments on commit b4eab4d

Please sign in to comment.