无法从node_modules包中延迟加载模块

时间:2018-02-13 13:38:57

标签: angular typescript angular-cli tsconfig

动机:: 使用Angular CLI创建App Shell,并定义从node_modules内的包中延迟加载模块的路由。

步骤:: 使用Angular CLI创建了一个app shell。 参考了app.routes.ts

中的路线
const appShellRoutes: Routes = [
  { path: 'sample',  loadChildren : './sample#SampleModule' }// location in src/app,
  {path : 'visual-designer', loadChildren: 'visual-designer#VisualDesignerModule'} //location in node_modules
];

因为我需要配置带有path&的tsconfigs。 include tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": [],
    "paths": {
      "@angular/*": [
        "../node_modules/@angular/*"
      ],
      "visual-designer": [
        "../node_modules/visual-designer/*"
      ]
    }
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ],
  "include": [
    "../src/**/*",
    "../node_modules/visual-designer/*"
  ]
}

并在tsconfig.json中添加了include根级别

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "include": [
    "./src/**/*"
  ]
}

问题:: 在此之后我得到了这个错误

enter image description here

要求我通过includefiles

配置tsconfigs

我究竟错过了什么?看了这么多关于git的问题,发现只有这一个相关。 Git cli Issue

Angular CLI版本:1.6.7

0 个答案:

没有答案