3

I have a sub project(it has a different git repo) and it has its own package.json etc.

parent app:

**tsconfig.json**
    "paths": {
    "subproject1": ["dist/subproject1"],
    "subproject1/*": ["dist/subproject1/*"],
    "subproject2": ["dist/subproject2"],
    "subproject2/*": ["dist/subproject2/*"],
  

angular.json

"subproject1": {
      "projectType": "library",
      "root": "projects/subproject1",
      "sourceRoot": "projects/subproject1/src",
      "prefix": "lib",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:ng-packagr",
          "options": {
            "tsConfig": "projects/subproject1/tsconfig.lib.json",
            "project": "projects/subproject1/ng-package.json"
          },
          "configurations": {
            "production": {
              "tsConfig": "projects/subproject1/tsconfig.lib.prod.json"
            }
          }
        },
      }
    },

app.module.ts

import { Subproject1Module } from 'subproject1';
import { Subproject2Module } from 'subproject2';
imports: [
Subproject1Module,
Subproject2Module
...

And we run ng build subproject1 && ng build subproject2 it will create its own classes inside dist folder and when we run ng serve everything is fine.

But I want to add a common library to be used among all these services. (in fact it is a lib created by openapigenerator)

inside parent app

libs/fontend/common-api

tsconfig.json:

"paths": {
  "@spec/frontend/common-api": ["libs/frontend/common-api/index.ts"]
}

angular.json

"common-api": {
  "root": "libs/frontend/common-api",
  "sourceRoot": "libs/frontend/common-api/src",
  "projectType": "library"
},

and to inject basepath:

app.module.ts
    CommonApiModule.forRoot(() => {
      return new CommonConfiguration({
        basePath: environment.apiGatewayUrl,
      });
    }),
    

The issue starts here:

I need to use this common api services inside subproject1

it gives error when i try to import it:

'rootDir' is expected to contain all source files.
mgnfcnt
  • 77
  • 11

0 Answers0