refactor(compiler-cli): implement ɵɵngDeclareNgModule and ɵɵngDeclareInjector (#41080)

This commit changes the partial compilation so that it outputs declaration
calls rather than definition calls for NgModules and Injectors.

The JIT compiler and the linker are updated to be able to handle these
new declarations.

PR Close #41080
This commit is contained in:
Pete Bacon Darwin
2021-03-04 20:55:25 +00:00
committed by Jessica Janiuk
parent 8a33842cca
commit 5565810bd6
85 changed files with 2330 additions and 827 deletions
@@ -7,7 +7,7 @@
*/
import * as ts from 'typescript';
import {LinkerOptions} from '../../..';
import {DEFAULT_LINKER_OPTIONS, LinkerOptions} from '../../..';
import {FileSystem} from '../../../../src/ngtsc/file_system';
import {MockFileSystemNative} from '../../../../src/ngtsc/file_system/testing';
import {MockLogger} from '../../../../src/ngtsc/logging/testing';
@@ -16,16 +16,13 @@ import {TypeScriptAstHost} from '../../../src/ast/typescript/typescript_ast_host
import {LinkerEnvironment} from '../../../src/file_linker/linker_environment';
import {PartialComponentLinkerVersion1} from '../../../src/file_linker/partial_linkers/partial_component_linker_1';
import {PartialDirectiveLinkerVersion1} from '../../../src/file_linker/partial_linkers/partial_directive_linker_1';
import {PartialInjectorLinkerVersion1} from '../../../src/file_linker/partial_linkers/partial_injector_linker_1';
import {PartialLinkerSelector} from '../../../src/file_linker/partial_linkers/partial_linker_selector';
import {PartialNgModuleLinkerVersion1} from '../../../src/file_linker/partial_linkers/partial_ng_module_linker_1';
import {PartialPipeLinkerVersion1} from '../../../src/file_linker/partial_linkers/partial_pipe_linker_1';
describe('PartialLinkerSelector', () => {
const options: LinkerOptions = {
i18nNormalizeLineEndingsInICUs: true,
enableI18nLegacyMessageIdFormat: false,
i18nUseExternalIds: false,
sourceMapping: false,
};
const options: LinkerOptions = DEFAULT_LINKER_OPTIONS;
let environment: LinkerEnvironment<ts.Statement, ts.Expression>;
let fs: FileSystem;
@@ -65,6 +62,10 @@ describe('PartialLinkerSelector', () => {
.toBeInstanceOf(PartialComponentLinkerVersion1);
expect(selector.getLinker('ɵɵngDeclarePipe', '0.0.0-PLACEHOLDER'))
.toBeInstanceOf(PartialPipeLinkerVersion1);
expect(selector.getLinker('ɵɵngDeclareInjector', '0.0.0-PLACEHOLDER'))
.toBeInstanceOf(PartialInjectorLinkerVersion1);
expect(selector.getLinker('ɵɵngDeclareNgModule', '0.0.0-PLACEHOLDER'))
.toBeInstanceOf(PartialNgModuleLinkerVersion1);
});
it('should return the linker that matches the name and valid full version', () => {