angular/packages/core/testing/src
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
..
async.ts feat(core): drop support for zone.js 0.10.x (#40823) 2021-02-24 07:58:29 -08:00
component_fixture.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
fake_async.ts docs: update flush description to include microtasks (#45237) 2022-03-07 15:41:07 -08:00
lang_utils.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
logger.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
metadata_override.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
metadata_overrider.ts fix(core): support cyclic metadata in TestBed overrides (#44215) 2021-11-19 19:27:08 +00:00
ng_zone_mock.ts refactor(core): ensure compatibility with noImplicitOverride (#42512) 2021-07-12 13:11:15 -07:00
r3_test_bed.ts fix(compiler-cli): full side-effectful registration of NgModules with ids (#45024) 2022-03-22 11:11:53 -07:00
r3_test_bed_compiler.ts fix(core): associate the NgModule scope for an overridden component (#42817) 2021-07-13 15:59:28 -07:00
resolvers.ts feat(core): support TypeScript 4.4 (#43281) 2021-09-23 14:49:19 -07:00
styling.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test_bed.ts refactor: delete the View Engine runtime (#43884) 2021-11-23 21:10:06 +00:00
test_bed_common.ts feat(core): enable test module teardown by default (#43353) 2021-10-04 16:57:16 -07:00
test_hooks.ts refactor: delete the View Engine runtime (#43884) 2021-11-23 21:10:06 +00:00
testing.ts test: remove view-engine-only tests (#43884) 2021-11-23 21:10:06 +00:00
testing_internal.ts test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00