我可以使用SystemJsNgModuleLoader延迟加载angular-cli app中的本地模块,使用此评论中的建议:

How to manually lazy load a module?

我可以使用这个角度库生成器使用外部角度库模块的组件:

https://github.com/jvandemo/generator-angular2-library

所有这些都在同一个非常简单的angular-cli app中 . 但是当我从本地模块更改provideRoutes loadChildren param中的路由以尝试访问外部库模块时,我收到错误 . 似乎没有值我尝试loadChildren param成功访问外部角度库 .

这是我在 modtest app中尝试的一个堆栈跟踪:

ERROR in ./src/$$_gendir lazy
Module not found: Error: Can't resolve '...\modtest\src\node_modules\lib\lib.ngfactory.ts' in '...\modtest\src\$$_gendir'
resolve '...\modtest\src\node_modules\lib\lib.ngfactory.ts' in '...\modtest\src\$$_gendir'
  using description file: ...\modtest\package.json (relative path: ./src/$$_gendir)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: ...\modtest\package.json (relative path: ./src/$$_gendir)
    using description file: ...\modtest\package.json (relative path: ./src/node_modules/lib/lib.ngfactory.ts)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        ...\modtest\src\node_modules\lib\lib.ngfactory.ts doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        ...\modtest\src\node_modules\lib\lib.ngfactory.ts.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        ...\modtest\src\node_modules\lib\lib.ngfactory.ts.js doesn't exist
      as directory
        ...\modtest\src\node_modules\lib\lib.ngfactory.ts doesn't exist
[...\modtest\src\node_modules\lib\lib.ngfactory.ts]

注意它试图访问src目录下的node_modules目录!然后查找lib.ngfactory.ts文件 . 图书馆是否需要公开一些ngfactory课程?

有没有办法使用SystemJsNgModuleLoader访问外部库?或者块在哪里:angular,angular-cli或generator-angular2-library?所以我可以提出功能请求......

更新:要查看此代码的运行示例,请参阅以下具有使用说明的repo:https://github.com/neonguru/lazyloadtest