-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Allow delaying reprocessing on file change. #564
Conversation
Hmm, can we solve this by extending/exposing a configuration API to set chokidar options? In situations like this I’d rather defer to exposing configuration rather than solving it with more code internally. See: Maybe by adding an Object.assign to: This is similar to what we do with advanced BrowserSync usage here: |
Actually now that I think about it we may already allow customization of this, because you can set watchOptions in browser sync config: https://browsersync.io/docs/options#option-watchOptions Docs here: https://www.11ty.io/docs/config/#override-browsersync-server-options |
There may have been a bit of a miscommunication in the original issue. I actually already tried manually overriding the chokidar options on my own build but it doesn't solve the problem. The chokidar option I referred to ( Delays for eleventy processing are show way lower than they actually are, but lets just say it's 1000ms.
Now assuming we have a 200 ms delay configured and we have this change merged:
So unfortunately, just passing some configuration to to chokidar doesn't solve the problem. We explicitly need the ability to delay processing for some period of time. I referenced this in the issue, but I think it's worth referring to it here too, but gulp supports a delay option when watching files and it defaults to a non-zero value for the exact same reason we need it here. |
Those links will be wrong in the future. @zachleat if you are on the site, hit y to get a canonical URL (which will stay permanent over time). More tips hidden behind ? :-) |
@zachleat - Any further thoughts on this? I've been using this for a week now and while it's only one user it seems to be working pretty well for me. |
Hey @zachleat. I'm still hoping to get this merged if possible. Please let me know if there's anything else that you'd like to consider and I'll try to make the change so we can get this closed. |
Resolves #559
Add support for specifying a delay after a file change occurs after which Eleventy will start reprocessing the input files. As a super simple example, if you have two files open in an editor and you are running
eleventy --serve
and then you execute a save all eleventy will:This double processing can be time consuming for large projects and is especially noticeable when you have additional external tools running to modify files (like SASS). If you change a single SASS file, the SASS tool will run and regenerate all CSS files, and the first one to finish will trigger eleventy to rebuild, and then they will immediately re-process a second time after that.
This PR add support for a new config property
watchTriggerDelay
(open for alternate suggestions). IfwatchTriggerDelay
is provided eleventy will wait until that long AFTER the last file change occurred before it starts reprocessing. This means that if you setwatchTriggerDelay
to 10 seconds, and save a file, and then wait 5 seconds and save a second file, then it will wait another 10 seconds before starting to process any changes.As a side-effect of this change, we now also queue up any file changes that do occur while we're processing and will refresh all of them instead of just the very last one. This change does NOT attempt solve the fact that file changes during processing can result in unexpected output, but it will still trigger an immediate re-process immediately afterwards for any changes that didn't make it into the first "batch".
This change is using an async sleep method by the
es7-sleep
package, but it's an incredibly minimal implementation so if you'd prefer dropping that dependency we can move it directly into eleventy.