This reverts commit 7f8c2225f2cba3dfcf3ec23e0fe08b7d2e3497e8. This commit caused test failures internally, which were traced back to the optimizer removing NgModuleFactory constructor calls when those calls caused side-effectful registration of NgModules by their ids. PR Close #38303