-
Notifications
You must be signed in to change notification settings - Fork 12k
(AngularCompilerPlugin) AOT with lazy modules without angular/router #8142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's not happening because |
@clydin thanks for reply. I give an simple example that illustrates the issue. My component: @Component({
selector: "foo-cmp",
template: `<button (click)="loadLazyModule()">Load lazy module</button>`
})
export class FooComponent {
loadLazyModule() {
require.ensure([], () => {
const lazyModule = require("../../../+profile/profile.module.ts")["ProfileModule"];
console.log(lazyModule); // <--- lazyModule is ProfileModule both in JIT and AOT builds
}, err => console.error(err), "profile");
}
} I expect that I guess it's because |
When using Angular's router (or even |
@clydin yes we have the same handling logic as angular/router. But I don't understand how can I get |
The |
@clydin we already have a custom
But in our app nobody creates Also I see that |
Oh, I look at |
The AOT compiler will turn The code you're linking to in AngularCompilerPlugin is used when Also, the bootstrapping code is very different than this. The plugin actually performs code refactoring to adjust the bootstrap call. The bootstrap call does not perform lazy loading and as such is using an instance of the module directly. As a result the call must be adjusted to handle AOT. The semantics of the Angular bootstrap call are also well known which allows the refactoring to be safely performed. This is essentially convenience functionality as the manual method of providing two |
@clydin I got it! Thank you for explanation. |
@bukharin were you able to get the angular compiler to compile modules loaded through System.import instead of router definition ? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hi,
I try to enable AOT compilation in our project with lazy modules. We do not use
@angular/router
and lazy modules loads like this:At runtime I discover that
AngularCompilerPlugin
do not overrideProfileModule
toProfileModuleNgFactory
. The plugin can not determine lazy modules in our application because we don't useangular/router
and instantinate modules by using angular low level api for that (like router).How can I achieve this?
I think the best way is to remove explicit binding from
@angular/router
for determining lazy modules. Also you can provide additional options for explicit lazy modules config.The text was updated successfully, but these errors were encountered: