angular-cn/packages/compiler-cli/test
Alex Rickabaugh 8e73f9b0aa feat(compiler-cli): lower some exported expressions (#30038)
The compiler uses metadata to represent what it statically knows about
various expressions in a program. Occasionally, expressions in the program
for which metadata is extracted may contain sub-expressions which are not
representable in metadata. One such construct is an arrow function.

The compiler does not always need to understand such expressions completely.
For example, for a provider defined with `useValue`, the compiler does not
need to understand the value at all, only the outer provider definition. In
this case, the compiler employs a technique known as "expression lowering",
where it rewrites the provider expression into one that can be represented
in metadata. Chiefly, this involves extracting out the dynamic part (the
`useValue` expression) into an exported constant.

Lowering is applied through a heuristic, which considers the containing
statement as well as the field name of the expression.

Previously, this heuristic was not completely accurate in the case of
route definitions and the `loadChildren` field, which is lowered. If the
route definition using `loadChildren` existed inside a decorator invocation,
lowering was performed correctly. However, if it existed inside a standalone
variable declaration with an export keyword, the heuristic would conclude
that lowering was unnecessary. For ordinary providers this is true; however
the compiler attempts to fully understand the ROUTES token and thus even if
an array of routes is declared in an exported variable, any `loadChildren`
expressions within still need to be lowered.

This commit enables lowering of already exported variables under a limited
set of conditions (where the initializer expression is of a specific form).
This should enable the use of `loadChildren` in route definitions.

PR Close #30038
2019-04-23 08:30:58 -07:00
..
compliance feat(ivy): generate ɵɵproperty in host bindings (#30009) 2019-04-22 17:30:17 -07:00
diagnostics build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871) 2019-02-28 12:06:36 -08:00
metadata fix(compiler-cli): incorrect metadata bundle for multiple unnamed re-exports (#29360) 2019-03-18 15:08:40 -04:00
ngtsc feat(ivy): generate ɵɵproperty in host bindings (#30009) 2019-04-22 17:30:17 -07:00
transformers build: add moduleName to ngFactory sourcefiles (#29385) 2019-03-19 01:10:49 -04:00
BUILD.bazel refactor(ivy): move ngcc into a higher level folder (#29092) 2019-03-20 14:45:54 -04:00
extract_i18n_spec.ts build: remove unused "test.sh" leftover code in compiler-cli (#28352) 2019-02-05 14:31:10 -05:00
mocks.ts fix(compiler-cli): Use typescript to resolve modules for metadata (#22856) 2018-07-10 11:11:48 -07:00
ngc_spec.ts feat(compiler-cli): lower some exported expressions (#30038) 2019-04-23 08:30:58 -07:00
ngtools_api_spec.ts fix(ivy): DebugNode.query should query nodes in the logical tree (#29480) 2019-03-26 12:48:37 -07:00
perform_compile_spec.ts feat(compiler-cli): add support to extend `angularCompilerOptions` (#22717) 2018-09-19 16:17:28 -07:00
perform_watch_spec.ts build: fix failing compiler-cli tests on windows (#28352) 2019-02-05 14:31:10 -05:00
runfile_helpers.ts build: support running compiler-cli tests on windows (#28352) 2019-02-05 14:31:10 -05:00
test_support.ts test: remove symlink workaround (#29426) 2019-03-20 15:13:09 -04:00