Skip to content

Commit

Permalink
fix(core): Allow modification of lifecycle hooks any time before boot…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mhevery committed Jul 14, 2020
1 parent b358495 commit 269c093
Show file tree
Hide file tree
Showing 21 changed files with 613 additions and 149 deletions.
34 changes: 34 additions & 0 deletions .history/goldens/size-tracking/aio-payloads_20200714135705.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"aio": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
"main-es2015": 450880,
"polyfills-es2015": 52685
}
}
},
"aio-local": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
<<<<<<< HEAD
"main-es2015": 450883,
"polyfills-es2015": 52630
=======
"main-es2015": 450966,
"polyfills-es2015": 52655
>>>>>>> e3af65ede0... fix(core): Allow modification of lifecycle hooks any time before bootstrap
}
}
},
"aio-local-viewengine": {
"master": {
"uncompressed": {
"runtime-es2015": 3097,
"main-es2015": 429200,
"polyfills-es2015": 52195
}
}
}
}
29 changes: 29 additions & 0 deletions .history/goldens/size-tracking/aio-payloads_20200714135739.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"aio": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
"main-es2015": 450880,
"polyfills-es2015": 52685
}
}
},
"aio-local": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
"main-es2015": 450883,
"polyfills-es2015": 52630
}
}
},
"aio-local-viewengine": {
"master": {
"uncompressed": {
"runtime-es2015": 3097,
"main-es2015": 429200,
"polyfills-es2015": 52195
}
}
}
}
29 changes: 29 additions & 0 deletions .history/goldens/size-tracking/aio-payloads_20200714135740.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"aio": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
"main-es2015": 450880,
"polyfills-es2015": 52685
}
}
},
"aio-local": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
"main-es2015": 450883,
"polyfills-es2015": 52630
}
}
},
"aio-local-viewengine": {
"master": {
"uncompressed": {
"runtime-es2015": 3097,
"main-es2015": 429200,
"polyfills-es2015": 52195
}
}
}
}
29 changes: 29 additions & 0 deletions .history/goldens/size-tracking/aio-payloads_20200714142715.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"aio": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
"main-es2015": 450880,
"polyfills-es2015": 52685
}
}
},
"aio-local": {
"master": {
"uncompressed": {
"runtime-es2015": 2987,
"main-es2015": 450301,
"polyfills-es2015": 52630
}
}
},
"aio-local-viewengine": {
"master": {
"uncompressed": {
"runtime-es2015": 3097,
"main-es2015": 429200,
"polyfills-es2015": 52195
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"cli-hello-world": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 141151,
"polyfills-es2015": 36571
}
}
},
"cli-hello-world-ivy-minimal": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 17362,
"polyfills-es2015": 36657
}
}
},
"cli-hello-world-ivy-compat": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 147573,
"polyfills-es2015": 36571
}
}
},
"cli-hello-world-ivy-i18n": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 135533,
"polyfills-es2015": 37248
}
}
},
"cli-hello-world-lazy": {
"master": {
"uncompressed": {
"runtime-es2015": 2289,
"main-es2015": 246044,
"polyfills-es2015": 36938,
"5-es2015": 751
}
}
},
"cli-hello-world-lazy-rollup": {
"master": {
"uncompressed": {
"runtime-es2015": 2289,
<<<<<<< HEAD
"main-es2015": 221897,
=======
"main-es2015": 221846,
>>>>>>> e3af65ede0... fix(core): Allow modification of lifecycle hooks any time before bootstrap
"polyfills-es2015": 36938,
"5-es2015": 779
}
}
},
"hello_world__closure": {
"master": {
"uncompressed": {
"bundle": "TODO(i): temporarily increase the payload size limit from 105779 - this is due to a closure issue related to ESM reexports that still needs to be investigated",
"bundle": "TODO(i): we should define ngDevMode to false in Closure, but --define only works in the global scope.",
"bundle": "TODO(i): (FW-2164) TS 3.9 new class shape seems to have broken Closure in big ways. The size went from 169991 to 252338",
"bundle": "TODO(i): after removal of tsickle from ngc-wrapped / ng_package, we had to switch to SIMPLE optimizations which increased the size from 252338 to 1198917, see PR#37221 and PR#37317 for more info",
"bundle": 1209659
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"cli-hello-world": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 141151,
"polyfills-es2015": 36571
}
}
},
"cli-hello-world-ivy-minimal": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 17362,
"polyfills-es2015": 36657
}
}
},
"cli-hello-world-ivy-compat": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 147573,
"polyfills-es2015": 36571
}
}
},
"cli-hello-world-ivy-i18n": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 135533,
"polyfills-es2015": 37248
}
}
},
"cli-hello-world-lazy": {
"master": {
"uncompressed": {
"runtime-es2015": 2289,
"main-es2015": 246044,
"polyfills-es2015": 36938,
"5-es2015": 751
}
}
},
"cli-hello-world-lazy-rollup": {
"master": {
"uncompressed": {
"runtime-es2015": 2289,
"main-es2015": 221897,
"polyfills-es2015": 36938,
"5-es2015": 779
}
}
},
"hello_world__closure": {
"master": {
"uncompressed": {
"bundle": "TODO(i): temporarily increase the payload size limit from 105779 - this is due to a closure issue related to ESM reexports that still needs to be investigated",
"bundle": "TODO(i): we should define ngDevMode to false in Closure, but --define only works in the global scope.",
"bundle": "TODO(i): (FW-2164) TS 3.9 new class shape seems to have broken Closure in big ways. The size went from 169991 to 252338",
"bundle": "TODO(i): after removal of tsickle from ngc-wrapped / ng_package, we had to switch to SIMPLE optimizations which increased the size from 252338 to 1198917, see PR#37221 and PR#37317 for more info",
"bundle": 1209659
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"cli-hello-world": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 141151,
"polyfills-es2015": 36571
}
}
},
"cli-hello-world-ivy-minimal": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 17362,
"polyfills-es2015": 36657
}
}
},
"cli-hello-world-ivy-compat": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 147573,
"polyfills-es2015": 36571
}
}
},
"cli-hello-world-ivy-i18n": {
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 136168,
"polyfills-es2015": 37248
}
}
},
"cli-hello-world-lazy": {
"master": {
"uncompressed": {
"runtime-es2015": 2289,
"main-es2015": 245351,
"polyfills-es2015": 36938,
"5-es2015": 751
}
}
},
"cli-hello-world-lazy-rollup": {
"master": {
"uncompressed": {
"runtime-es2015": 2289,
"main-es2015": 221897,
"polyfills-es2015": 36938,
"5-es2015": 779
}
}
},
"hello_world__closure": {
"master": {
"uncompressed": {
"bundle": "TODO(i): temporarily increase the payload size limit from 105779 - this is due to a closure issue related to ESM reexports that still needs to be investigated",
"bundle": "TODO(i): we should define ngDevMode to false in Closure, but --define only works in the global scope.",
"bundle": "TODO(i): (FW-2164) TS 3.9 new class shape seems to have broken Closure in big ways. The size went from 169991 to 252338",
"bundle": "TODO(i): after removal of tsickle from ngc-wrapped / ng_package, we had to switch to SIMPLE optimizations which increased the size from 252338 to 1198917, see PR#37221 and PR#37317 for more info",
"bundle": 1209659
}
}
}
}

0 comments on commit 269c093

Please sign in to comment.