setrsin.blogg.se

Pnpm workspace monorepo
Pnpm workspace monorepo









With this, we now have a fully functioning monorepo and can share code between our applications! Wrap up You should see an alert with the text ‘Hello, Client User! You are not an admin.’ Once again, run the app and click the button. Add the following configuration options to it. For this example, we’ll be creating two React apps with Vite for our Admin and Client, and then having a shared project they both use code from.īefore we create those however, we need to setup our base tsconfig.json file. What we’re doing here is telling pnpm that we’ll have three projects that it needs to keep track of.

pnpm workspace monorepo

# pnpm-workspace.yaml packages : - "admin" - "client" - "shared" Open up the file and add the following lines to it. Here, we will configure all the different projects that we’ll have. Go ahead and run $ pnpm add -D typescript create a new file called pnpm-workspace.yaml. Now we can go ahead and add a couple of folders and files we’ll need.įirst, we should install our root package dependencies. Our project should now have a package.json for us to use. With pnpm installed, we can create a new Node project like so $ pnpm init

Pnpm workspace monorepo how to#

If you don’t have pnpm setup already on your system, head on over to for details on how to install it for your system.

pnpm workspace monorepo

It has quite a few noticeable improvements over both of them, including faster package installation, a non-flat node_modules structure, disk space optimization, and, what we care about, built-in monorepo support. Setting up our monorepo workspace with pnpm In this article, I’ll show you how you can setup a monorepo for a Node project using pnpm and TypeScript. Monorepos enable you to put all of your apps for a project in a single repository, share code between them, and more! And while this is not a new concept, modern tooling makes it easy to get one setup. Or maybe you have some code that you’d like to share between projects, but don’t want to deal with having to set up and manage an NPM package.Įnter the monorepo. Have you ever worked on a project where each app that was a part of it was in a different repository? It can be frustrating and time-consuming to deal with.









Pnpm workspace monorepo