将导入的 angular 应用程序中的库用于多项目结构

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

我在 10.0.6 中有一个 angular 应用程序 a-app,但我需要将其包含到 angular 多项目结构中。在这个多项目结构中,我有一个 b-app 应用程序。

文件夹结构是这样的:

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)

但是当我尝试在多项目结构中的应用程序 a-app 中导入 my-lib 时,它不起作用!!!仅显示此错误:

我已将 a-app 中的所有配置文件修改为与 b-app 相似,将 a-app 包含在 angular.json 中,但仍然无法正常工作。实际上,我从这里执行了步骤 3-5:

我在此配置中缺少什么才能使其正常工作?

嗯...这是一个错误。

我在 a-app 应用程序中使用 Path mapping 这意味着我已经在 a-app 中的 tsconfig.app.json 中配置了 paths 属性 .

使用该配置,a-app 没有扩展 tsconfig.base.json 中的 paths 属性,因此找不到 my-lib在此文件上声明的路径。

解决方案:remove/check tsconfig.app.jsonpaths 中的任何配置以正确扩展 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/