diff --git a/src/server/builder.ts b/src/compiler/builder.ts
similarity index 90%
rename from src/server/builder.ts
rename to src/compiler/builder.ts
index 001bd708b2e..b830e517e5c 100644
--- a/src/server/builder.ts
+++ b/src/compiler/builder.ts
@@ -1,8 +1,17 @@
-///
-///
-///
+///
+
+namespace ts {
+ export interface EmitOutput {
+ outputFiles: OutputFile[];
+ emitSkipped: boolean;
+ }
+
+ export interface OutputFile {
+ name: string;
+ writeByteOrderMark: boolean;
+ text: string;
+ }
-namespace ts.server {
export interface Builder {
/**
* This is the callback when file infos in the builder are updated
@@ -13,6 +22,20 @@ namespace ts.server {
clear(): void;
}
+ export function getFileEmitOutput(program: Program, sourceFile: SourceFile, emitOnlyDtsFiles?: boolean,
+ cancellationToken?: CancellationToken, customTransformers?: CustomTransformers): EmitOutput {
+ const outputFiles: OutputFile[] = [];
+ const emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
+ return {
+ outputFiles,
+ emitSkipped: emitOutput.emitSkipped
+ };
+
+ function writeFile(fileName: string, text: string, writeByteOrderMark: boolean) {
+ outputFiles.push({ name: fileName, writeByteOrderMark, text });
+ }
+ }
+
interface EmitHandler {
addScriptInfo(program: Program, sourceFile: SourceFile): void;
removeScriptInfo(path: Path): void;
@@ -157,7 +180,7 @@ namespace ts.server {
for (const importName of sourceFile.imports) {
const symbol = checker.getSymbolAtLocation(importName);
if (symbol && symbol.declarations && symbol.declarations[0]) {
- const declarationSourceFile = symbol.declarations[0].getSourceFile();
+ const declarationSourceFile = getSourceFileOfNode(symbol.declarations[0]);
if (declarationSourceFile) {
referencedFiles.set(declarationSourceFile.path, true);
}
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index 0c319b18053..e2bfa647eb7 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -1,6 +1,7 @@
///
///
///
+///
namespace ts {
const ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/;
diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json
index 3709d65b7fd..6c50bef7216 100644
--- a/src/compiler/tsconfig.json
+++ b/src/compiler/tsconfig.json
@@ -36,6 +36,7 @@
"declarationEmitter.ts",
"emitter.ts",
"program.ts",
+ "builder.ts",
"commandLineParser.ts",
"tsc.ts",
"diagnosticInformationMap.generated.ts"
diff --git a/src/server/project.ts b/src/server/project.ts
index 851a26a5d4a..d764e1701d8 100644
--- a/src/server/project.ts
+++ b/src/server/project.ts
@@ -3,7 +3,7 @@
///
///
///
-///
+///
namespace ts.server {
diff --git a/src/services/services.ts b/src/services/services.ts
index e22d6041159..091364b5c50 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -1471,19 +1471,8 @@ namespace ts {
synchronizeHostData();
const sourceFile = getValidSourceFile(fileName);
- const outputFiles: OutputFile[] = [];
-
- function writeFile(fileName: string, text: string, writeByteOrderMark: boolean) {
- outputFiles.push({ name: fileName, writeByteOrderMark, text });
- }
-
const customTransformers = host.getCustomTransformers && host.getCustomTransformers();
- const emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
-
- return {
- outputFiles,
- emitSkipped: emitOutput.emitSkipped
- };
+ return getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers);
}
// Signature help
diff --git a/src/services/types.ts b/src/services/types.ts
index 6ff7402f3ad..34d79b311ca 100644
--- a/src/services/types.ts
+++ b/src/services/types.ts
@@ -693,23 +693,12 @@ namespace ts {
autoCollapse: boolean;
}
- export interface EmitOutput {
- outputFiles: OutputFile[];
- emitSkipped: boolean;
- }
-
export const enum OutputFileType {
JavaScript,
SourceMap,
Declaration
}
- export interface OutputFile {
- name: string;
- writeByteOrderMark: boolean;
- text: string;
- }
-
export const enum EndOfLineState {
None,
InMultiLineCommentTrivia,