jvandemo / generator-angular2-library

Yeoman generator to create an Angular library
MIT License
752 stars 122 forks source link

Routing with lazy loaded modules, AOT compilation #280

Closed mateusz-klosinski closed 6 years ago

mateusz-klosinski commented 6 years ago

Hi, I have created a library that contains smaller modules inside. Every module has it's own 'small' routing inside taking care of simplest crud operations for every model. Then in the top module I am loading those modules with loadChildren with 'url#ModuleName'. So far so good. Everything is working fine until I try AOT compilation.

My problem is that when I build this package and ship it to another app I don't know how to tell angular that this small modules aren't available at theirs location but inside flat index.js file. When I am trying explicitly type'(..)/index.js#Module' he tries to find it in 'index.d.ts' file and I receive error about not shipping '.ts' files in npm package...

Has anyone tried something similiar? I honesly am out of options.

I am sorry if i put my question in wrong place.

EDIT I managed to give good path like "library-name#Module" and compiled successfully but now I have an error

Error: Runtime compiler is not loaded

So my compiled package with module inside is treated like not compiled?

EDIT I solved this by moving every path building with loadChildren to app which receives the package and providing only modules and components inside library.

DhiaEddineSaidi commented 6 years ago

hello @mateusz-klosinski can you give me an example , i did not understand how : give good paths like "library-name#Module" ? moving every path building with loadChildren to app which receives the package and providing only modules and components inside library ?

PLEASE HELP THANKS

deepthan commented 6 years ago

hi @mateusz-klosinski ,can you give me an example? I tried but failed. thanks.