About 6 months ago I was struggling with dealing with config issue, mono repo perf issues and a few other things and stumbled across NX.
I quickly started using their project templates for React, Express, Node etc which was good for a time, but now the plugins it comes with for these tools are stopping me from adopting some of the really interesting tools coming out in the node ecosystem. Similar to when you hit the edge of Create React App. I want to use ESBuild, and Vite and TypeScript project references in my repos.
The good news is that NX provides a heap of value without using all the plugins it comes with, read on to find out why looking further into NX is worth your time.
So why NX?
The primary function of NX is a mono repo tool, it gives you a few things:
- Workspace management — to manage the projects in your repo
- A plugin system — to extend NX with your own project templates/runners
- E2E testing tools for your plugins — high level APIs to write tests against a temporary workspace create for your test
- Affected build calculation (only build what has changed)
- A VSCode extension to surface plugins and their options
They then have a bunch of plugins out of the box allowing you to quickly add libraries which can be published to NPM, or React apps.
This is an awesome productivity boost, because all of the projects come with build/lint/test steps configured out of the box.
BUT these plugins are not the best part of NX, depending on your requirements you may have skipped looking further into NX because of these plugins not fitting your requirements.
Instead I think the value is the core plugins
They allow you to create your own plugins really easily. The docs for doing this is available at https://nx.dev/latest/node/executors/creating-custom-builders
I am also working on a blog post on building your own because the docs don’t do a great job on selling how easy it is to create your own. It took me about 2 hours to figure out how to build an NX plugin which could bootstrap a node project which uses ESBuild to bundle and can be served using ESBuild in watch mode with Nodemon to restart it
I’ve been getting heaps of value from NX while still using the tools I already enjoy.
- PNPM as my package manager
- Changesets to version and publish my NPM packages
- TypeScript project references to keep type checking fast
- TSUP to package my NPM packages before publish
- Pulumi to deploy my applications
I have started building NX generators around these tools to make using these tools easier with NX but you can get a long way with the inbuilt Run command executor.