diff --git a/src/index.ts b/src/index.ts index 9f7fd1901..7a31e1d84 100644 --- a/src/index.ts +++ b/src/index.ts @@ -421,6 +421,17 @@ function updateFileInCache( instance.changedFilesList = true; } + // instance.version must be increased when a new root file is added. + // + // Note that the file could actually be in the cache if it was found + // as a dependency before. + // + // See https://github.com/TypeStrong/ts-loader/issues/943 + // + if (!instance.rootFileNames.has(filePath)) { + instance.version!++; + } + if (instance.watchHost !== undefined && contents === undefined) { fileWatcherEventKind = instance.compiler.FileWatcherEventKind.Deleted; }