@@ -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
4054function diagnosticCallback ( callback ) {
4155 if ( callback ) {
0 commit comments