Seeking assistance with Angular7 libraries.
In project A, I've created two libraries - library 1 and library 2. Library 2 depends on library 1. In a future project, like project B, I might utilize library 2.
The issue arises when specifying the dependency of library 2 on library 1. Currently, both libraries are stored in a folder called libs/ at the root level of the project. This setup allows imports from library 1 to work in library 2 without explicitly stating the dependency 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"
}
}
Their build and development locations are 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 to ensure that the second library does not compile if the first one is missing?