angular/packages/core/src/linker
Alex Rickabaugh 27b4af7240 fix(compiler-cli): full side-effectful registration of NgModules with ids (#45024)
Angular contains an NgModule registry, which allows a user to declare
NgModules with string ids and retrieve them via those ids, using the
`getNgModuleById` API.

Previously, we attempted to structure this registration in a clever fashion
to allow for tree-shaking of registered NgModules (that is, those with ids).
This sort of worked due to the accidental alignment of behaviors from the
different tree-shakers involved. However, this trick relies on the
generation of `.ngfactory` files and how they're specifically processed in
various bundling scenarios. We intend to remove `.ngfactory` files, hence
we can no longer rely on them in this way.

The correct solution here is to recognize that `@NgModule({id})` is
inherently declaring a global side-effect, and such classes should not
really be eligible for tree-shaking in the first place. This commit removes
all the old registration machinery, and standardizes on generating a side-
effectful call to `registerNgModuleType` for NgModules that have ids.

There is some risk here that NgModules with unnecessary `id`s may not
tree-shake as a result of this change, whereas they would have in previous
circumstances. The fix here should be to remove the `id` if it's not needed.
Specifying an `id` is a request that the NgModule be retained regardless of
any other references, in case it is later looked up by string id.

PR Close #45024
2022-03-22 11:11:53 -07:00
..
compiler.ts perf(core): make Compiler, ApplicationRef and ApplicationInitStatus tree-shakable (#45102) 2022-02-18 13:40:02 -08:00
component_factory.ts docs: deprecate ComponentFactory and ComponentFactoryResolver symbols (#44749) 2022-01-19 09:42:40 -08:00
component_factory_resolver.ts docs: deprecate ComponentFactory and ComponentFactoryResolver symbols (#44749) 2022-01-19 09:42:40 -08:00
element_ref.ts refactor: delete the View Engine runtime (#43884) 2021-11-23 21:10:06 +00:00
ng_module_factory.ts docs: deprecate ComponentFactory and ComponentFactoryResolver symbols (#44749) 2022-01-19 09:42:40 -08:00
ng_module_factory_loader.ts fix(compiler-cli): full side-effectful registration of NgModules with ids (#45024) 2022-03-22 11:11:53 -07:00
ng_module_factory_loader_impl.ts refactor(router): add stub files for g3 patch of NgModuleFactoryLoader (#43660) 2021-10-04 10:28:02 -07:00
ng_module_registration.ts fix(compiler-cli): full side-effectful registration of NgModules with ids (#45024) 2022-03-22 11:11:53 -07:00
query_list.ts ci: add lint error for files with missing trailing new-line (#42478) 2021-06-04 13:31:03 -07:00
template_ref.ts feat(core): allow for injector to be specified when creating an embedded view (#45156) 2022-03-02 16:38:00 +00:00
view_container_ref.ts feat(core): allow for injector to be specified when creating an embedded view (#45156) 2022-03-02 16:38:00 +00:00
view_ref.ts fix(core): allow EmbeddedViewRef context to be updated (#40360) 2021-02-23 08:14:01 -08:00