-
Notifications
You must be signed in to change notification settings - Fork 627
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
Use a middleware only once #61
Comments
Sorry, but I don't think this is a good idea. The You'd have the same problem not only with middleware that should act once, but with any middleware that uses context from other files to produce it's output. |
That's a good abstraction of the problem. But I wonder: if this plugin is broken, why is it present on the official website? It encourages bad practices on Metalsmith development. Considering your answer, the only feasible solution would be to trigger the whole build again each time a file changes, there is three opinions on this:
For the last 2 suggestions, a cache system could be implemented in order to avoid excessive read-access, and only refresh the cache entries concerned by the modifications. I would really appreciate a functionality like this to faster my development with Metalsmith. I'm ok to do some development but I would like your way of thinking to work in the good direction. |
Author of metalsmith-watch here. I remember that we had this discussion before (about including a watcher in core) but that was out of scope that time. It is true that metalsmith-watch makes assumptions that will break with certain plugins but this is due to the fact that it is not feasible to rebuild the whole project for every file change. Furthermore metalsmith is not exposing a method to re trigger the build, so I had to hack around this to make metalsmith-watch work in the first place. I would be really glad if we could find a way to make this work. |
Which constraints restrain you from rebuilding the whole project on each modification? Is it for performance reasons? Doing so would ensure the build integrity. |
Hello,
In a classical workflow, every single plugin registered as a middleware is run once. But in a workflow using metalsmith-watch, each registered plugin is meant to be called several times.
The problem is: there is some metalsmith plugins (the ones not directly interacting with the files stream) which makes sense to only run once. Run them twice or more may be a waste of time. This could be the case with:
Therefore, I think it could be great to have the possibility to register a middleware which will only be called once. So the choice would be left to the developer judgment.
A code sample of how I see it:
What do you think?
The text was updated successfully, but these errors were encountered: