Skip to content

Commit 54ad038

Browse files
committed
Merge pull request #751 from laurelnaiad/iss737
use externalTranspiler before doing diffs for status
2 parents 5482604 + 900a1da commit 54ad038

File tree

4 files changed

+64
-30
lines changed

4 files changed

+64
-30
lines changed

dist/main/lang/modules/building.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ function getRawOutput(proj, filePath) {
7878
return output;
7979
}
8080
exports.getRawOutput = getRawOutput;
81+
function getRawOutputPostExternal(proj, filePath) {
82+
var output1 = getRawOutput(proj, filePath);
83+
var sourceFile = proj.languageService.getSourceFile(filePath);
84+
var sourceMapContents = {};
85+
return runExternalTranspiler(filePath, sourceFile.text, output1.outputFiles[0], proj, sourceMapContents).then(function () {
86+
return {
87+
outputFiles: output1.outputFiles,
88+
emitSkipped: false
89+
};
90+
});
91+
}
92+
exports.getRawOutputPostExternal = getRawOutputPostExternal;
8193
function getBabelInstance(projectDirectory) {
8294
return new Promise(function (resolve) {
8395
if (!babels[projectDirectory]) {

dist/main/lang/projectService.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -599,23 +599,27 @@ exports.getOutputJs = getOutputJs;
599599
function getOutputJsStatus(query) {
600600
projectCache_1.consistentPath(query);
601601
var project = projectCache_1.getOrCreateProject(query.filePath);
602-
var output = building_1.getRawOutput(project, query.filePath);
603-
if (output.emitSkipped) {
604-
if (output.outputFiles && output.outputFiles.length === 1) {
605-
if (output.outputFiles[0].text === building.Not_In_Context) {
602+
return building_1.getRawOutputPostExternal(project, query.filePath)
603+
.then(function (output) {
604+
if (output.emitSkipped) {
605+
if (output.outputFiles && output.outputFiles.length === 1) {
606+
if (output.outputFiles[0].text === building.Not_In_Context) {
607+
return resolve({ emitDiffers: false });
608+
}
609+
}
610+
return resolve({ emitDiffers: true });
611+
}
612+
else {
613+
var jsFile = output.outputFiles.filter(function (x) { return path.extname(x.name) == ".js"; })[0];
614+
if (!jsFile) {
606615
return resolve({ emitDiffers: false });
607616
}
617+
else {
618+
var emitDiffers = !fs.existsSync(jsFile.name) || fs.readFileSync(jsFile.name).toString() !== jsFile.text;
619+
return resolve({ emitDiffers: emitDiffers });
620+
}
608621
}
609-
return resolve({ emitDiffers: true });
610-
}
611-
var jsFile = output.outputFiles.filter(function (x) { return path.extname(x.name) == ".js"; })[0];
612-
if (!jsFile) {
613-
return resolve({ emitDiffers: false });
614-
}
615-
else {
616-
var emitDiffers = !fs.existsSync(jsFile.name) || fs.readFileSync(jsFile.name).toString() !== jsFile.text;
617-
return resolve({ emitDiffers: emitDiffers });
618-
}
622+
});
619623
}
620624
exports.getOutputJsStatus = getOutputJsStatus;
621625
function softReset(query) {

lib/main/lang/modules/building.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ export function getRawOutput(proj: project.Project, filePath: string): ts.EmitOu
106106
return output;
107107
}
108108

109+
export function getRawOutputPostExternal(proj: project.Project, filePath: string): Promise<ts.EmitOutput> {
110+
var output1 = getRawOutput(proj, filePath);
111+
let sourceFile = proj.languageService.getSourceFile(filePath);
112+
let sourceMapContents: { [index: string]: any } = {};
113+
return runExternalTranspiler(
114+
filePath, sourceFile.text, output1.outputFiles[0], proj, sourceMapContents
115+
).then(() => {
116+
return {
117+
outputFiles: output1.outputFiles,
118+
emitSkipped: false
119+
};
120+
});
121+
}
122+
109123
function getBabelInstance(projectDirectory: string) {
110124
return new Promise<any>(resolve => {
111125
if (!babels[projectDirectory]) {

lib/main/lang/projectService.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function build(query: BuildQuery): Promise<BuildResponse> {
124124
return output;
125125
});
126126

127-
// Also optionally emit a root dts:
127+
// Also optionally emit a root dts:
128128
building.emitDts(proj);
129129

130130
// If there is a post build script to run ... run it
@@ -138,7 +138,7 @@ export function build(query: BuildQuery): Promise<BuildResponse> {
138138
}
139139
});
140140
}
141-
141+
142142
let tsFilesWithInvalidEmit = outputs
143143
.filter((o) => o.emitError)
144144
.map((o) => o.sourceFileName);
@@ -909,7 +909,7 @@ export function applyQuickFix(query: ApplyQuickFixQuery): Promise<ApplyQuickFixR
909909
interface GetOutputResponse {
910910
output: ts.EmitOutput;
911911
}
912-
import {getRawOutput} from "./modules/building";
912+
import {getRawOutputPostExternal, getRawOutput} from "./modules/building";
913913
export function getOutput(query: FilePathQuery): Promise<GetOutputResponse> {
914914
consistentPath(query);
915915
var project = getOrCreateProject(query.filePath);
@@ -938,22 +938,26 @@ interface GetOutputJsStatusResponse {
938938
export function getOutputJsStatus(query: FilePathQuery): Promise<GetOutputJsStatusResponse> {
939939
consistentPath(query);
940940
var project = getOrCreateProject(query.filePath);
941-
var output = getRawOutput(project, query.filePath);
942-
if (output.emitSkipped) {
943-
if (output.outputFiles && output.outputFiles.length === 1) {
944-
if (output.outputFiles[0].text === building.Not_In_Context) {
941+
return getRawOutputPostExternal(project, query.filePath)
942+
.then((output) => {
943+
if (output.emitSkipped) {
944+
if (output.outputFiles && output.outputFiles.length === 1) {
945+
if (output.outputFiles[0].text === building.Not_In_Context) {
946+
return resolve({ emitDiffers: false });
947+
}
948+
}
949+
return resolve({ emitDiffers: true });
950+
}
951+
else {
952+
var jsFile = output.outputFiles.filter(x=> path.extname(x.name) == ".js")[0];
953+
if (!jsFile) {
945954
return resolve({ emitDiffers: false });
955+
} else {
956+
var emitDiffers = !fs.existsSync(jsFile.name) || fs.readFileSync(jsFile.name).toString() !== jsFile.text;
957+
return resolve({ emitDiffers });
946958
}
947959
}
948-
return resolve({ emitDiffers: true });
949-
}
950-
var jsFile = output.outputFiles.filter(x=> path.extname(x.name) == ".js")[0];
951-
if (!jsFile) {
952-
return resolve({ emitDiffers: false });
953-
} else {
954-
var emitDiffers = !fs.existsSync(jsFile.name) || fs.readFileSync(jsFile.name).toString() !== jsFile.text;
955-
return resolve({ emitDiffers });
956-
}
960+
});
957961
}
958962

959963
/**

0 commit comments

Comments
 (0)