Skip to content

write: allow for skipping write when mtime is unchanged #14

@dominicbarnes

Description

@dominicbarnes

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.stat exists (null stats probably mean the file completely exists in memory)
  • the file located at file.path already 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions