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 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
---|
10 | if (k2 === undefined) k2 = k;
|
---|
11 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
---|
12 | }) : (function(o, m, k, k2) {
|
---|
13 | if (k2 === undefined) k2 = k;
|
---|
14 | o[k2] = m[k];
|
---|
15 | }));
|
---|
16 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
---|
17 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
18 | }) : function(o, v) {
|
---|
19 | o["default"] = v;
|
---|
20 | });
|
---|
21 | var __importStar = (this && this.__importStar) || function (mod) {
|
---|
22 | if (mod && mod.__esModule) return mod;
|
---|
23 | var result = {};
|
---|
24 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
---|
25 | __setModuleDefault(result, mod);
|
---|
26 | return result;
|
---|
27 | };
|
---|
28 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
29 | exports.maxWorkers = exports.profilingEnabled = exports.persistentBuildCacheEnabled = exports.cachingBasePath = exports.cachingDisabled = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
---|
30 | const path = __importStar(require("path"));
|
---|
31 | function isDisabled(variable) {
|
---|
32 | return variable === '0' || variable.toLowerCase() === 'false';
|
---|
33 | }
|
---|
34 | function isEnabled(variable) {
|
---|
35 | return variable === '1' || variable.toLowerCase() === 'true';
|
---|
36 | }
|
---|
37 | function isPresent(variable) {
|
---|
38 | return typeof variable === 'string' && variable !== '';
|
---|
39 | }
|
---|
40 | // Optimization and mangling
|
---|
41 | const debugOptimizeVariable = process.env['NG_BUILD_DEBUG_OPTIMIZE'];
|
---|
42 | const debugOptimize = (() => {
|
---|
43 | if (!isPresent(debugOptimizeVariable) || isDisabled(debugOptimizeVariable)) {
|
---|
44 | return {
|
---|
45 | mangle: true,
|
---|
46 | minify: true,
|
---|
47 | beautify: false,
|
---|
48 | };
|
---|
49 | }
|
---|
50 | const debugValue = {
|
---|
51 | mangle: false,
|
---|
52 | minify: false,
|
---|
53 | beautify: true,
|
---|
54 | };
|
---|
55 | if (isEnabled(debugOptimizeVariable)) {
|
---|
56 | return debugValue;
|
---|
57 | }
|
---|
58 | for (const part of debugOptimizeVariable.split(',')) {
|
---|
59 | switch (part.trim().toLowerCase()) {
|
---|
60 | case 'mangle':
|
---|
61 | debugValue.mangle = true;
|
---|
62 | break;
|
---|
63 | case 'minify':
|
---|
64 | debugValue.minify = true;
|
---|
65 | break;
|
---|
66 | case 'beautify':
|
---|
67 | debugValue.beautify = true;
|
---|
68 | break;
|
---|
69 | }
|
---|
70 | }
|
---|
71 | return debugValue;
|
---|
72 | })();
|
---|
73 | const mangleVariable = process.env['NG_BUILD_MANGLE'];
|
---|
74 | exports.allowMangle = isPresent(mangleVariable)
|
---|
75 | ? !isDisabled(mangleVariable)
|
---|
76 | : debugOptimize.mangle;
|
---|
77 | exports.shouldBeautify = debugOptimize.beautify;
|
---|
78 | exports.allowMinify = debugOptimize.minify;
|
---|
79 | // Build cache
|
---|
80 | const cacheVariable = process.env['NG_BUILD_CACHE'];
|
---|
81 | exports.cachingDisabled = isPresent(cacheVariable) && isDisabled(cacheVariable);
|
---|
82 | exports.cachingBasePath = (() => {
|
---|
83 | if (exports.cachingDisabled || !isPresent(cacheVariable) || isEnabled(cacheVariable)) {
|
---|
84 | return null;
|
---|
85 | }
|
---|
86 | if (!path.isAbsolute(cacheVariable)) {
|
---|
87 | throw new Error('NG_BUILD_CACHE path value must be absolute.');
|
---|
88 | }
|
---|
89 | return cacheVariable;
|
---|
90 | })();
|
---|
91 | // Persistent build cache
|
---|
92 | const persistentBuildCacheVariable = process.env['NG_PERSISTENT_BUILD_CACHE'];
|
---|
93 | exports.persistentBuildCacheEnabled = !exports.cachingDisabled &&
|
---|
94 | isPresent(persistentBuildCacheVariable) &&
|
---|
95 | isEnabled(persistentBuildCacheVariable);
|
---|
96 | // Build profiling
|
---|
97 | const profilingVariable = process.env['NG_BUILD_PROFILING'];
|
---|
98 | exports.profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);
|
---|
99 | /**
|
---|
100 | * Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
|
---|
101 | * This cause `Error: Call retries were exceeded` errors when trying to use them.
|
---|
102 | *
|
---|
103 | * @see https://github.com/nodejs/node/issues/28762
|
---|
104 | * @see https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
|
---|
105 | * @see https://ithub.com/angular/angular-cli/issues/16860#issuecomment-588828079
|
---|
106 | *
|
---|
107 | */
|
---|
108 | const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
|
---|
109 | exports.maxWorkers = isPresent(maxWorkersVariable) ? +maxWorkersVariable : 4;
|
---|