1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | const json_file_1 = require("../../utility/json-file");
|
---|
11 | const workspace_1 = require("../../utility/workspace");
|
---|
12 | const workspace_models_1 = require("../../utility/workspace-models");
|
---|
13 | function default_1() {
|
---|
14 | return async (host) => {
|
---|
15 | var _a;
|
---|
16 | const workspace = await workspace_1.getWorkspace(host);
|
---|
17 | for (const [, project] of workspace.projects) {
|
---|
18 | for (const [, target] of project.targets) {
|
---|
19 | if (target.builder !== workspace_models_1.Builders.NgPackagr) {
|
---|
20 | continue;
|
---|
21 | }
|
---|
22 | if (!target.configurations) {
|
---|
23 | continue;
|
---|
24 | }
|
---|
25 | for (const options of Object.values(target.configurations)) {
|
---|
26 | addDeclarationMapValue(host, options === null || options === void 0 ? void 0 : options.tsConfig, false);
|
---|
27 | }
|
---|
28 | addDeclarationMapValue(host, (_a = target.options) === null || _a === void 0 ? void 0 : _a.tsConfig, true);
|
---|
29 | }
|
---|
30 | }
|
---|
31 | };
|
---|
32 | }
|
---|
33 | exports.default = default_1;
|
---|
34 | function addDeclarationMapValue(host, tsConfigPath, value) {
|
---|
35 | if (typeof tsConfigPath !== 'string') {
|
---|
36 | return;
|
---|
37 | }
|
---|
38 | const declarationMapPath = ['compilerOptions', 'declarationMap'];
|
---|
39 | const file = new json_file_1.JSONFile(host, tsConfigPath);
|
---|
40 | if (file.get(declarationMapPath) === undefined) {
|
---|
41 | file.modify(declarationMapPath, value);
|
---|
42 | }
|
---|
43 | }
|
---|