-
Notifications
You must be signed in to change notification settings - Fork 604
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
[rush] Avoid cold start overhead by allowing a toolchain process to continue running (as with "webpack --watch") #1151
Comments
In addition to incremental build performance, isn't hot-module-reloading an important usecase of webpack --watch? |
@wbern I think you might have forgotten to hyperlink the repo that demos your feature. :-P I'm very curious to see that. |
Is the idea that you want Rush to spawn a separate If so, how scalable is this for a repo with 1000+ projects in it? Also is there a race condition, e.g. if an application starts compiling before a library that it depends on has been built? |
My naive approach was, that rush build could be triggering watch instances, or it wouldn't even know about it (except that ipc is enabled). The rush build is complete, it would not perform any more logic, but still not exit from terminal, since there are watch scripts running async in the background. The problems and solutions I guess would be Problem 1. Rush doesn't know about which processes have gone to the background. Problem 2. Rush build has already ended, nothing more can be done. Problem 3. How is this going to scale with 1000+ projects
I get really excited thinking about this functionality, I hope you see what I mean. |
As a small update, I have started coding something that works outside of rush. Basically rush builds projects, and the projects create job requests which connect to an ipc server that determines if there's a job running already or not, and if there is, waits for that job to finish before exiting, so rush can work as normal. Putting this functionality inside rush would make things easier for other devs, but at the same time, it might break design. |
I agree this is a kickass feature, and we should aim to make it as easy as possible for people to use. If there are toolchain-specific complexities, perhaps Rush could provide two modes: "Basic" where Rush does everything for you using naive assumptions, and "Advanced" where Rush gets things going, but then uses a contract (e.g. IPC) to hand off the real work to a custom service (e.g. that understands idiosyncrasies of a particular tool chain). I apologize that I haven't had time to give this feature the attention it deserves. My main design feedback is that there should really be a single central service that watches all the files in the repo folder. It should certainly be driven by per-project configurations, as it needs to keep the projects isolated; we shouldn't even assume that the files being "watched" are being consumed by the same task type (webpack, jest, sass whatever). But without a central coordinator, the design seems like it will fall down very quickly as we scale. For example, I have a small Rush repo with only one library and one application. What I do today is manually run The If you get some "down time" hanging out at the office watercooler or doing the family dishes or whatever, I'd encourage you to think in depth about the right solution to monorepo watching. If you can work out a solid design, it's very likely people will show up to help you code it as a Rush feature. We all absolutely share your excitement about this idea. :-) |
Since handling non-terminating watch processes in task-runners is a common problem, maybe we can come up with a protocol, that can be used by all watch-tasks and task-runners. Here's a proposal of mine: https://github.com/VanCoding/task-graph-protocol I'd really like to get the discussion started here: VanCoding/task-graph-processor#3 |
I made a minor note about this functionality in this thread: #1122. This turned out to be really important for us in order to make the switch to Rush, as frontend developers.
What?
Rush currently offers incremental builds, which is great for building as little as possible. However, due to the monolithic nature in the industry of frontend development, there are many tools that ship "watch" instances of themselves, webpack for example, that will keep a running instance of itself, and process changed files immediately as they change. If you are running many small apps (micro-frontends), this might be bearable with the way Rush builds today, but for the larger monolithic webpack-powered apps, this is simply way too much time spent waiting for builds to complete.
What I am requesting is the ability to let build scripts executed by Rush request themselves to be considered "complete", and be sent to background so that Rush can proceed to execute the next script that may or may not have relied on the previous one(s).
Why?
While Webpack 5 is going to specialize in saving the current cache to disk, monolithic applications are literally everywhere, and with the presence of frameworks like Angular, React and Vue, they're likely not going away anytime soon.
At the same time, nodejs offers a complete cross-platform solution for IPC between parent processes and child processes. Surely this should not be a difficult thing to do.
How?
I have made a PR to this Repo that shows how simple it is to do it.
After incorporating this change, all you would need in a typical webpack config is:
After doing this, Rush build will complete and say
rush rebuild (46.61 seconds)
, but will keep running instead of exiting with a zero code. PressingCTRL + C
will exit it, and all IPC-connected spawned processes will exit in the background as well.This PR of course needs to be improved, as the following issues remain:
Enabling this functionality would make us able to use Rush in production, and finally move from Lerna's open-ended nature and into a documented and scalable monorepo manager which is Rush.
Thanks for reading.
The text was updated successfully, but these errors were encountered: