Adding the first library

How to add Angular library to monorepo

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the Next-Level Angular Apps with NX course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Next-Level Angular Apps with NX, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Next-Level Angular Apps with NX
  • [00:00 - 00:29] Now it's the time to add the first Angular library that we will use later in our time tracking application. Similarly, the applications you can easily add a new library to your manner repo using a straightforward command. So, yarn, annex, g for generate, annex Angular library, the path to your library. So, we will use the recommended layout, leaps/name of our library, and of course, a prefix for Angular.

    [00:30 - 00:42] So, that's what we are going to execute. As you can see, generating is a very fast process. We have a list of created files and the last file, that's create.base.json was updated.

    [00:43 - 01:33] So, let's check how it looks like. cat, ts, config, base.json. And as you can see, path's configuration was added. So, from this point, we can access our library using path at time tracker/timetracking state lib. So , let's check what was generated for us by annex. First of all, let's list the files. And as you can see, we have a leaps directory. So, let's access it. And inside of our leaps directory, we have time tracking state lib that I have just created. So, let's access it. And again, let's list the files. And as you can see, our new library has separate jest config, separate ts config.

    [01:34 - 02:01] And if you are going to list all files, even the hidden ones, you will see that we have even separated as lint airc config, which means that every library in your mono repo can be configured separately. It gives you a huge flexibility in organizing your code in your repository. In crucial parts of your application, you can have a very strict configuration.

    [02:02 - 02:36] So, for example, you can have a lot of as lint roles that force a very secure code. And in different parts of your application, you can have different configuration. And again, you can have less as lint roles if you need. You can have different type script configuration, different jest plugins. So, basically, you can configure everything you want in every place separately. Now , you know how to add a simple library to your mono repo. In the next lesson, we will use the app and library we have just generated to create a simple time tracking application.