chrisguttandin / angular-prerender

A command line tool to prerender Angular Apps.
MIT License
126 stars 7 forks source link

"Multiple root routing modules" error when one lazy loading module is loaded from another #112

Closed helix46 closed 4 years ago

helix46 commented 4 years ago

Hi @chrisguttandin Any help you can give would be appreciated

Error: Multiple root routing modules found /home/bryce/temp/prerender-multilevel-lazyload/src/app/lazy-level2/lazy-level2-routing.module.ts, /home/bryce/temp/prerender-multilevel-lazyload/src/app/app.module.ts

I've created an example app to demonstrate this.

git clone https://github.com/helix46/prerender-multilevel-lazyload.git cd prerender-multilevel-lazyload npm i ng build ng run prerender-multilevel-lazyload:server npx angular-prerender

guess-parser recognises that the first level lazy loaded routing module is not root, but does not see that the second level lazy loaded routing module is loaded by import from the first and is not root

Angular CLI: 9.0.6 Node: 12.16.1 OS: linux x64

chrisguttandin commented 4 years ago

Thanks, for reporting this @helix46. And many thanks for providing the test case. I can reproduce the error and I will try to fix it.

helix46 commented 4 years ago

guess-parser seem to have a couple of related issues that have been open for a month, so perhaps this is the same? https://github.com/guess-js/guess/issues/336 https://github.com/guess-js/guess/issues/335

chrisguttandin commented 4 years ago

Yes, I think the bug that you discovered is the same as the one reported in those issues. My patch meanwhile landed in guess-parser and I also updated angular-prerender. Version 5.2.3 contains the fix and when I test it with your repository it works as expected.

Thanks again for reporting this and please let me know if you run into any other issues.

helix46 commented 4 years ago

Wow so fast thank you Will test asap

helix46 commented 4 years ago

Yes, works fine on my test app thanks

chrisguttandin commented 4 years ago

Thanks for reporting back. Good to know that it works for you as well.