-
Notifications
You must be signed in to change notification settings - Fork 12k
fix(@schematics/angular): enable lazy loading with ivy #13524
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
Conversation
Angular `8.0.0-beta.1` supports lazy loading with Ivy (at least a partial support), but currently the CLI needs `"allowEmptyCodegenFiles": true` to avoid errors like: ``` ERROR in ./src/$$_lazy_route_resource lazy namespace object Module not found: Error: Can't resolve '/src/app/races/races.module.ngfactory.js' in '/src/$$_lazy_route_resource' ```
Related Jira issue: FW-737 |
The last time I talked to @IgorMinar, he mentioned that we should NOT enable this by default. So I am going to wait for his feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we understand the root cause of the problem?
is the problem that the web pack pipeline expects the factories to be around for the lazy loading to work?
Originally I thought that we would always need factory shims to be generated by default, but in reality we need this only in google3 where the pipeline works differently from external webpack-based cli.
Unless I'm mistaken, we don't ever scaffold any kind of code that references factories directly. Both the bootstrap and router lazy loading in the ngc/view-engine pipeline swap factories for components behind the scenes, so the developer never interacts with them directly. If this is the case, then we should not generate factories with ivy at all and instead focus on fixing whatever it is that is causing the lazy loading in CLI to fail today.
I see that @gkalpak added this flag to his aio PR as well: https://github.com/angular/angular/pull/26947/files#r251221208
it's ok to use the flag as a workaround, but we shouldn't start scaffolding new projects with it, even if it's an option behind the ivy flag.
btw the main reason for not generating the shims is that they cause lots of headaches within webpack, make code splitting and tree-shaking less reliable, slow down the build, and just add noise to the build output. this is why we should try to disable them by default in ivy and only tell users to enable them if they somehow directly using factories in the existing code (as is the case in google3).
Hi Igor,
I didn’t look into this recently, but in the webpack pipeline, we do change
the modules and file paths to factories when not having a jit compilation.
We should definitely change this and do only so for AOT and when enabling
factories shimming.
However, I doubt that lazy loading will work in ivy without factories
because of the SystemJsNgModuleLoader in core, as it always expects to have factories
https://github.com/angular/angular/blob/master/packages/core/src/linker/system_js_ng_module_factory_loader.ts
…On Sun, 27 Jan 2019 at 05:45, Igor Minar ***@***.***> wrote:
***@***.**** requested changes on this pull request.
do we understand the root cause of the problem?
is the problem that the web pack pipeline expects the factories to be
around for the lazy loading to work?
Originally I thought that we would need factory shims to be generated by
default, but in reality we need this only in google3 where the pipeline
works differently from cli.
Unless I'm mistaken, we don't ever scaffold any kind of code that
references factories directly. Both the bootstrap and router lazy loading
in the ngc/view-engine pipeline swap factories for components behind the
scenes, so the developer never interacts with them directly. If this is the
case, then we should not generate factories with ivy at all and instead
focus on fixing whatever it is that is causing the lazy loading in CLI to
fail today.
I see that @gkalpak <https://github.com/gkalpak> added this flag to his
aio PR as well:
https://github.com/angular/angular/pull/26947/files#r251221208
it's ok to use the flag as a workaround, but we shouldn't start
scaffolding new projects with it, even if it's an option behind the ivy
flag.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13524 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQv-WiLe_kvTPOYwBdcoDc2qsn87PaWgks5vHS7cgaJpZM4aTZlX>
.
|
I see.. the right solution is to change the loader so that it doesn't use the NgModuleFactoryLoader when we run in the Ivy mode:
I'm just not sure if we need to be able to handle both the scenario with Ivy on with and without factory shims. @jasonaden should weigh in as well... |
Can we have the Ivy AOT compiler normalize the string form to the
|
Supersedes angular#13524 Blocked on angular#13597 Blocked on angular/angular#28685
Supersedes angular#13524 Blocked on angular#13597
Superseded by #13667 |
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. |
Angular
8.0.0-beta.1
supports lazy loading with Ivy (at least a partial support), but currently the CLI needs"allowEmptyCodegenFiles": true
to avoid errors like:As discussed with @gkalpak this might be a temporary workaround, but it might help users giving a try to Ivy (as the workaround is not really trivial ^^) .