source: trip-planner-front/node_modules/@schematics/angular/migrations/update-12/update-angular-config.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.5 KB
Line 
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 */
9Object.defineProperty(exports, "__esModule", { value: true });
10const core_1 = require("@angular-devkit/core");
11const workspace_1 = require("../../utility/workspace");
12const BrowserBuilderOptions = [
13 ['aot', false, true],
14 ['vendorChunk', true, false],
15 ['extractLicenses', false, true],
16 ['buildOptimizer', false, true],
17 ['sourceMap', true, false],
18 ['optimization', false, true],
19 ['namedChunks', true, false],
20];
21const ServerBuilderOptions = [
22 ['sourceMap', true, false],
23 ['optimization', false, true],
24];
25function default_1() {
26 return (_tree, context) => workspace_1.updateWorkspace((workspace) => {
27 for (const [targetName, target, projectName] of workspace_1.allWorkspaceTargets(workspace)) {
28 if (!target.builder.startsWith('@angular-devkit/') &&
29 !target.builder.startsWith('@nguniversal/')) {
30 context.logger.warn(core_1.tags.stripIndent `
31 "${targetName}" target in "${projectName}" project is using a third-party builder.
32 You may need to adjust the options to retain the existing behavior.
33 For more information, see the breaking changes section within the release notes: https://github.com/angular/angular-cli/releases/tag/v12.0.0
34 `);
35 continue;
36 }
37 // Only interested in Angular Devkit browser and server builders
38 switch (target.builder) {
39 case '@angular-devkit/build-angular:server':
40 updateOptions(target, ServerBuilderOptions);
41 break;
42 case '@angular-devkit/build-angular:browser':
43 updateOptions(target, BrowserBuilderOptions);
44 break;
45 }
46 for (const [, options] of workspace_1.allTargetOptions(target)) {
47 delete options.experimentalRollupPass;
48 delete options.lazyModules;
49 delete options.forkTypeChecker;
50 }
51 }
52 });
53}
54exports.default = default_1;
55function updateOptions(target, optionsToUpdate) {
56 // This is a hacky way to make this migration idempotent.
57 // `defaultConfiguration` was only introduced in v12 projects and hence v11 projects do not have this property.
58 // Setting it as an empty string will not cause any side-effect.
59 if (typeof target.defaultConfiguration === 'string') {
60 return;
61 }
62 target.defaultConfiguration = '';
63 if (!target.options) {
64 target.options = {};
65 }
66 const configurationOptions = target.configurations && Object.values(target.configurations);
67 for (const [optionName, oldDefault, newDefault] of optionsToUpdate) {
68 let value = target.options[optionName];
69 if (value === newDefault) {
70 // Value is same as new default
71 delete target.options[optionName];
72 }
73 else if (value === undefined) {
74 // Value is not defined, hence the default in the builder was used.
75 target.options[optionName] = oldDefault;
76 value = oldDefault;
77 }
78 // Remove overrides in configurations which are no longer needed.
79 configurationOptions === null || configurationOptions === void 0 ? void 0 : configurationOptions.filter((o) => o && o[optionName] === value).forEach((o) => o && delete o[optionName]);
80 }
81}
Note: See TracBrowser for help on using the repository browser.