huozhi / bunchee

Zero config bundler for ECMAScript and TypeScript packages
https://npmjs.com/bunchee
948 stars 29 forks source link

fix: algorithm for determine the end of build in watch mode #438

Closed nnecec closed 10 months ago

nnecec commented 10 months ago

if we print console.log(startTime, watcherCount) in end function, it looks like:

❯ bunchee -w
Watching project /Users/nnecec/Github/bunchee...
523.054045021534 1
523.054045021534 2
523.054045021534 3
523.054045021534 4
✓ Build in 3250.67ms
523.054045021534 5
523.054045021534 6
523.054045021534 7
523.054045021534 8
523.054045021534 9
523.054045021534 10

logWatcherBuildTime will be executed only once at the beginning. So we need reset startTime and watcherCount in the start function.

Also, if we modify a file, it may not trigger a rebuild of all the entry files, so the watcherCount maybe not equal to result.length.