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 | */
|
---|
8 | import * as o from '../../output/output_ast';
|
---|
9 | import { createFactoryType, FactoryTarget } from '../r3_factory';
|
---|
10 | import { Identifiers as R3 } from '../r3_identifiers';
|
---|
11 | import { DefinitionMap } from '../view/util';
|
---|
12 | import { compileDependencies } from './util';
|
---|
13 | /**
|
---|
14 | * Every time we make a breaking change to the declaration interface or partial-linker behavior, we
|
---|
15 | * must update this constant to prevent old partial-linkers from incorrectly processing the
|
---|
16 | * declaration.
|
---|
17 | *
|
---|
18 | * Do not include any prerelease in these versions as they are ignored.
|
---|
19 | */
|
---|
20 | const MINIMUM_PARTIAL_LINKER_VERSION = '12.0.0';
|
---|
21 | export function compileDeclareFactoryFunction(meta) {
|
---|
22 | const definitionMap = new DefinitionMap();
|
---|
23 | definitionMap.set('minVersion', o.literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
---|
24 | definitionMap.set('version', o.literal('12.2.13'));
|
---|
25 | definitionMap.set('ngImport', o.importExpr(R3.core));
|
---|
26 | definitionMap.set('type', meta.internalType);
|
---|
27 | definitionMap.set('deps', compileDependencies(meta.deps));
|
---|
28 | definitionMap.set('target', o.importExpr(R3.FactoryTarget).prop(FactoryTarget[meta.target]));
|
---|
29 | return {
|
---|
30 | expression: o.importExpr(R3.declareFactory).callFn([definitionMap.toLiteralMap()]),
|
---|
31 | statements: [],
|
---|
32 | type: createFactoryType(meta),
|
---|
33 | };
|
---|
34 | }
|
---|
35 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9yZW5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