@@ -205,8 +205,8 @@ namespace ts {
205
205
return createSolutionBuilderWorker ( /*watch*/ false , host , rootNames , defaultOptions ) ;
206
206
}
207
207
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 ) ;
210
210
}
211
211
212
212
type ConfigFileCacheEntry = ParsedCommandLine | Diagnostic ;
@@ -232,6 +232,7 @@ namespace ts {
232
232
readonly options : BuildOptions ;
233
233
readonly baseCompilerOptions : CompilerOptions ;
234
234
readonly rootNames : readonly string [ ] ;
235
+ readonly baseWatchOptions : WatchOptions | undefined ;
235
236
236
237
readonly resolvedConfigFilePaths : Map < ResolvedConfigFilePath > ;
237
238
readonly configFileCache : ConfigFileMap < ConfigFileCacheEntry > ;
@@ -272,7 +273,7 @@ namespace ts {
272
273
writeLog : ( s : string ) => void ;
273
274
}
274
275
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 > {
276
277
const host = hostOrHostWithWatch as SolutionBuilderHost < T > ;
277
278
const hostWithWatch = hostOrHostWithWatch as SolutionBuilderWithWatchHost < T > ;
278
279
const currentDirectory = host . getCurrentDirectory ( ) ;
@@ -306,6 +307,7 @@ namespace ts {
306
307
options,
307
308
baseCompilerOptions,
308
309
rootNames,
310
+ baseWatchOptions,
309
311
310
312
resolvedConfigFilePaths : createMap ( ) ,
311
313
configFileCache : createConfigFileMap ( ) ,
@@ -374,15 +376,15 @@ namespace ts {
374
376
}
375
377
376
378
let diagnostic : Diagnostic | undefined ;
377
- const { parseConfigFileHost, baseCompilerOptions, extendedConfigCache, host } = state ;
379
+ const { parseConfigFileHost, baseCompilerOptions, baseWatchOptions , extendedConfigCache, host } = state ;
378
380
let parsed : ParsedCommandLine | undefined ;
379
381
if ( host . getParsedCommandLine ) {
380
382
parsed = host . getParsedCommandLine ( configFileName ) ;
381
383
if ( ! parsed ) diagnostic = createCompilerDiagnostic ( Diagnostics . File_0_not_found , configFileName ) ;
382
384
}
383
385
else {
384
386
parseConfigFileHost . onUnRecoverableConfigFileDiagnostic = d => diagnostic = d ;
385
- parsed = getParsedCommandLineOfConfigFile ( configFileName , baseCompilerOptions , parseConfigFileHost , extendedConfigCache ) ;
387
+ parsed = getParsedCommandLineOfConfigFile ( configFileName , baseCompilerOptions , parseConfigFileHost , extendedConfigCache , baseWatchOptions ) ;
386
388
parseConfigFileHost . onUnRecoverableConfigFileDiagnostic = noop ;
387
389
}
388
390
configFileCache . set ( configFilePath , parsed || diagnostic ! ) ;
@@ -1147,7 +1149,7 @@ namespace ts {
1147
1149
}
1148
1150
1149
1151
if ( reloadLevel === ConfigFileProgramReloadLevel . Full ) {
1150
- watchConfigFile ( state , project , projectPath ) ;
1152
+ watchConfigFile ( state , project , projectPath , config ) ;
1151
1153
watchWildCardDirectories ( state , project , projectPath , config ) ;
1152
1154
watchInputFiles ( state , project , projectPath , config ) ;
1153
1155
}
@@ -1751,7 +1753,7 @@ namespace ts {
1751
1753
reportErrorSummary ( state , buildOrder ) ;
1752
1754
}
1753
1755
1754
- function watchConfigFile ( state : SolutionBuilderState , resolved : ResolvedConfigFileName , resolvedPath : ResolvedConfigFilePath ) {
1756
+ function watchConfigFile ( state : SolutionBuilderState , resolved : ResolvedConfigFileName , resolvedPath : ResolvedConfigFilePath , parsed : ParsedCommandLine | undefined ) {
1755
1757
if ( ! state . watch || state . allWatchedConfigFiles . has ( resolvedPath ) ) return ;
1756
1758
state . allWatchedConfigFiles . set ( resolvedPath , state . watchFile (
1757
1759
state . hostWithWatch ,
@@ -1760,6 +1762,7 @@ namespace ts {
1760
1762
invalidateProjectAndScheduleBuilds ( state , resolvedPath , ConfigFileProgramReloadLevel . Full ) ;
1761
1763
} ,
1762
1764
PollingInterval . High ,
1765
+ parsed ?. watchOptions ,
1763
1766
WatchType . ConfigFile ,
1764
1767
resolved
1765
1768
) ) ;
@@ -1820,6 +1823,7 @@ namespace ts {
1820
1823
invalidateProjectAndScheduleBuilds ( state , resolvedPath , ConfigFileProgramReloadLevel . Partial ) ;
1821
1824
} ,
1822
1825
flags ,
1826
+ parsed ?. watchOptions ,
1823
1827
WatchType . WildcardDirectory ,
1824
1828
resolved
1825
1829
)
@@ -1837,6 +1841,7 @@ namespace ts {
1837
1841
input ,
1838
1842
( ) => invalidateProjectAndScheduleBuilds ( state , resolvedPath , ConfigFileProgramReloadLevel . None ) ,
1839
1843
PollingInterval . Low ,
1844
+ parsed ?. watchOptions ,
1840
1845
path as Path ,
1841
1846
WatchType . SourceFile ,
1842
1847
resolved
@@ -1851,10 +1856,9 @@ namespace ts {
1851
1856
state . watchAllProjectsPending = false ;
1852
1857
for ( const resolved of getBuildOrderFromAnyBuildOrder ( buildOrder ) ) {
1853
1858
const resolvedPath = toResolvedConfigFilePath ( state , resolved ) ;
1854
- // Watch this file
1855
- watchConfigFile ( state , resolved , resolvedPath ) ;
1856
-
1857
1859
const cfg = parseConfigFile ( state , resolved , resolvedPath ) ;
1860
+ // Watch this file
1861
+ watchConfigFile ( state , resolved , resolvedPath , cfg ) ;
1858
1862
if ( cfg ) {
1859
1863
// Update watchers for wildcard directories
1860
1864
watchWildCardDirectories ( state , resolved , resolvedPath , cfg ) ;
@@ -1870,9 +1874,9 @@ namespace ts {
1870
1874
* can dynamically add/remove other projects based on changes on the rootNames' references
1871
1875
*/
1872
1876
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 ) ;
1876
1880
return {
1877
1881
build : ( project , cancellationToken ) => build ( state , project , cancellationToken ) ,
1878
1882
clean : project => clean ( state , project ) ,
0 commit comments