When compiling an Angular library, I am getting this error concerning rootDir of my sub libraries
library/services/src/public-api.ts:31:15 - error TS6059: File 'C:/libname/library/services/src/orders/orders.service.ts' is not under 'rootDir' 'C:/libname\library\classes\src'. 'rootDir' is expected to contain all source files.
I have come to understanding that it is not a good practice to use relative imports inside Angular library between individual secondary entries. So I have divided my code into secondary entries + setup paths in TSConfig
Code structure
library
services
src
public-api.ts
package.json
models
src
public-api.ts
package.json
src
public-api.ts
package.json
TSConfig
{
"rootDir": "./library/",
"paths": {
"@core/services": [ "library/services/src/public-api.ts" ]
}
}
angular.json
{
"projects": {
"lib": {
"root": "library",
"sourceRoot": "library"
}
}
}
So the question is - how to fix imports between individual secondary entry points or file structure and make the project compile okay? I understand that the compilation of secondary entry points is separate and "treated as a separate project", hence the error. Should I therefore add individual secondary entry points as peer dependencies?
Of course there are more paths and secondary endpoints - But that is irrelevant for the issue, this is enough to show my file structure and setup