Install Nx to Start Optimizing Your pnpm Workspace

Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated a year ago

Even running all your scripts at once will get slow and tedious as your project grows.

That's where Nx come in. Nx will generally optimize the experience with caching and selectively running commands.

Instructor: [0:00] As our PNPM workspace grows, we might want one to optimize some of the things that we do with it. For instance, running PNPM, let's say run -r build every time we push a new change to our repository. Every time we run a PR might not be feasible anymore, simply because it takes so long on our CI system, it will be overwhelming. [0:23] We might want to optimize some of the things in here and leverage things like caching or abilities to only run packages that got changed between the different PRs.

[0:34] One way to do that is by using Nx. Nx is a modern, fast, extensible built system that basically can sit on top of your existing PNPM workspace and do nothing else than providing you things like caching support, things like figuring out what changed and only running commands against that, and in general running tasks in a very efficient manner.

[0:56] Let's see how we can set up Nx on top of our PNPM workspace. For now, all that we need to do is run pnpm add. We need to add Nx package. We want to have it as a dev dependency because we don't really need it at runtime when we deploy our application or libraries. We want to install it at the workspace level, so the very root level package.json.

[1:19] Once Nx is installed, we can see now in the package.json at the root level, we got a new dev dependency. With that we are already set up.

egghead
egghead
~ 10 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today