feat(compiler-cli): support for partial compilation of components (#39707)

This commit implements partial compilation of components, together with
linking the partial declaration into its full AOT output.

This commit does not yet enable accurate source maps into external
templates. This requires additional work to account for escape sequences
which is non-trivial. Inline templates that were represented using a
string or template literal are transplated into the partial declaration
output, so their source maps should be accurate. Note, however, that
the accuracy of source maps is not currently verified in tests; this is
also left as future work.

The golden files of partial compilation output have been updated to
reflect the generated code for components. Please note that the current
output should not yet be considered stable.

PR Close #39707
This commit is contained in:
JoostK
2020-11-16 18:24:37 +01:00
committed by Andrew Kushnir
parent f6be161a3c
commit e75244ec00
23 changed files with 583 additions and 135 deletions
@@ -21,6 +21,17 @@ const INTERFACE_EXCEPTIONS = new Set<string>([
'ModuleWithProviders',
]);
/**
* The following symbols are only referenced from partial declaration compilation outputs, which
* will never be emitted by the JIT compiler so are allowed to be omitted from the JIT environment.
*/
const PARTIAL_ONLY = new Set<string>([
'ɵɵngDeclareDirective',
'ɵɵngDeclareComponent',
'ChangeDetectionStrategy',
'ViewEncapsulation',
]);
describe('r3 jit environment', () => {
// This test keeps render3/jit/environment and r3_identifiers in the compiler in sync, ensuring
// that if the compiler writes a reference to a render3 symbol, it will be resolvable at runtime
@@ -33,7 +44,7 @@ describe('r3 jit environment', () => {
// A few such properties are string constants. Ignore them, and focus on ExternalReferences.
.filter(isExternalReference)
// Some references are to interface types. Only take properties which have runtime values.
.filter(sym => !INTERFACE_EXCEPTIONS.has(sym.name))
.filter(sym => !INTERFACE_EXCEPTIONS.has(sym.name) && !PARTIAL_ONLY.has(sym.name))
.forEach(sym => {
// Assert that angularCoreEnv has a reference to the runtime symbol.
expect(angularCoreEnv.hasOwnProperty(sym.name))