Skip to content

Commit c46ec3b

Browse files
authored
Merge pull request #209 from typed-ember/ts-2-9-support
Stop inspecting output strings to determine when builds complete
2 parents ad7748e + 1f4803c commit c46ec3b

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

lib/incremental-typescript-compiler/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,11 @@ module.exports = class IncrementalTypescriptCompiler {
9797

9898
this._watchProgram = compile(project, { outDir, watch: true }, {
9999
watchedFileChanged: () => this.state.tscDidStart(),
100+
buildComplete: () => this.state.tscDidEnd(),
100101

101102
reportWatchStatus: (diagnostic) => {
102103
let text = diagnostic.messageText;
103104
debugTsc(text);
104-
105-
if (text.indexOf('Compilation complete') !== -1) {
106-
this.state.tscDidEnd();
107-
}
108105
},
109106

110107
reportDiagnostic: (diagnostic) => {

lib/utilities/compile.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,37 @@ module.exports = function compile(project, tsOptions, callbacks) {
1919
}, tsOptions);
2020

2121
let ts = project.require('typescript');
22+
let host = createWatchCompilerHost(ts, fullOptions, project, callbacks);
23+
24+
return ts.createWatchProgram(host);
25+
};
26+
27+
function createWatchCompilerHost(ts, options, project, callbacks) {
2228
let configPath = ts.findConfigFile('./', ts.sys.fileExists, 'tsconfig.json');
2329
let createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
2430
let host = ts.createWatchCompilerHost(
2531
configPath,
26-
fullOptions,
32+
options,
2733
buildWatchHooks(project, ts.sys, callbacks),
2834
createProgram,
2935
diagnosticCallback(callbacks.reportDiagnostic),
3036
diagnosticCallback(callbacks.reportWatchStatus)
3137
);
3238

39+
let afterCreate = host.afterProgramCreate;
40+
host.afterProgramCreate = function() {
41+
afterCreate.apply(this, arguments);
42+
if (callbacks.buildComplete) {
43+
callbacks.buildComplete();
44+
}
45+
};
46+
3347
if (debug.enabled) {
3448
host.trace = str => debug(str.trim());
3549
}
3650

37-
return ts.createWatchProgram(host);
38-
};
51+
return host;
52+
}
3953

4054
function diagnosticCallback(callback) {
4155
if (callback) {

0 commit comments

Comments
 (0)