-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use simple program for single compilation (no watch) (#574)
Use simple ts.Program and ts.CompilerHost when running webpack in non-watch mode. This can improve check time in CI for some cases. BREAKING CHANGE: 🧨 Use ts.Program and ts.CompilerHost for single compilation by default ✅ Closes: #572
- Loading branch information
1 parent
1057b23
commit a195dd5
Showing
8 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/typescript-reporter/reporter/ControlledCompilerHost.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as ts from 'typescript'; | ||
import { TypeScriptHostExtension } from '../extension/TypeScriptExtension'; | ||
import { ControlledTypeScriptSystem } from './ControlledTypeScriptSystem'; | ||
|
||
function createControlledCompilerHost( | ||
typescript: typeof ts, | ||
parsedCommandLine: ts.ParsedCommandLine, | ||
system: ControlledTypeScriptSystem, | ||
hostExtensions: TypeScriptHostExtension[] = [] | ||
): ts.CompilerHost { | ||
const baseCompilerHost = typescript.createCompilerHost(parsedCommandLine.options); | ||
|
||
let controlledCompilerHost: ts.CompilerHost = { | ||
...baseCompilerHost, | ||
fileExists: system.fileExists, | ||
readFile: system.readFile, | ||
directoryExists: system.directoryExists, | ||
getDirectories: system.getDirectories, | ||
realpath: system.realpath, | ||
}; | ||
|
||
hostExtensions.forEach((hostExtension) => { | ||
if (hostExtension.extendCompilerHost) { | ||
controlledCompilerHost = hostExtension.extendCompilerHost( | ||
controlledCompilerHost, | ||
parsedCommandLine | ||
); | ||
} | ||
}); | ||
|
||
return controlledCompilerHost; | ||
} | ||
|
||
export { createControlledCompilerHost }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters