@@ -161,15 +161,15 @@ export const system: ControlledTypeScriptSystem = {
161
161
isInitialRun = false ;
162
162
} ,
163
163
invokeFileCreated ( path : string ) {
164
- const normalizedPath = realFileSystem . normalizePath ( path ) ;
164
+ const normalizedPath = normalizeAndResolvePath ( path ) ;
165
165
166
166
invokeFileWatchers ( path , typescript . FileWatcherEventKind . Created ) ;
167
167
invokeDirectoryWatchers ( normalizedPath ) ;
168
168
169
169
deletedFiles . set ( normalizedPath , false ) ;
170
170
} ,
171
171
invokeFileChanged ( path : string ) {
172
- const normalizedPath = realFileSystem . normalizePath ( path ) ;
172
+ const normalizedPath = normalizeAndResolvePath ( path ) ;
173
173
174
174
if ( deletedFiles . get ( normalizedPath ) || ! fileWatcherCallbacksMap . has ( normalizedPath ) ) {
175
175
invokeFileWatchers ( path , typescript . FileWatcherEventKind . Created ) ;
@@ -181,7 +181,7 @@ export const system: ControlledTypeScriptSystem = {
181
181
}
182
182
} ,
183
183
invokeFileDeleted ( path : string ) {
184
- const normalizedPath = realFileSystem . normalizePath ( path ) ;
184
+ const normalizedPath = normalizeAndResolvePath ( path ) ;
185
185
186
186
if ( ! deletedFiles . get ( normalizedPath ) ) {
187
187
invokeFileWatchers ( path , typescript . FileWatcherEventKind . Deleted ) ;
@@ -205,8 +205,7 @@ function createWatcher<TCallback>(
205
205
path : string ,
206
206
callback : TCallback
207
207
) {
208
- const normalizedPath = realFileSystem . normalizePath ( path ) ;
209
-
208
+ const normalizedPath = normalizeAndResolvePath ( path ) ;
210
209
const watchers = watchersMap . get ( normalizedPath ) || [ ] ;
211
210
const nextWatchers = [ ...watchers , callback ] ;
212
211
watchersMap . set ( normalizedPath , nextWatchers ) ;
@@ -226,7 +225,7 @@ function createWatcher<TCallback>(
226
225
}
227
226
228
227
function invokeFileWatchers ( path : string , event : ts . FileWatcherEventKind ) {
229
- const normalizedPath = realFileSystem . normalizePath ( path ) ;
228
+ const normalizedPath = normalizeAndResolvePath ( path ) ;
230
229
if ( normalizedPath . endsWith ( '.js' ) ) {
231
230
// trigger relevant .d.ts file watcher - handles the case, when we have webpack watcher
232
231
// that points to a symlinked package
@@ -243,7 +242,7 @@ function invokeFileWatchers(path: string, event: ts.FileWatcherEventKind) {
243
242
}
244
243
245
244
function invokeDirectoryWatchers ( path : string ) {
246
- const normalizedPath = realFileSystem . normalizePath ( path ) ;
245
+ const normalizedPath = normalizeAndResolvePath ( path ) ;
247
246
const directory = dirname ( normalizedPath ) ;
248
247
249
248
if ( ignoredPaths . some ( ( ignoredPath ) => forwardSlash ( normalizedPath ) . includes ( ignoredPath ) ) ) {
@@ -272,6 +271,16 @@ function invokeDirectoryWatchers(path: string) {
272
271
) ;
273
272
}
274
273
274
+ function normalizeAndResolvePath ( path : string ) {
275
+ let normalizedPath = realFileSystem . normalizePath ( path ) ;
276
+ try {
277
+ normalizedPath = realFileSystem . realPath ( normalizedPath ) ;
278
+ } catch ( error ) {
279
+ // ignore error - maybe file doesn't exist
280
+ }
281
+ return normalizedPath ;
282
+ }
283
+
275
284
function isArtifact ( path : string ) {
276
285
return (
277
286
( artifacts . dirs . some ( ( dir ) => path . includes ( dir ) ) ||
0 commit comments