Nx - The fastest growing monorepo solution in the JS ecosystem

Juri Strumpflohner - Jun 29 '22 - - Dev Community

EDIT(Sep 9th, 2022): approaching 2.5 million


Nx just crossed 2 million NPM downloads / week (see @nrwl/tao package on npm).

And these are just the public downloads which do not include all the big fortune 500 companies using Nx on a daily basis to power their teams.

But it is not just about the number of downloads, but about the growth: Nx crossed 1 million per week in January 2022 and now 2 million in June 2022.

Nx growth

At this point you might now be wondering: what is Nx and what are monorepos? Let's start with monorepos first.

What is a monorepo?

The term "monorepo" is kind of misleading, but in principle it is a single (usually) Git repository hosting multiple projects. Those projects ideally form relationships among them by sharing and re-using functionality.

Monorepo

The advantage for developers? If done right, increased productivity by being able to directly use shared dependencies rather than going through versioning & publishing to internal registries, being able to easily run cross-cutting experiments, do a refactoring with a single PR rather than coordinating multiple releases & version updates, more visibility to other projects & greater developer mobility among teams. These are just some of the benefits.

The exact setup of a monorepo comes in different shapes, from using a single-version policy approach to colocating packages with their own node_modules folders and applying symlinks for sharing code.

You can learn more at https://monorepo.tools.

What is Nx?

The official slogan: "a smart, fast and extensible build system". Does that mean it is a replacement for Webpack, Vite, SWC or Vite? Not really! At its core Nx is rather an orchestrator that applies these tools in the most efficient way.

Monorepo support is built into Nx's DNA. You can use Nx..

Light-weight and incrementally by leveraging it's powerful task scheduler. This is especially interesting if you already have a yarn/npm/pnpm workspace based monorepo setup and you want to enhance its capabilities. If you happen to use Lerna you might want to read this.

Here's an example for showing the lightweight setup of Nx, by incrementally adding it to an existing Yarn workspaces monorepo:

Using its plugin system which comes with powerful support for Angular, React, Next, Next.js, Node and more. These plugins are more opinionated, but carefully crafted to provide the best possible developer experience and remove the burden of a manual tooling setup. Furthermore it comes with advanced features such as automated module federation setup or automated code migrations, a feature that is highly appreciated by large enterprises which otherwise struggle to keep their tooling up to date.

Here's an example of developing a React application using Nx's powerful plugin system:

Learn more at nx.dev and on Youtube. You might also find this free Egghead course interesting.

How does Nx compare to other monorepo tools in the space?

  • Nx offers the full spectrum, allowing for an incremental and lightweight adoption to providing a more complete and preconfigured experience based on plugins. It does not just help setup a monorepo and execute tasks, but also guides developers throughout the development lifecycle.
  • Nx is faster than most of the current available alternatives. See the corresponding benchmark repository
  • Nx provides the ability to distribute the execution of tasks efficiently across multiple machines, known as Distributed Task Execution (DTE). This is possible via Nx Cloud and provides major performance improvements on CI.
  • Nx has a particular focus on the developer experience. A dedicated VSCode extension and a beautiful terminal output are just two examples for that.
  • Nx is extensible, coming with its own devkit which allows to fully customize and tailor the Nx experience to your own needs.

Nx Community

There's a large community behind Nx which can be found at https://nx.dev/community.


Learn more

🧠 Nx Docs
πŸ‘©β€πŸ’» Nx GitHub
πŸ’¬ Nrwl Community Slack
πŸ“Ή Nrwl Youtube Channel
πŸ₯š Free Egghead course
🧐 Need help with Angular, React, Monorepos, Lerna or Nx? Talk to us πŸ˜ƒ
πŸ›  monorepo.tools

Also, if you liked this, click the ❀️ and make sure to follow Juri and Nx on Twitter for more!

#nx

Some of the latest announcements:

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player