source: trip-planner-front/node_modules/@angular-devkit/build-angular/src/server/index.js@ e29cc2e

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

initial commit

  • Property mode set to 100644
File size: 5.8 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 */
9var __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}));
16var __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});
21var __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};
28Object.defineProperty(exports, "__esModule", { value: true });
29exports.execute = void 0;
30const architect_1 = require("@angular-devkit/architect");
31const build_webpack_1 = require("@angular-devkit/build-webpack");
32const core_1 = require("@angular-devkit/core");
33const path = __importStar(require("path"));
34const rxjs_1 = require("rxjs");
35const operators_1 = require("rxjs/operators");
36const typescript_1 = require("typescript");
37const utils_1 = require("../utils");
38const i18n_inlining_1 = require("../utils/i18n-inlining");
39const output_paths_1 = require("../utils/output-paths");
40const read_tsconfig_1 = require("../utils/read-tsconfig");
41const version_1 = require("../utils/version");
42const webpack_browser_config_1 = require("../utils/webpack-browser-config");
43const configs_1 = require("../webpack/configs");
44const stats_1 = require("../webpack/utils/stats");
45/**
46 * @experimental Direct usage of this function is considered experimental.
47 */
48function execute(options, context, transforms = {}) {
49 const root = context.workspaceRoot;
50 // Check Angular version.
51 version_1.assertCompatibleAngularVersion(root);
52 const tsConfig = read_tsconfig_1.readTsconfig(options.tsConfig, root);
53 const target = tsConfig.options.target || typescript_1.ScriptTarget.ES5;
54 const baseOutputPath = path.resolve(root, options.outputPath);
55 let outputPaths;
56 if (typeof options.bundleDependencies === 'string') {
57 options.bundleDependencies = options.bundleDependencies === 'all';
58 context.logger.warn(`Option 'bundleDependencies' string value is deprecated since version 9. Use a boolean value instead.`);
59 }
60 if (!options.bundleDependencies && tsConfig.options.enableIvy) {
61 // eslint-disable-next-line import/no-extraneous-dependencies
62 const { __processed_by_ivy_ngcc__, main = '' } = require('@angular/core/package.json');
63 if (!__processed_by_ivy_ngcc__ ||
64 !__processed_by_ivy_ngcc__.main ||
65 main.includes('__ivy_ngcc__')) {
66 context.logger.warn(core_1.tags.stripIndent `
67 Warning: Turning off 'bundleDependencies' with Ivy may result in undefined behaviour
68 unless 'node_modules' are transformed using the standalone Angular compatibility compiler (NGCC).
69 See: https://angular.io/guide/ivy#ivy-and-universal-app-shell
70 `);
71 }
72 }
73 return rxjs_1.from(initialize(options, context, transforms.webpackConfiguration)).pipe(operators_1.concatMap(({ config, i18n }) => {
74 return build_webpack_1.runWebpack(config, context, {
75 webpackFactory: require('webpack'),
76 logging: (stats, config) => {
77 if (options.verbose) {
78 context.logger.info(stats.toString(config.stats));
79 }
80 },
81 }).pipe(operators_1.concatMap(async (output) => {
82 const { emittedFiles = [], outputPath, webpackStats } = output;
83 if (!webpackStats) {
84 throw new Error('Webpack stats build result is required.');
85 }
86 let success = output.success;
87 if (success && i18n.shouldInline) {
88 outputPaths = output_paths_1.ensureOutputPaths(baseOutputPath, i18n);
89 success = await i18n_inlining_1.i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), [], outputPath, target <= typescript_1.ScriptTarget.ES5, options.i18nMissingTranslation);
90 }
91 stats_1.webpackStatsLogger(context.logger, webpackStats, config);
92 return { ...output, success };
93 }));
94 }), operators_1.map((output) => {
95 if (!output.success) {
96 return output;
97 }
98 return {
99 ...output,
100 baseOutputPath,
101 outputPath: baseOutputPath,
102 outputPaths: outputPaths || [baseOutputPath],
103 };
104 }));
105}
106exports.execute = execute;
107exports.default = architect_1.createBuilder(execute);
108async function initialize(options, context, webpackConfigurationTransform) {
109 const originalOutputPath = options.outputPath;
110 const { config, i18n } = await webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext({
111 ...options,
112 buildOptimizer: false,
113 aot: true,
114 platform: 'server',
115 }, context, (wco) => [
116 configs_1.getCommonConfig(wco),
117 configs_1.getServerConfig(wco),
118 configs_1.getStylesConfig(wco),
119 configs_1.getStatsConfig(wco),
120 configs_1.getTypeScriptConfig(wco),
121 ]);
122 let transformedConfig;
123 if (webpackConfigurationTransform) {
124 transformedConfig = await webpackConfigurationTransform(config);
125 }
126 if (options.deleteOutputPath) {
127 utils_1.deleteOutputDir(context.workspaceRoot, originalOutputPath);
128 }
129 return { config: transformedConfig || config, i18n };
130}
Note: See TracBrowser for help on using the repository browser.