Matthias Hryniszak
Posted on November 22, 2023
I've been doing node and frontend for years now. More than anything, it bugs me that some things that should be simple are so darn difficult. For example, setting up projects...
The bad
Imagine you have a monorepo that contains a common library and two projects that use it. It makes perfect sense that you'd like them to be in dev mode at the same time, so that during development you can treat the whole thing as a whole. It's just easier to think about it this way...
The ugly
There is a catch, though. You can't start the dev server for your apps until the common library is done. So what do you do? you start the build watch in one console and once that has finished you start the next console and run the build for your app1 and a third console for the second app.
To say that it is tedious is like not saying at all.
And then there's the final build...
Of course, you can employ tools like turbo
for the final build (doesn't work for dev mode as you can't dependOn
persistent tasks!) and it works quite well, but then you ask yourself, why is that tool so stupid? If I already have a build
task in all my projects, why do I have to again express that build
depends on build
? That's ridiculous, to say the least.
mrdr to the rescue!
mrdr
(pronounced appropriately /mordor/) is exactly what you would expect a runner like that to be. It assumes that your build task is called build
and that your dev task is, well, called dev
.
When you have things laid out like that, all you need to do to start your dev environment is:
npx mrdr
and off you go. The build -w
will keep on running but once all the exports
are there, it will continue on with projects that depend on them.
It really is that simple!
If you want to build your project in order you run
npx mrdr build
and life is good again. No more wait-on
, no more turbo.json
, no more hassle.
Credits
Although I wrote mordor myself there is a person that deserves recognition. Aleksej Dix pushed me to do it. I was thinking of it for a long time, hoping that some other person will do it instead, but he finally bugged me so much I've had to do it. Thank you, Aleksej, for being such a good friend!
Posted on November 22, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.