angular/packages/core/test/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
..
change_detection_integration_spec.ts build: enable useUnknownInCatchVariables (#44679) 2022-02-01 18:17:29 +00:00
entry_components_integration_spec.ts test: remove Ivy/ViewEngine switch helpers and obsolete tests (#44120) 2021-11-24 19:42:39 +00:00
inheritance_integration_spec.ts refactor(core): make the error messages tree shakable (#44359) 2022-01-18 17:38:10 -08:00
integration_spec.ts build: enable useUnknownInCatchVariables (#44679) 2022-02-01 18:17:29 +00:00
ng_container_integration_spec.ts test: remove Ivy/ViewEngine switch helpers and obsolete tests (#44120) 2021-11-24 19:42:39 +00:00
ng_module_integration_spec.ts fix(compiler-cli): full side-effectful registration of NgModules with ids (#45024) 2022-03-22 11:11:53 -07:00
projection_integration_spec.ts test(core): clean up tests relying on entryComponents (#44276) 2021-11-29 12:36:04 -05:00
query_integration_spec.ts test: remove Ivy/ViewEngine switch helpers and obsolete tests (#44120) 2021-11-24 19:42:39 +00:00
query_list_spec.ts test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
regression_integration_spec.ts test(core): clean up tests relying on entryComponents (#44276) 2021-11-29 12:36:04 -05:00
resource_loader_mock.ts test: remove view-engine-only tests (#43884) 2021-11-23 21:10:06 +00:00
security_integration_spec.ts test: remove Ivy/ViewEngine switch helpers and obsolete tests (#44120) 2021-11-24 19:42:39 +00:00
source_map_integration_node_only_spec.ts perf(compiler): chain element start/end instructions (#44994) 2022-02-08 09:56:50 -08:00
source_map_util.ts test: remove view-engine-only tests (#43884) 2021-11-23 21:10:06 +00:00
view_injector_integration_spec.ts test(core): clean up tests relying on entryComponents (#44276) 2021-11-29 12:36:04 -05:00