Skip to content

Commit 1156141

Browse files
committed
Merge pull request #7525 from chuckjaz/sourceFile_callback
Adding sourceFiles to the Program emit callback
2 parents eef907a + 8bf9da6 commit 1156141

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/compiler/emitter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
604604
write(`//# sourceMappingURL=${sourceMappingURL}`);
605605
}
606606

607-
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM);
607+
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM, sourceFiles);
608608

609609
// reset the state
610610
sourceMap.reset();
@@ -748,16 +748,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
748748
}
749749

750750
/** Write emitted output to disk */
751-
function writeEmittedFiles(emitOutput: string, jsFilePath: string, sourceMapFilePath: string, writeByteOrderMark: boolean) {
751+
function writeEmittedFiles(emitOutput: string, jsFilePath: string, sourceMapFilePath: string, writeByteOrderMark: boolean, sourceFiles: SourceFile[]) {
752752
if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) {
753-
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false);
753+
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, sourceFiles);
754754
}
755755

756756
if (sourceMapDataList) {
757757
sourceMapDataList.push(sourceMap.getSourceMapData());
758758
}
759759

760-
writeFile(host, emitterDiagnostics, jsFilePath, emitOutput, writeByteOrderMark);
760+
writeFile(host, emitterDiagnostics, jsFilePath, emitOutput, writeByteOrderMark, sourceFiles);
761761
}
762762

763763
// Create a temporary variable with a unique unused name.

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ namespace ts {
931931
getSourceFile: program.getSourceFile,
932932
getSourceFiles: program.getSourceFiles,
933933
writeFile: writeFileCallback || (
934-
(fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)),
934+
(fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)),
935935
isEmitBlocked,
936936
};
937937
}

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ namespace ts {
15841584
}
15851585

15861586
export interface WriteFileCallback {
1587-
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
1587+
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: SourceFile[]): void;
15881588
}
15891589

15901590
export class OperationCanceledException { }

src/compiler/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,10 +2110,10 @@ namespace ts {
21102110
return combinePaths(newDirPath, sourceFilePath);
21112111
}
21122112

2113-
export function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean) {
2113+
export function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]) {
21142114
host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => {
21152115
diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
2116-
});
2116+
}, sourceFiles);
21172117
}
21182118

21192119
export function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) {

0 commit comments

Comments
 (0)