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 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler-cli/src/transformers/r3_transform", ["require", "exports", "tslib", "@angular/compiler-cli/src/transformers/node_emitter"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.getAngularClassTransformerFactory = void 0;
|
---|
20 | var tslib_1 = require("tslib");
|
---|
21 | var node_emitter_1 = require("@angular/compiler-cli/src/transformers/node_emitter");
|
---|
22 | /**
|
---|
23 | * Returns a transformer that adds the requested static methods specified by modules.
|
---|
24 | */
|
---|
25 | function getAngularClassTransformerFactory(modules, annotateForClosureCompiler) {
|
---|
26 | if (modules.length === 0) {
|
---|
27 | // If no modules are specified, just return an identity transform.
|
---|
28 | return function () { return function (sf) { return sf; }; };
|
---|
29 | }
|
---|
30 | var moduleMap = new Map(modules.map(function (m) { return [m.fileName, m]; }));
|
---|
31 | return function (context) {
|
---|
32 | return function (sourceFile) {
|
---|
33 | var module = moduleMap.get(sourceFile.fileName);
|
---|
34 | if (module && module.statements.length > 0) {
|
---|
35 | var _a = tslib_1.__read(node_emitter_1.updateSourceFile(sourceFile, module, annotateForClosureCompiler), 1), newSourceFile = _a[0];
|
---|
36 | return newSourceFile;
|
---|
37 | }
|
---|
38 | return sourceFile;
|
---|
39 | };
|
---|
40 | };
|
---|
41 | }
|
---|
42 | exports.getAngularClassTransformerFactory = getAngularClassTransformerFactory;
|
---|
43 | });
|
---|
44 | //# sourceMappingURL=data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