@@ -205,8 +205,8 @@ namespace ts {
205205 return createSolutionBuilderWorker ( /*watch*/ false , host , rootNames , defaultOptions ) ;
206206 }
207207
208- export function createSolutionBuilderWithWatch < T extends BuilderProgram > ( host : SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , defaultOptions : BuildOptions ) : SolutionBuilder < T > {
209- return createSolutionBuilderWorker ( /*watch*/ true , host , rootNames , defaultOptions ) ;
208+ export function createSolutionBuilderWithWatch < T extends BuilderProgram > ( host : SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , defaultOptions : BuildOptions , baseWatchOptions ?: WatchOptions ) : SolutionBuilder < T > {
209+ return createSolutionBuilderWorker ( /*watch*/ true , host , rootNames , defaultOptions , baseWatchOptions ) ;
210210 }
211211
212212 type ConfigFileCacheEntry = ParsedCommandLine | Diagnostic ;
@@ -232,6 +232,7 @@ namespace ts {
232232 readonly options : BuildOptions ;
233233 readonly baseCompilerOptions : CompilerOptions ;
234234 readonly rootNames : readonly string [ ] ;
235+ readonly baseWatchOptions : WatchOptions | undefined ;
235236
236237 readonly resolvedConfigFilePaths : Map < ResolvedConfigFilePath > ;
237238 readonly configFileCache : ConfigFileMap < ConfigFileCacheEntry > ;
@@ -272,7 +273,7 @@ namespace ts {
272273 writeLog : ( s : string ) => void ;
273274 }
274275
275- function createSolutionBuilderState < T extends BuilderProgram > ( watch : boolean , hostOrHostWithWatch : SolutionBuilderHost < T > | SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , options : BuildOptions ) : SolutionBuilderState < T > {
276+ function createSolutionBuilderState < T extends BuilderProgram > ( watch : boolean , hostOrHostWithWatch : SolutionBuilderHost < T > | SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , options : BuildOptions , baseWatchOptions : WatchOptions | undefined ) : SolutionBuilderState < T > {
276277 const host = hostOrHostWithWatch as SolutionBuilderHost < T > ;
277278 const hostWithWatch = hostOrHostWithWatch as SolutionBuilderWithWatchHost < T > ;
278279 const currentDirectory = host . getCurrentDirectory ( ) ;
@@ -306,6 +307,7 @@ namespace ts {
306307 options,
307308 baseCompilerOptions,
308309 rootNames,
310+ baseWatchOptions,
309311
310312 resolvedConfigFilePaths : createMap ( ) ,
311313 configFileCache : createConfigFileMap ( ) ,
@@ -374,15 +376,15 @@ namespace ts {
374376 }
375377
376378 let diagnostic : Diagnostic | undefined ;
377- const { parseConfigFileHost, baseCompilerOptions, extendedConfigCache, host } = state ;
379+ const { parseConfigFileHost, baseCompilerOptions, baseWatchOptions , extendedConfigCache, host } = state ;
378380 let parsed : ParsedCommandLine | undefined ;
379381 if ( host . getParsedCommandLine ) {
380382 parsed = host . getParsedCommandLine ( configFileName ) ;
381383 if ( ! parsed ) diagnostic = createCompilerDiagnostic ( Diagnostics . File_0_not_found , configFileName ) ;
382384 }
383385 else {
384386 parseConfigFileHost . onUnRecoverableConfigFileDiagnostic = d => diagnostic = d ;
385- parsed = getParsedCommandLineOfConfigFile ( configFileName , baseCompilerOptions , parseConfigFileHost , extendedConfigCache ) ;
387+ parsed = getParsedCommandLineOfConfigFile ( configFileName , baseCompilerOptions , parseConfigFileHost , extendedConfigCache , baseWatchOptions ) ;
386388 parseConfigFileHost . onUnRecoverableConfigFileDiagnostic = noop ;
387389 }
388390 configFileCache . set ( configFilePath , parsed || diagnostic ! ) ;
@@ -1147,7 +1149,7 @@ namespace ts {
11471149 }
11481150
11491151 if ( reloadLevel === ConfigFileProgramReloadLevel . Full ) {
1150- watchConfigFile ( state , project , projectPath ) ;
1152+ watchConfigFile ( state , project , projectPath , config ) ;
11511153 watchWildCardDirectories ( state , project , projectPath , config ) ;
11521154 watchInputFiles ( state , project , projectPath , config ) ;
11531155 }
@@ -1751,7 +1753,7 @@ namespace ts {
17511753 reportErrorSummary ( state , buildOrder ) ;
17521754 }
17531755
1754- function watchConfigFile ( state : SolutionBuilderState , resolved : ResolvedConfigFileName , resolvedPath : ResolvedConfigFilePath ) {
1756+ function watchConfigFile ( state : SolutionBuilderState , resolved : ResolvedConfigFileName , resolvedPath : ResolvedConfigFilePath , parsed : ParsedCommandLine | undefined ) {
17551757 if ( ! state . watch || state . allWatchedConfigFiles . has ( resolvedPath ) ) return ;
17561758 state . allWatchedConfigFiles . set ( resolvedPath , state . watchFile (
17571759 state . hostWithWatch ,
@@ -1760,6 +1762,7 @@ namespace ts {
17601762 invalidateProjectAndScheduleBuilds ( state , resolvedPath , ConfigFileProgramReloadLevel . Full ) ;
17611763 } ,
17621764 PollingInterval . High ,
1765+ parsed ?. watchOptions ,
17631766 WatchType . ConfigFile ,
17641767 resolved
17651768 ) ) ;
@@ -1820,6 +1823,7 @@ namespace ts {
18201823 invalidateProjectAndScheduleBuilds ( state , resolvedPath , ConfigFileProgramReloadLevel . Partial ) ;
18211824 } ,
18221825 flags ,
1826+ parsed ?. watchOptions ,
18231827 WatchType . WildcardDirectory ,
18241828 resolved
18251829 )
@@ -1837,6 +1841,7 @@ namespace ts {
18371841 input ,
18381842 ( ) => invalidateProjectAndScheduleBuilds ( state , resolvedPath , ConfigFileProgramReloadLevel . None ) ,
18391843 PollingInterval . Low ,
1844+ parsed ?. watchOptions ,
18401845 path as Path ,
18411846 WatchType . SourceFile ,
18421847 resolved
@@ -1851,10 +1856,9 @@ namespace ts {
18511856 state . watchAllProjectsPending = false ;
18521857 for ( const resolved of getBuildOrderFromAnyBuildOrder ( buildOrder ) ) {
18531858 const resolvedPath = toResolvedConfigFilePath ( state , resolved ) ;
1854- // Watch this file
1855- watchConfigFile ( state , resolved , resolvedPath ) ;
1856-
18571859 const cfg = parseConfigFile ( state , resolved , resolvedPath ) ;
1860+ // Watch this file
1861+ watchConfigFile ( state , resolved , resolvedPath , cfg ) ;
18581862 if ( cfg ) {
18591863 // Update watchers for wildcard directories
18601864 watchWildCardDirectories ( state , resolved , resolvedPath , cfg ) ;
@@ -1870,9 +1874,9 @@ namespace ts {
18701874 * can dynamically add/remove other projects based on changes on the rootNames' references
18711875 */
18721876 function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : false , host : SolutionBuilderHost < T > , rootNames : readonly string [ ] , defaultOptions : BuildOptions ) : SolutionBuilder < T > ;
1873- function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : true , host : SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , defaultOptions : BuildOptions ) : SolutionBuilder < T > ;
1874- function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : boolean , hostOrHostWithWatch : SolutionBuilderHost < T > | SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , options : BuildOptions ) : SolutionBuilder < T > {
1875- const state = createSolutionBuilderState ( watch , hostOrHostWithWatch , rootNames , options ) ;
1877+ function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : true , host : SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , defaultOptions : BuildOptions , baseWatchOptions ?: WatchOptions ) : SolutionBuilder < T > ;
1878+ function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : boolean , hostOrHostWithWatch : SolutionBuilderHost < T > | SolutionBuilderWithWatchHost < T > , rootNames : readonly string [ ] , options : BuildOptions , baseWatchOptions ?: WatchOptions ) : SolutionBuilder < T > {
1879+ const state = createSolutionBuilderState ( watch , hostOrHostWithWatch , rootNames , options , baseWatchOptions ) ;
18761880 return {
18771881 build : ( project , cancellationToken ) => build ( state , project , cancellationToken ) ,
18781882 clean : project => clean ( state , project ) ,
0 commit comments