gobblejs / gobble

The last build tool you'll ever need
333 stars 20 forks source link

Save checksums between builds, and extend checksum check to all transforms #25

Open Rich-Harris opened 9 years ago

Rich-Harris commented 9 years ago

Idea from @evs-chris (see https://github.com/ractivejs/ractive/issues/1544#issuecomment-65948239). Currently, the built-in map transformer (which orchestrates one-to-one file transformations) calculates a checksum of each input file, and sees if it matches the last checksum - if so, the transformation isn't repeated. (This might seem inefficient compared to e.g. checking timestamps, but it's intrinsically more reliable and turns out to be very fast).

This could happen in a more structured way - the check could happen before each transformation, and if it turned out that nothing had actually changed, none of the downstream transformations would need to be re-run. I think it's likely that the time saved on unnecessary transformations would outweigh the cost of performing the check. Transformers could potentially use this information themselves, if it was exposed as this.changes or similar (e.g. gobble-concat could simply reuse the previous result if the list of changes didn't include any of the files to be concatenated).

Furthermore, the results of the check could be saved to disk. That way, as long as the temporary files weren't discarded between builds (i.e. no-one deletes the .gobble folder), it ought to be possible to drastically cut down the duration of cold builds (because they wouldn't actually be cold).