I am looking for some help with Angular7 libraries.
I have a project A in which I have developed two libraries - library 1 and library 2. The second library (library 2) has a dependency on the first library (library 1). Later, in another project, let's say project B I may use library 2.
My problem is with specifying that library 2 has a dependency on library 1. Currently, the two libraries are built in a folder libs/ in the root of the project - which makes library 2 imports from library 1 works with and without specifying that it has a dependency on library 1 in its package.json file.
Library 1 package.json
{
"name": "library-1",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^7.1.0",
"@angular/core": "^7.1.0"
}
}
Library 2 package.json
{
"name": "library-2",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^7.1.0",
"@angular/core": "^7.1.0",
"@angular/material": "7.2.0",
"library-1": "0.0.1"
}
}
Also, their build+dev location is specified in the main tsconfig.json file:
{
...,
"compilerOptions": {
...,
"paths": {
"library-1": ["libs/library-1", "projects/library-1/src/"],
"library-1/*": ["libs/library-1/*", "projects/library-1/src/*"],
"library-2": ["libs/library-2", "projects/library-2/src/"],
"library-2/*": ["libs/library-2/*", "projects/library-2/src/*"]
}
}
}
Is there a way where I can make it explicit that the second library does not compile if the first one is not installed?