diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 14f0e5bdf94ec..e5498d2457660 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -604,7 +604,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge write(`//# sourceMappingURL=${sourceMappingURL}`); } - writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM, sourceFiles); // reset the state sourceMap.reset(); @@ -748,16 +748,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } /** Write emitted output to disk */ - function writeEmittedFiles(emitOutput: string, jsFilePath: string, sourceMapFilePath: string, writeByteOrderMark: boolean) { + function writeEmittedFiles(emitOutput: string, jsFilePath: string, sourceMapFilePath: string, writeByteOrderMark: boolean, sourceFiles: SourceFile[]) { if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { - writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false); + writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, sourceFiles); } if (sourceMapDataList) { sourceMapDataList.push(sourceMap.getSourceMapData()); } - writeFile(host, emitterDiagnostics, jsFilePath, emitOutput, writeByteOrderMark); + writeFile(host, emitterDiagnostics, jsFilePath, emitOutput, writeByteOrderMark, sourceFiles); } // Create a temporary variable with a unique unused name. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c0f769078e0be..b528143384e2f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -931,7 +931,7 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFiles: program.getSourceFiles, writeFile: writeFileCallback || ( - (fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)), + (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, }; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 155f5c1a77fb4..d86bc87ce532b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1584,7 +1584,7 @@ namespace ts { } export interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; + (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: SourceFile[]): void; } export class OperationCanceledException { } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index de10d469c87fa..6b120b745fef2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2110,10 +2110,10 @@ namespace ts { return combinePaths(newDirPath, sourceFilePath); } - export function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean) { + export function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]) { host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => { diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }); + }, sourceFiles); } export function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) {