-
Notifications
You must be signed in to change notification settings - Fork 2
Description
From @dominicbarnes on October 8, 2016 20:48
In the same vein as copy/symlink check mtimes before doing their operation, it would be nice if this plugin also had a mechanism to not do work when it isn't needed.
One thought I have is that if the following conditions are all true, skip writing: (with a debug log indicating that)
file.statexists (null stats probably mean the file completely exists in memory)- the file located at
file.pathalready exists file.stat.mtime < stat(file.path).mtime(ie: input file has not been modified since last output file modification)
My hope is that these conditions are so specific that they would not be met accidentally. (the hope is to avoid false positives that would cause someone's build to not go as expected)
In cases where a sub-tree of files is being combined into a single output file, (eg: js and css) my thought would be that during their "roll up", (aka: postdependencies they would bubble the latest mtime up to the top. Therefore, the mtime for the output file would be the latest mtime for the entire sub-tree.
As for any additional files being added to the tree, (eg: source map files) they could share file.stats with their parent file, which other plugins would need to know about to benefit from this behavior.
This behavior should hide behind a flag for now, but probably made the default in v2 if it turns out to be useful.
Copied from original issue: makojs/write#21