angular/packages/compiler
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
..
design refactor: fix various typos across different packages (#44523) 2022-01-07 18:11:10 +00:00
src fix(compiler-cli): full side-effectful registration of NgModules with ids (#45024) 2022-03-22 11:11:53 -07:00
test fix(compiler): scope css rules within @layer blocks (#45396) 2022-03-21 14:51:45 -07:00
testing test: remove view-engine-only tests (#43884) 2021-11-23 21:10:06 +00:00
BUILD.bazel build: update visibility for npm package targets to work with new integration test structure (#44238) 2021-12-08 13:42:41 -05:00
compiler.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
index.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
package.json feat(core): drop support for Node.js 12 (#45286) 2022-03-08 12:05:03 -08:00
public_api.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00