Nx: Lazy loaded lib not added to tsconfig(s) include.

Created on 6 Mar 2018  路  5Comments  路  Source: nrwl/nx

If lib added as --lazy and --parent-module specified as lib and not as app -
no changes to tsconfig.app.json and tsconfig.e2e.json would be written.

Include should be added.
Otherwise error thrown on serve:

ERROR in ./libs/crm-ui/user/index.ts
Module build failed: Error: C:\Users\alex\Documents\_dev\nx-test\libs\crm-ui\user\index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (C:\Users\alex\Documents\_dev\nx-test\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23)
    at plugin.done.then (C:\Users\alex\Documents\_dev\nx-test\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Steps to reproduce:

  • Add app
ng g app crm --routing
  • Add lazy lib
ng g lib access-control --routing --lazy --directory=crm-ui --parent-module=apps/crm/src/app/app.module.ts
  • Add another lazy lib to parent
ng g lib user --routing --lazy --directory=crm-ui --parent-module=libs/crm-ui/access-control/src/access-control.module.ts

Error fixed by manually adding following line to tsconfig.app.json include:

"../../../libs/crm-ui/user/index.ts",
feature

Most helpful comment

Folks. I'm going to close this issue. The new loadChildren syntax doesn't require you to update tsconfig files.

All 5 comments

Hi all,

I'm relabeling this as an enhancement instead of a bug. We do not yet incorporate multi-level dependency information into the generation of libs. So I am just labeling this as an enhancement to differentiate between providing new functionality and fixing existing functionality.

Related to #528

Nothing created with following command.

ng g lib grid1  --routing --lazy --prefix=ngx --parent-module=libs/dashboard/src/lib/dashboard.module.ts   --tags=child-module

Sample app to reproduce:
https://github.com/xmlking/ngx-starter-kit

Env:

"@nrwl/schematics": "^6.2.0",

Angular CLI: 6.1.2
Node: 10.7.0
OS: darwin x64
Angular: 6.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.7.2
@angular-devkit/build-angular      0.7.2
@angular-devkit/build-ng-packagr   0.7.2
@angular-devkit/build-optimizer    0.7.2
@angular-devkit/build-webpack      0.7.2
@angular-devkit/core               0.7.2
@angular-devkit/schematics         0.7.2
@angular/cdk                       6.4.3
@angular/cdk-experimental          6.4.3
@angular/cli                       6.1.2
@angular/flex-layout               6.0.0-beta.17
@angular/material                  6.4.3
@angular/material-moment-adapter   6.4.3
@angular/pwa                       0.7.2
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.1.2
@schematics/angular                0.7.2
@schematics/update                 0.7.2
ng-packagr                         4.0.1
rxjs                               6.2.2
typescript                         2.9.2

looks like above issue happens when we upgrade "@angular-devkit/build-angular": "^0.7.2",
if we rollback to ~~ ~~ "@angular-devkit/build-angular": "^0.6.8" routing/lazy works.

actually the issue is with typescript 2.9.2. after downgrading to 2.7.2 it looks like working !

Folks. I'm going to close this issue. The new loadChildren syntax doesn't require you to update tsconfig files.

Was this page helpful?
0 / 5 - 0 ratings