angular/packages/core/src
Alex Rickabaugh b54ed980ed fix(ivy): retain JIT metadata unless JIT mode is explicitly disabled (#33671)
NgModules in Ivy have a definition which contains various different bits
of metadata about the module. In particular, this metadata falls into two
categories:

* metadata required to use the module at runtime (for bootstrapping, etc)
in AOT-only applications.
* metadata required to depend on the module from a JIT-compiled app.

The latter metadata consists of the module's declarations, imports, and
exports. To support JIT usage, this metadata must be included in the
generated code, especially if that code is shipped to NPM. However, because
this metadata preserves the entire NgModule graph (references to all
directives and components in the app), it needs to be removed during
optimization for AOT-only builds.

Previously, this was done with a clever design:

1. The extra metadata was added by a function called `setNgModuleScope`.
A call to this function was generated after each NgModule.
2. This function call was marked as "pure" with a comment and used
`noSideEffects` internally, which causes optimizers to remove it.

The effect was that in dev mode or test mode (which use JIT), no optimizer
runs and the full NgModule metadata was available at runtime. But in
production (presumably AOT) builds, the optimizer runs and removes the JIT-
specific metadata.

However, there are cases where apps that want to use JIT in production, and
still make an optimized build. In this case, the JIT-specific metadata would
be erroneously removed. This commit solves that problem by adding an
`ngJitMode` global variable which guards all `setNgModuleScope` calls. An
optimizer can be configured to statically define this global to be `false`
for AOT-only builds, causing the extra metadata to be stripped.

A configuration for Terser used by the CLI is provided in `tooling.ts` which
sets `ngJitMode` to `false` when building AOT apps.

PR Close #33671
2019-11-20 12:55:43 -08:00
..
change_detection refactor(core): rename ngInjectableDef to ɵprov (#33151) 2019-10-16 16:36:19 -04:00
compiler fix(ivy): retain JIT metadata unless JIT mode is explicitly disabled (#33671) 2019-11-20 12:55:43 -08:00
debug fix(ivy): shadow all DOM properties in DebugElement.properties (#33781) 2019-11-18 15:49:22 -08:00
di fix(core): support ngInjectableDef on types with inherited ɵprov (#33732) 2019-11-12 11:54:15 -08:00
i18n feat(common): support loading locales from a global (#33523) 2019-11-05 17:27:00 +00:00
interface feat(core): Add "AbstractType<T>" interface (#29295) 2019-04-02 16:07:22 -07:00
linker fix(core): make QueryList implement Iterable in the type system (#33536) 2019-11-19 13:43:53 -08:00
metadata docs: add ModuleWithProviders deprecation (#33266) 2019-10-22 14:35:27 -07:00
profile feat(core): deprecate integration with the Web Tracing Framework (WTF) (#30642) 2019-05-23 15:09:48 -07:00
reflection perf: don't create holey arrays (#32155) 2019-08-21 08:27:43 -07:00
render refactor(core): remove deprecated Renderer (#33019) 2019-10-08 09:23:00 -07:00
render3 fix(ivy): retain JIT metadata unless JIT mode is explicitly disabled (#33671) 2019-11-20 12:55:43 -08:00
sanitization fix(ivy): ExpressionChangedAfterItHasBeenCheckedError for SafeValue (#33749) 2019-11-15 10:44:23 -08:00
testability build: update zone.js to 0.9.0 (#28219) 2019-03-26 12:50:38 -07:00
util test(ivy): Have more descriptive names for LView (#33449) 2019-11-07 15:33:50 +00:00
view refactor(core): remove deprecated Renderer (#33019) 2019-10-08 09:23:00 -07:00
zone feat: add a flag in bootstrap to enable coalesce event change detection to improve performance (#30533) 2019-11-05 18:58:25 +00:00
application_init.ts docs: update core to use @publicApi tags (#26595) 2018-10-19 14:35:53 -07:00
application_module.ts feat(ivy): allow the locale to be set via a global property (#33314) 2019-10-24 10:16:25 -07:00
application_ref.ts feat: add a flag in bootstrap to enable coalesce event change detection to improve performance (#30533) 2019-11-05 18:58:25 +00:00
application_tokens.ts docs: convert all @experimental tags to @publicApi tags (#26595) 2018-10-19 14:35:52 -07:00
change_detection.ts refactor(core): remove deprecated TrackByFn (#18757) 2017-08-18 13:23:46 -05:00
codegen_private_exports.ts fix(ivy): align NgModule registration timing with ViewEngine (#30244) 2019-05-13 11:13:25 -07:00
console.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
core.externs.js fix(ivy): add missing closure extern for \$localize (#32460) 2019-09-03 11:55:16 -07:00
core.ts docs(ivy): improve the missing $localize error message (#33826) 2019-11-15 10:38:36 -08:00
core_private_export.ts feat(common): support loading locales from a global (#33523) 2019-11-05 17:27:00 +00:00
core_render3_private_export.ts fix(ivy): ensure that the correct document is available (#33712) 2019-11-11 14:01:04 -08:00
di.ts refactor(ivy): create Injector interface; remove dependency on Ivy (#28066) 2019-01-11 16:24:03 -08:00
error_handler.ts refactor(ivy): refactor more files in DI to prepare it for bazel packages (#28098) 2019-01-14 09:55:30 -08:00
errors.ts build: extract interface and util sub compilation from core (#28028) 2019-01-10 16:31:44 -08:00
event_emitter.ts docs(core): mark EventEmitter#__isAsync as internal to hide from API docs (#31378) 2019-10-03 10:24:34 -07:00
ivy_switch.ts refactor(ivy): obviate the Bazel component of the ivy_switch (#26550) 2018-10-19 09:23:05 -07:00
linker.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
metadata.ts docs: fix and add decorator api doc (#28986) 2019-03-04 11:47:30 -08:00
platform_core_providers.ts docs: convert all @experimental tags to @publicApi tags (#26595) 2018-10-19 14:35:52 -07:00
r3_symbols.ts refactor(ivy): generate ngFactoryDef for injectables (#32433) 2019-10-02 13:04:26 -07:00
render.ts refactor(core): remove deprecated Renderer (#33019) 2019-10-08 09:23:00 -07:00
version.ts docs: update core to use @publicApi tags (#26595) 2018-10-19 14:35:53 -07:00
zone.ts feat(router): warn if navigation triggered outside Angular zone (#24959) 2018-09-05 09:35:14 -07:00