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
fix(core): Allow modification of lifecycle hooks any time before bootstrap #38119
Conversation
…strap Currently we read lifecycle hooks eagerly during `ɵɵdefineComponent`. The result is that it is not possible to do any sort of meta-programing such as mixins or adding lifecycle hooks using custom decorators since any such code executes after `ɵɵdefineComponent` has extracted the lifecycle hooks from the prototype. Additionally the behavior is inconsistent between AOT and JIT mode. In JIT mode overriding lifecycle hooks is possible because the whole `ɵɵdefineComponent` is placed in getter which is executed lazily. This is because JIT mode must compile a template which can be specified as `templateURL` and those we are waiting for its resolution. - `+` `ɵɵdefineComponent` becomes smaller as it no longer needs to copy lifecycle hooks from prototype to `ComponentDef` - `-` `ɵɵNgOnChangesFeature` feature is now always included with the codebase as it is no longer tree shakable. Previously we have read lifecycle hooks from prototype in the `ɵɵdefineComponent` so that lifecycle hook access would be monomorphic. This decision was made before we had `T*` data structures. By not reading the lifecycle hooks we are moving the megamorhic read form `ɵɵdefineComponent` to instructions. However, the reads happen on `firstTemplatePass` only and are subsequently cached in the `T*` data structures. The result is that the overall performance should be same (or slightly better as the intermediate `ComponentDef` has been removed.) - [ ] Remove `ɵɵNgOnChangesFeature` from compiler. (It will no longer be a feature.) - [ ] Discuss the future of `Features` as they hinder meta-programing. Fix angular#30497
FYI, this is patch-only version of the PR #35464 that was reviewed and approved, so no additional reviews are required. |
…strap (#38119) Currently we read lifecycle hooks eagerly during `ɵɵdefineComponent`. The result is that it is not possible to do any sort of meta-programing such as mixins or adding lifecycle hooks using custom decorators since any such code executes after `ɵɵdefineComponent` has extracted the lifecycle hooks from the prototype. Additionally the behavior is inconsistent between AOT and JIT mode. In JIT mode overriding lifecycle hooks is possible because the whole `ɵɵdefineComponent` is placed in getter which is executed lazily. This is because JIT mode must compile a template which can be specified as `templateURL` and those we are waiting for its resolution. - `+` `ɵɵdefineComponent` becomes smaller as it no longer needs to copy lifecycle hooks from prototype to `ComponentDef` - `-` `ɵɵNgOnChangesFeature` feature is now always included with the codebase as it is no longer tree shakable. Previously we have read lifecycle hooks from prototype in the `ɵɵdefineComponent` so that lifecycle hook access would be monomorphic. This decision was made before we had `T*` data structures. By not reading the lifecycle hooks we are moving the megamorhic read form `ɵɵdefineComponent` to instructions. However, the reads happen on `firstTemplatePass` only and are subsequently cached in the `T*` data structures. The result is that the overall performance should be same (or slightly better as the intermediate `ComponentDef` has been removed.) - [ ] Remove `ɵɵNgOnChangesFeature` from compiler. (It will no longer be a feature.) - [ ] Discuss the future of `Features` as they hinder meta-programing. Fix #30497 PR Close #38119
@mhevery |
We need this o 9.x too, it'll be done too? @AndrewKushnir @mhevery |
I think that it's necessary to count on the fact that it won't be added to any previous versions. As usual, new features flow only forward. Where is the problem with such logic? The difference between 9 and 10 is not so significant so it's easy to migrate. |
makes sense @mlc-mlapis |
It happens that I am partly dependent on applications that do not make upgrades often. So waiting for them to upgrade to version 10 might take months. Not that I am asking for personal favors :) I thought it was due naturally to enter version 9, since the issue was opened when Angular was at version 9. Angular switched to version 10 when the PR was still in process. |
P.S. and what is this "patch" for anyway? Why is there a PR for a "patch" beside the original PR? I thought it was related too to fixing previous versions. |
"Patch" is the version branch that is currently receiving bug fixes. Currently this is 10.0.x. |
Thanks. Which reminds me: this PR is a fix, not a feature. Which also seems to provide a reason for applying it to version 9 too.. |
Yes, |
@ramtob It certainly would be fine to have it also in 9.x, but it would also mean significant circumstances and additional costs. Just imagine how standard development flow is going on. It starts at some point. All surrounding things are changing from day to day, even new versions and so. You, as a developer, are keeping your work up-to-date with all the latest changes, continuously merging, so in the end, you finish your work in a different situation than you have been started. |
This bug is critical, all reasons listed in the original issue. So it should be ported to v9, as per stated below: All of our major releases are supported for 18 months. 6 months of active support, during which regularly-scheduled updates and patches are released.
|
If you started using 9.x and then realized this bug, you obviously have learned how to live with it, or you've downgraded to Angular 8. Upgrading to Angular 10 may be an issue to people because of policies, but you've already made compromises if you're using Angular 9 with this bug. I don't think we should demand the team backport this rather extensive PR just to satisfy our policies. |
any updates? |
@mikaelboff Update for what? |
didn't saw it was released, thanks @mlc-mlapis |
Sorry, this will not be added to v9. If you need this functionality please upgrade to latest code. |
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. |
Rebase of #45464 onto
10.0.x
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information