UNPKG

3.08 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { R3DeclareNgModuleFacade } from '../compiler_facade_interface';
9import * as o from '../output/output_ast';
10import { R3CompiledExpression, R3Reference } from './util';
11/**
12 * Metadata required by the module compiler to generate a module def (`ɵmod`) for a type.
13 */
14export interface R3NgModuleMetadata {
15 /**
16 * An expression representing the module type being compiled.
17 */
18 type: R3Reference;
19 /**
20 * An expression representing the module type being compiled, intended for use within a class
21 * definition itself.
22 *
23 * This can differ from the outer `type` if the class is being compiled by ngcc and is inside
24 * an IIFE structure that uses a different name internally.
25 */
26 internalType: o.Expression;
27 /**
28 * An expression intended for use by statements that are adjacent (i.e. tightly coupled) to but
29 * not internal to a class definition.
30 *
31 * This can differ from the outer `type` if the class is being compiled by ngcc and is inside
32 * an IIFE structure that uses a different name internally.
33 */
34 adjacentType: o.Expression;
35 /**
36 * An array of expressions representing the bootstrap components specified by the module.
37 */
38 bootstrap: R3Reference[];
39 /**
40 * An array of expressions representing the directives and pipes declared by the module.
41 */
42 declarations: R3Reference[];
43 /**
44 * An array of expressions representing the imports of the module.
45 */
46 imports: R3Reference[];
47 /**
48 * An array of expressions representing the exports of the module.
49 */
50 exports: R3Reference[];
51 /**
52 * Whether to emit the selector scope values (declarations, imports, exports) inline into the
53 * module definition, or to generate additional statements which patch them on. Inline emission
54 * does not allow components to be tree-shaken, but is useful for JIT mode.
55 */
56 emitInline: boolean;
57 /**
58 * Whether to generate closure wrappers for bootstrap, declarations, imports, and exports.
59 */
60 containsForwardDecls: boolean;
61 /**
62 * The set of schemas that declare elements to be allowed in the NgModule.
63 */
64 schemas: R3Reference[] | null;
65 /** Unique ID or expression representing the unique ID of an NgModule. */
66 id: o.Expression | null;
67}
68/**
69 * Construct an `R3NgModuleDef` for the given `R3NgModuleMetadata`.
70 */
71export declare function compileNgModule(meta: R3NgModuleMetadata): R3CompiledExpression;
72/**
73 * This function is used in JIT mode to generate the call to `ɵɵdefineNgModule()` from a call to
74 * `ɵɵngDeclareNgModule()`.
75 */
76export declare function compileNgModuleDeclarationExpression(meta: R3DeclareNgModuleFacade): o.Expression;
77export declare function createNgModuleType({ type: moduleType, declarations, imports, exports }: R3NgModuleMetadata): o.ExpressionType;