【问题标题】:AngularCompilerPlugin with multipe node_modules folders具有多个 node_modules 文件夹的 AngularCompilerPlugin
【发布时间】:2019-10-19 22:33:57
【问题描述】:

我正在开发一个包含多个 Angular (v7) 应用程序的单一存储库。

使用 webpack 进行 Angular AOT 编译给我带来了麻烦。

顶层结构如下所示:

  • 申请01
    • node_modules
    • 源代码
  • 申请02
    • node_modules
    • 源代码
  • ...
  • 共享
    • node_modules
    • 源代码

所有应用程序都可以使用共享文件夹中的代码。在运行 AngularCompilerPlugin 的第二个编译阶段之前,一切都运行良好。

它会抛出如下错误:

Module not found: Error: Can't resolve '../../../../../../../Shared/node_modules/@angular/material/button/typings/index.ngfactory'

共享文件夹中的组件和服务似乎没有被创建和/或包含在编译中。

有没有人遇到过类似的问题?

是否可以让 AngularCompilerPlugin 包含来自多个源目录的工厂文件?

感谢您的帮助。

【问题讨论】:

    标签: angular webpack monorepo angular-aot


    【解决方案1】:

    我在项目中只有一个具有相同结构的 node_module 文件夹。我使用nrwl/nx 获得更多工作空间。

    See it on github

    我的结构:

    apps
      - app1
         - src
      - app2
         - src
    libs
      - shared1
         - src
      - shared2
         - src
    node_modules
    

    为什么需要更多 node_modules?

    【讨论】:

    • 感谢您的回答@ErikHer。也许你建议的结构会更好。我一定会考虑的。但是,由于在没有 AOT 的情况下编译东西时一切正常,我仍然想了解如何在我的特定设置中使用 AngularCompilerPlugin。
    猜你喜欢
    • 2017-02-05
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多