Does angular 2 AOT support multiple startup page?

263 Views Asked by At

I currently have an [email protected] app which uses [email protected] for build and dev work. In this setup i have two startup pages index.html and login.html so both of them have their own separate booststrap and modules.This setup works just fine.

But now i am trying to Add AOT to the mix, and i am not able to make both work.

For example if index.html works then login.html gives me error "Error: The selector "my-app" did not match any elements". and similarly if login.html works then index.html gives me error "Error: The selector "my-login" did not match any elements".

So before i dig further, can anyone tell me if this scenario (of multiple entry) is possible with AOT?

2

There are 2 best solutions below

1
On BEST ANSWER

I think the answer may be "no". Please see this from the docs:

"With AOT, the compiler runs once at build time using one set of libraries; With JIT it runs every time for every user at runtime using a different set of libraries."

AOT only running once may explain the issue you're having.

0
On

I've was hoping AoT would have improved usability significantly by version 4.x but so far I'm unimpressed. I've found no information on whether or not multiple entry points are possible, but it appears not without considerable effort and the lack of useful error messages from the AoT process makes that doubly hard.

I do agree this would be a common use case, building multiple apps. The best I can tell is that you would need to have multiple build steps to do this, which is unfortunate.

AoT still feels very experimental to me. Error messages are uninformative when trying to work with it. If you stray from the happy path you are going to have a lot of trouble.