10up-toolkit
10up-toolkit copied to clipboard
Better graceful stop for `--hot` 🔥
Is your enhancement related to a problem? Please describe.
Hot is great for development and helps a lot during development. There're times thought in which you might want to save resources from watching, it could be because you're joining a call or compiling a kernel but then the stop here:
https://github.com/10up/10up-toolkit/blob/0c011c9a9138f0de7644984fd64356cb2965f41d/packages/toolkit/scripts/start.js#L55-L61
Will kill the whole dist
folder which leaves your site broken.
This is generally something we want. By doing this, we avoid constant polling but at the same time, we get a potentially broken site which is mitigated by doing an extra npm run build
afterward.
It has happened that I've stopped the build, joined a call to do a demo, and... had to do a build right after that. I can get used to it definitely but I thought about discussing if we want to just launch a last one build.
The drawback to this is that you get a slight delay when closing. I see 3 options if we end up adding this:
- Ignore the delay and move on with it
- Furiously repeat CTRL+C so you avoid both the
dist
removal and the build from happening - Add yet another option that enables this behavior
Before doing anything else I wonder what other people think about this scenario as, perhaps, it's just something that has bothered me and no one else.
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
I had a chat with @Antonio-Laguna about this in Slack. Essentially we agreed on the fact that even right now stopping the watch mode with the --hot
flag takes ages and feels like something is stuck in an infinite loop. I'm not concerned about prolonging the shutdown time with these enhancements.
Instead, I would love us to showcase to the user what is currently happening with some better status indications.
I'm fine with running a build after shutting down hot mode. I agree that showing what's going on would be ideal. Something along the lines of "cleaning up HMR and rebuilding". I think it would be good to have a better output than just a simple console.log (using colors perhaps).
We can even say something like "press CTRL+C again to stop immediatelly (this will result in a broken build)"