0

I have packaged an angular feature module with routing details as npm dependency and uploaded to my git. I am trying to add this dependency to another application and lazy load the module. This results in below error,

ERROR in ./node_modules/module1/module1.d.ts
Module build failed: Error: Debug Failure. False expression: Output generation failed
    at Object.assert (C:\AAA\MULTIMODULE\PORTAL WITH MODULES\portal2\AngularMain\node_modules\typescript\lib\typescript.js:3284:23)
    at Object.transpileModule (C:\AAA\MULTIMODULE\PORTAL WITH MODULES\portal2\AngularMain\node_modules\typescript\lib\typescript.js:79313:18)
    at TypeScriptFileRefactor.transpile (C:\AAA\MULTIMODULE\PORTAL WITH MODULES\portal2\AngularMain\node_modules\@ngtools\webpack\src\refactor.j
s:182:27)
    at Promise.resolve.then.then.then.then (C:\AAA\MULTIMODULE\PORTAL WITH MODULES\portal2\AngularMain\node_modules\@ngtools\webpack\src\loader.
js:598:41)
 @ ./src/$$_gendir lazy
 @ ./node_modules/@angular/core/@angular/core.es5.js
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

MainAppln NgModule:

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    RouterModule.forRoot(
      [
        { path: 'external', loadChildren: 'module1#AppModule1' } 
      ], { useHash: true, enableTracing: false }
    ),
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Angular Environment details

"@angular/cli": "^1.6.0",
"@angular/compiler": "^4.3.2",
"@angular/compiler-cli": "^4.3.2"
"typescript": "2.3.0"

The same above application works fine if I do not add any routing information to the module which is compiled and added as npm dependency.

Is there any limitation that we can not load a feature module dependency with routing details ?

If not, any idea what went wrong in my code ? I am not sure which part of code should I paste here, so I am pasting the source code git for the dummy project which I have created.

Git for Main appln : https://github.com/rajagopalmani/AngularMain

Git for dependency : https://github.com/rajagopalmani/AppModule1

Raja
  • 627
  • 1
  • 9
  • 24
  • The problem is most likely due to the fact you are referencing the module via loadChildren. Angular has no way of knowing where that module is (no import to point it in right direction). – Adam Greene Feb 01 '18 at 04:31
  • Hi Adam Greene, I tried adding the module in import as well. But it didn't help. – Raja Feb 01 '18 at 04:52

0 Answers0