Skip to content

AOT with multiple root module #4624

Closed
@hikalkan

Description

@hikalkan

OS?

Windows 10

Versions.

Node v6.9.1
Npm v3.10.8.
ng-cli beta.30

Repro steps.

In brief, I want to bootstap one of my root modules based on an async call to the server. So, my code is like that:

AppPreBootstrap.run(() => { 
    if (abp.session.userId) {
        AppPreBootstrap.bootstrap(AppModule);
    } else {
        AppPreBootstrap.bootstrap(AccountModule);
    }
});

//A workaround to make angular-cli finding the startup module!
var b = false; if (b) { platformBrowserDynamic().bootstrapModule(AppModule); }

Given workaround works fine when AOT is disabled. But, when AOT is enabled, it only compiles AppModule and the logic above can not work.

I know AOT statically analysis main.ts and bundles all module files starting from the root module. But I also believe my case is not so unique. I simple want to bootstrap a different module if user has not logged in.

So, isn't that possible or is there a way of doing it? If not, how do you recommend as a best practice? Should I merge 2 modules and implement the logic with routes and route guards?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions