angularangular-librarymulti-project

Use a library in an imported angular application into multi-project structure


I've an angular application a-app in 10.0.6, but I need to include it into an angular multi-project structure. In this multi-project structure, I have a b-app application.

Folder structure is this:

my-workspace/
  ...             (workspace-wide config files)
  projects/       (generated applications and libraries)
    a-app/        --(imported application manually)
      ...         --(application-specific config: karma.conf.js, tsconfig.app.json, tsconfig.spec.json)
      src/        --(source and support files for application)
    b-app/ --(an explicitly generated application)
      ...         --(application-specific config)
      src/        --(source and support files for application)
    my-lib/       --(a generated library)
      ...         --(library-specific config)
      src/        --source and support files for library)

But when I try to import my-lib in application a-app in the multi-project structure, it's not working!!! Just displays this error:

I've modified all config files from a-app to be similar to b-app, included the a-app in the angular.json, but still not working. Practically, I did steps 3-5 from here: Adding Angular application to an existing project

What am I missing in this configuration, to make it work?


Solution

  • Well... It was a mistake.

    I'm using Path mapping in a-app application which means that I had configured the paths property in tsconfig.app.json inside a-app.

    With that configuration, the a-app didn't extend the paths property in tsconfig.base.json, therefore, it couldn't find the my-lib path declared on this file.

    Solution: remove/check any configuration in your paths in tsconfig.app.json to extend properly the tsconfig.base.json

    my-workspace/
      tsconfig.base.json <--- this file contains all libraries declared
      projects/       
        a-app/        
          tsconfig.app.json <--- Check this file in order to extend properly the tsconfig.base.json
        b-app/
          tsconfig.app.json
        my-lib/
          ...
          src/