@@ -39,7 +39,7 @@ import picomatch from 'picomatch'
3939import { resolveFrom } from './util/resolveFrom'
4040import * as parcel from './watcher/index.js'
4141import { equal } from '@tailwindcss/language-service/src/util/array'
42- import { CONFIG_GLOB , CSS_GLOB , PACKAGE_LOCK_GLOB } from './lib/constants'
42+ import { CONFIG_GLOB , CSS_GLOB , PACKAGE_LOCK_GLOB , TSCONFIG_GLOB } from './lib/constants'
4343import { clearRequireCache , isObject , changeAffectsFile , normalizeDriveLetter } from './utils'
4444import { DocumentService } from './documents'
4545import { createProjectService , type ProjectService } from './projects'
@@ -48,6 +48,7 @@ import { readCssFile } from './util/css'
4848import { ProjectLocator , type ProjectConfig } from './project-locator'
4949import type { TailwindCssSettings } from '@tailwindcss/language-service/src/util/state'
5050import { createResolver , Resolver } from './resolver'
51+ import { retry } from './util/retry'
5152
5253const TRIGGER_CHARACTERS = [
5354 // class attributes
@@ -296,6 +297,7 @@ export class TW {
296297 let isPackageMatcher = picomatch ( `**/${ PACKAGE_LOCK_GLOB } ` , { dot : true } )
297298 let isCssMatcher = picomatch ( `**/${ CSS_GLOB } ` , { dot : true } )
298299 let isConfigMatcher = picomatch ( `**/${ CONFIG_GLOB } ` , { dot : true } )
300+ let isTSConfigMatcher = picomatch ( `**/${ TSCONFIG_GLOB } ` , { dot : true } )
299301
300302 changeLoop: for ( let change of changes ) {
301303 let normalizedFilename = normalizePath ( change . file )
@@ -335,6 +337,12 @@ export class TW {
335337 }
336338 }
337339
340+ let isTsconfig = isTSConfigMatcher ( normalizedFilename )
341+ if ( isTsconfig ) {
342+ needsSoftRestart = true
343+ break changeLoop
344+ }
345+
338346 for ( let [ , project ] of this . projects ) {
339347 if ( ! project . state . v4 ) continue
340348
@@ -391,6 +399,18 @@ export class TW {
391399 }
392400
393401 if ( needsSoftRestart ) {
402+ let refreshPromise = retry ( {
403+ tries : 4 ,
404+ delay : 250 ,
405+ callback : ( ) => resolver . refresh ( ) ,
406+ } )
407+
408+ try {
409+ await refreshPromise
410+ } catch ( err ) {
411+ console . error ( 'Unable to reload resolver' , err )
412+ }
413+
394414 try {
395415 await this . softRestart ( )
396416 } catch {
@@ -429,6 +449,7 @@ export class TW {
429449 { globPattern : `**/${ CONFIG_GLOB } ` } ,
430450 { globPattern : `**/${ PACKAGE_LOCK_GLOB } ` } ,
431451 { globPattern : `**/${ CSS_GLOB } ` } ,
452+ { globPattern : `**/${ TSCONFIG_GLOB } ` } ,
432453 ] ,
433454 } ,
434455 )
@@ -477,7 +498,7 @@ export class TW {
477498 } else {
478499 let watch : typeof chokidar . watch = require ( 'chokidar' ) . watch
479500 let chokidarWatcher = watch (
480- [ `**/${ CONFIG_GLOB } ` , `**/${ PACKAGE_LOCK_GLOB } ` , `**/${ CSS_GLOB } ` ] ,
501+ [ `**/${ CONFIG_GLOB } ` , `**/${ PACKAGE_LOCK_GLOB } ` , `**/${ CSS_GLOB } ` , `**/ ${ TSCONFIG_GLOB } ` ] ,
481502 {
482503 cwd : base ,
483504 ignorePermissionErrors : true ,
0 commit comments