What is Nx library?

Library is an abstract concept for reusable part of our code base. It contains logic that can be accessed from different scopes through a well defined API.
Okay, but what is library?
Basically you write great code and don't want to repeat yourself, so you create library which can imported at certain point of your future program.
Okay, but why?
- less code to maintain
- less code to test
- less code to write
- less focus on element's implementation details
How Nx implements libraries?
nx g @nrwl/workspace:library --name=my-library

How it affects global workspace
UPDATE tsconfig.base.json
add ts alias for the library, so it can be easily imported by @...
UPDATE angular.json && UPDATE nx.json
add configuration options for library, it appends "project" attribute
UPDATE jest.config.js
add library to testing
Example of usage
We have car rental with two apps:
- web
- api
Both on front-end and back-end we will be using Car Entitiy
we create a library called entities, which later will be imported in both of them, as easily as an npm package with @ alias
Thanks for reading :-) Have a nice day ^^
