-
Notifications
You must be signed in to change notification settings - Fork 15
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
Do not rewrite files when content did not change #8
base: master
Are you sure you want to change the base?
Conversation
Thanks for contributing! Makes sense not to write file more than nessesary, but I don't see why your git repo gets dirty. It is simply touching the file. |
🤦♂️ sorry, I forgot to add that to the description, my bad... I still don't understand why it is taking so long to write to do the write, but here is what I have found. My primitive benchmarkingI added a really primitive benchmarking, in my local setup const start = +new Date();
fs.writeFile(outputPath, printFlowDefinition(tokens), {}, function() {
console.log(+new Date() - start);
}); And this gives me values that range from 1ms to 2000ms... I wonder if it because there are too many Info about the projectNode version: 8.6.0 |
Further investigationIt seems that |
Still missing it seems. : ) I would like to understand why writing/touching a file is a problem on your system. It should not cause any unstated files in git. Are you checking in the .css.flow files? Performance slow down is the reason why I'm not reading the file. IO is expensive here. Especially inside a webpack loader. |
In the diffs shown here it look like the file content were removed... or am I missing something? |
Yes I'm checking in the |
Here is a minimal repro case for this issue ttps://github.com/rogeliog/fs-write-weird-issue I don't know exactly why it happens, but think it has to do with how I wonder if we should use See https://github.com/rogeliog/fs-write-weird-issue for more details about this gif |
Any thoughts? |
@rogeliog sorry I've been a bit busy. It seems like this is an issue on some machines... Wondering a bit why I haven't seen the issue before.
Not sure if that will slow down webpack a lot. But please give it a try if you have time. Can you see how much reading and writing the file affect webpack performance? Like you touch a .css file and see how long a rebuild takes. |
Thanks for the reproducible repo! |
To me this seems like a good idea in general (performance-wise), regardless of the bug. |
How about using a local cache to store file content based on |
Good idea. 👍 |
I'm not using Flow nor CSS Modules anymore, so not invested 🤷 |
First of all thanks for all the great work on this package,👏 it has been super useful!
I know that there is no open issue for this, so feel free to close this PR if this does not go with the direction of the project.
TL;DR
Don't write a new version of the
.css.flow
file if the contents did not change.The problem
Every time that a file is changed our git repo gets dirty, making it hard to do