Skip to content

Commit

Permalink
fix: prevent extra first recompilation
Browse files Browse the repository at this point in the history
See ream/ream#124 for the test case
  • Loading branch information
IlyaSemenov committed Oct 15, 2018
1 parent 4ac73cb commit b279099
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@ module.exports = class TimeFixPlugin {
apply(compiler) {
const watch = compiler.watch
let watching
let offsetApplied

compiler.watch = function () {
watching = watch.apply(this, arguments)
watching.startTime += this.watchOffset
return watching
}

compiler.hooks.watchRun.tap('time-fix-plugin', () => {
if (watching) {
watching.startTime += this.watchOffset
offsetApplied = true
}
})

compiler.hooks.done.tap('time-fix-plugin', stats => {
if (offsetApplied) {
if (watching) {
stats.startTime -= this.watchOffset
}
})
Expand Down

0 comments on commit b279099

Please sign in to comment.