-
Notifications
You must be signed in to change notification settings - Fork 668
Description
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:
plugins: [
{
apply(compiler) {
compiler.hooks.done.tap(
'MyPlugin',
(/* compilation */) => {
if(compiler.options.watch) {
process.send('rush-continue');
}
},
);
}
}
]
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. Pressing CTRL + 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:
- IPC is enabled by default in the PR. This may introduce breaking changes and generally reduce performance. This should be an opt-in feature. I tried to add it to the options but it was a little difficult for me, so I chose to exclude it from the PR.
- When the task resolves itself, the writer is closed later on in the code. This means that any stdout/stderr needs to be suppressed in order for the code to work.
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status