Skip to content

Commit 46afbaa

Browse files
committed
Handle outFile
1 parent c0c5fbc commit 46afbaa

13 files changed

+1996
-124
lines changed

src/compiler/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ namespace ts {
707707
* Gets the program information to be emitted in buildInfo so that we can use it to create new program
708708
*/
709709
function getProgramBuildInfo(state: Readonly<ReusableBuilderProgramState>, getCanonicalFileName: GetCanonicalFileName): ProgramBuildInfo | undefined {
710-
if (outFile(state.compilerOptions)) return undefined;
710+
if (outFileWithoutPersistResolutions(state.compilerOptions)) return undefined;
711711
const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
712712
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions)!, currentDirectory));
713713
const fileInfos: MapLike<BuilderState.FileInfo> = {};

src/compiler/program.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ namespace ts {
16511651
}
16521652

16531653
function emitBuildInfo(writeFileCallback?: WriteFileCallback): EmitResult {
1654-
Debug.assert(!outFile(options));
1654+
Debug.assert(!outFileWithoutPersistResolutions(options));
16551655
tracing.begin(tracing.Phase.Emit, "emitBuildInfo", {});
16561656
performance.mark("beforeEmit");
16571657
const emitResult = emitFiles(
@@ -3849,7 +3849,7 @@ namespace ts {
38493849
if (options.noEmit) {
38503850
// Cache the semantic diagnostics
38513851
program.getSemanticDiagnostics(sourceFile, cancellationToken);
3852-
return sourceFile || outFile(options) ?
3852+
return sourceFile || outFileWithoutPersistResolutions(options) ?
38533853
emitSkippedWithNoDiagnostics :
38543854
program.emitBuildInfo(writeFile, cancellationToken);
38553855
}
@@ -3871,7 +3871,7 @@ namespace ts {
38713871

38723872
if (!diagnostics.length) return undefined;
38733873
let emittedFiles: string[] | undefined;
3874-
if (!sourceFile && !outFile(options)) {
3874+
if (!sourceFile && !outFileWithoutPersistResolutions(options)) {
38753875
const emitResult = program.emitBuildInfo(writeFile, cancellationToken);
38763876
if (emitResult.diagnostics) diagnostics = [...diagnostics, ...emitResult.diagnostics];
38773877
emittedFiles = emitResult.emittedFiles;

src/compiler/tsbuildPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ namespace ts {
12871287
buildResult: BuildResultFlags,
12881288
errorType: string,
12891289
) {
1290-
const canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !outFile(program.getCompilerOptions());
1290+
const canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !outFileWithoutPersistResolutions(program.getCompilerOptions());
12911291

12921292
reportAndStoreErrors(state, resolvedPath, diagnostics);
12931293
// List files if any other build error using program (emit errors already report files)

src/compiler/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4109,6 +4109,10 @@ namespace ts {
41094109
return options.outFile || options.out;
41104110
}
41114111

4112+
export function outFileWithoutPersistResolutions(options: CompilerOptions) {
4113+
return !!outFile(options) && !options.persistResolutions;
4114+
}
4115+
41124116
/** Returns 'undefined' if and only if 'options.paths' is undefined. */
41134117
export function getPathsBasePath(options: CompilerOptions, host: { getCurrentDirectory?(): string }) {
41144118
if (!options.paths) return undefined;

src/compiler/watchPublic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ts {
55
readFile(fileName: string): string | undefined;
66
}
77
export function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost) {
8-
if (outFile(compilerOptions)) return undefined;
8+
if (outFileWithoutPersistResolutions(compilerOptions)) return undefined;
99
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(compilerOptions);
1010
if (!buildInfoPath) return undefined;
1111
const content = host.readFile(buildInfoPath);
@@ -21,7 +21,7 @@ namespace ts {
2121
writeFile: WriteFileCallback;
2222
}
2323
export function cleanResolutionsOfTsBuildInfo(compilerOptions: CompilerOptions, host: CleanResolutionsOfTsBuildInfoHost): EmitResult {
24-
if (outFile(compilerOptions)) return emitSkippedWithNoDiagnostics;
24+
if (outFileWithoutPersistResolutions(compilerOptions)) return emitSkippedWithNoDiagnostics;
2525
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(compilerOptions);
2626
if (!buildInfoPath) return emitSkippedWithNoDiagnostics;
2727
const content = host.readFile(buildInfoPath);

0 commit comments

Comments
 (0)