Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dominicbarnes opened this issue Jul 1, 2017 · 0 comments
Open

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

dominicbarnes opened this issue Jul 1, 2017 · 0 comments

Comments

@dominicbarnes
Copy link
Member

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

@dominicbarnes dominicbarnes changed the title Allow for skipping write when mtime is unchanged write: allow for skipping write when mtime is unchanged Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant