From 242f1019c879ff5f522498cb329a68146e4d3a53 Mon Sep 17 00:00:00 2001 From: elf-mouse Date: Thu, 22 Apr 2021 17:22:52 +0800 Subject: [PATCH] fix: times is not iterable bug --- src/watch-run.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/watch-run.ts b/src/watch-run.ts index 8380404ea..6123f77bf 100644 --- a/src/watch-run.ts +++ b/src/watch-run.ts @@ -31,20 +31,24 @@ export function makeWatchRun( } else { const times = compiler.fileTimestamps; - for (const [filePath, date] of times) { - const key = instance.filePathKeyMapper(filePath); - const lastTime = lastTimes.get(key) || startTime; + if (times) { + for (const [filePath, date] of times) { + const key = instance.filePathKeyMapper(filePath); + const lastTime = lastTimes.get(key) || startTime; - if ( - !date || - date === 'ignore' || - (date.timestamp || date.safeTime) <= lastTime - ) { - continue; - } + if ( + !date || + date === 'ignore' || + (date.timestamp || date.safeTime) <= lastTime + ) { + continue; + } - lastTimes.set(key, date.timestamp || date.safeTime); - promises.push(updateFile(instance, key, filePath, loader, loaderIndex)); + lastTimes.set(key, date.timestamp || date.safeTime); + promises.push( + updateFile(instance, key, filePath, loader, loaderIndex) + ); + } } // On watch update add all known dts files expect the ones in node_modules