UNPKG

34 kBJavaScriptView Raw
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.buildWebpackBrowser = 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 fs = __importStar(require("fs"));
34const path = __importStar(require("path"));
35const rxjs_1 = require("rxjs");
36const operators_1 = require("rxjs/operators");
37const typescript_1 = require("typescript");
38const utils_1 = require("../utils");
39const action_executor_1 = require("../utils/action-executor");
40const bundle_calculator_1 = require("../utils/bundle-calculator");
41const cache_path_1 = require("../utils/cache-path");
42const color_1 = require("../utils/color");
43const copy_assets_1 = require("../utils/copy-assets");
44const environment_options_1 = require("../utils/environment-options");
45const i18n_inlining_1 = require("../utils/i18n-inlining");
46const index_html_generator_1 = require("../utils/index-file/index-html-generator");
47const output_paths_1 = require("../utils/output-paths");
48const package_chunk_sort_1 = require("../utils/package-chunk-sort");
49const read_tsconfig_1 = require("../utils/read-tsconfig");
50const service_worker_1 = require("../utils/service-worker");
51const spinner_1 = require("../utils/spinner");
52const version_1 = require("../utils/version");
53const webpack_browser_config_1 = require("../utils/webpack-browser-config");
54const configs_1 = require("../webpack/configs");
55const async_chunks_1 = require("../webpack/utils/async-chunks");
56const helpers_1 = require("../webpack/utils/helpers");
57const stats_1 = require("../webpack/utils/stats");
58const cacheDownlevelPath = environment_options_1.cachingDisabled ? undefined : cache_path_1.findCachePath('angular-build-dl');
59async function initialize(options, context, differentialLoadingNeeded, webpackConfigurationTransform) {
60 var _a, _b;
61 const originalOutputPath = options.outputPath;
62 // Assets are processed directly by the builder except when watching
63 const adjustedOptions = options.watch ? options : { ...options, assets: [] };
64 const { config, projectRoot, projectSourceRoot, i18n } = await webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext(adjustedOptions, context, (wco) => [
65 configs_1.getCommonConfig(wco),
66 configs_1.getBrowserConfig(wco),
67 configs_1.getStylesConfig(wco),
68 configs_1.getStatsConfig(wco),
69 configs_1.getAnalyticsConfig(wco, context),
70 configs_1.getTypeScriptConfig(wco),
71 wco.buildOptions.webWorkerTsConfig ? configs_1.getWorkerConfig(wco) : {},
72 ], { differentialLoadingNeeded });
73 // Validate asset option values if processed directly
74 if (((_a = options.assets) === null || _a === void 0 ? void 0 : _a.length) && !((_b = adjustedOptions.assets) === null || _b === void 0 ? void 0 : _b.length)) {
75 utils_1.normalizeAssetPatterns(options.assets, core_1.normalize(context.workspaceRoot), core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)).forEach(({ output }) => {
76 if (output.startsWith('..')) {
77 throw new Error('An asset cannot be written to a location outside of the output path.');
78 }
79 });
80 }
81 let transformedConfig;
82 if (webpackConfigurationTransform) {
83 transformedConfig = await webpackConfigurationTransform(config);
84 }
85 if (options.deleteOutputPath) {
86 utils_1.deleteOutputDir(context.workspaceRoot, originalOutputPath);
87 }
88 return { config: transformedConfig || config, projectRoot, projectSourceRoot, i18n };
89}
90/**
91 * @experimental Direct usage of this function is considered experimental.
92 */
93// eslint-disable-next-line max-lines-per-function
94function buildWebpackBrowser(options, context, transforms = {}) {
95 var _a;
96 const root = core_1.normalize(context.workspaceRoot);
97 const projectName = (_a = context.target) === null || _a === void 0 ? void 0 : _a.project;
98 if (!projectName) {
99 throw new Error('The builder requires a target.');
100 }
101 const baseOutputPath = path.resolve(context.workspaceRoot, options.outputPath);
102 let outputPaths;
103 // Check Angular version.
104 version_1.assertCompatibleAngularVersion(context.workspaceRoot);
105 return rxjs_1.from(context.getProjectMetadata(projectName)).pipe(operators_1.switchMap(async (projectMetadata) => {
106 var _a;
107 const sysProjectRoot = core_1.getSystemPath(core_1.resolve(core_1.normalize(context.workspaceRoot), core_1.normalize((_a = projectMetadata.root) !== null && _a !== void 0 ? _a : '')));
108 const { options: compilerOptions } = read_tsconfig_1.readTsconfig(options.tsConfig, context.workspaceRoot);
109 const target = compilerOptions.target || typescript_1.ScriptTarget.ES5;
110 const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(sysProjectRoot);
111 const isDifferentialLoadingNeeded = buildBrowserFeatures.isDifferentialLoadingNeeded(target);
112 checkInternetExplorerSupport(buildBrowserFeatures.supportedBrowsers, context.logger);
113 return {
114 ...(await initialize(options, context, isDifferentialLoadingNeeded, transforms.webpackConfiguration)),
115 buildBrowserFeatures,
116 isDifferentialLoadingNeeded,
117 target,
118 };
119 }), operators_1.switchMap(
120 // eslint-disable-next-line max-lines-per-function
121 ({ config, projectRoot, projectSourceRoot, i18n, buildBrowserFeatures, isDifferentialLoadingNeeded, target, }) => {
122 const normalizedOptimization = utils_1.normalizeOptimization(options.optimization);
123 return build_webpack_1.runWebpack(config, context, {
124 webpackFactory: require('webpack'),
125 logging: transforms.logging ||
126 ((stats, config) => {
127 if (options.verbose) {
128 context.logger.info(stats.toString(config.stats));
129 }
130 }),
131 }).pipe(
132 // eslint-disable-next-line max-lines-per-function
133 operators_1.concatMap(async (buildEvent) => {
134 var _a, _b, _c, _d, _e, _f, _g, _h;
135 const spinner = new spinner_1.Spinner();
136 spinner.enabled = options.progress !== false;
137 const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
138 const webpackRawStats = buildEvent.webpackStats;
139 if (!webpackRawStats) {
140 throw new Error('Webpack stats build result is required.');
141 }
142 // Fix incorrectly set `initial` value on chunks.
143 const extraEntryPoints = [
144 ...helpers_1.normalizeExtraEntryPoints(options.styles || [], 'styles'),
145 ...helpers_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts'),
146 ];
147 const webpackStats = {
148 ...webpackRawStats,
149 chunks: async_chunks_1.markAsyncChunksNonInitial(webpackRawStats, extraEntryPoints),
150 };
151 if (!success) {
152 // If using bundle downleveling then there is only one build
153 // If it fails show any diagnostic messages and bail
154 if (stats_1.statsHasWarnings(webpackStats)) {
155 context.logger.warn(stats_1.statsWarningsToString(webpackStats, { colors: true }));
156 }
157 if (stats_1.statsHasErrors(webpackStats)) {
158 context.logger.error(stats_1.statsErrorsToString(webpackStats, { colors: true }));
159 }
160 return { success };
161 }
162 else {
163 const processResults = [];
164 const bundleInfoStats = [];
165 outputPaths = output_paths_1.ensureOutputPaths(baseOutputPath, i18n);
166 let noModuleFiles;
167 let moduleFiles;
168 let files;
169 const scriptsEntryPointName = helpers_1.normalizeExtraEntryPoints(options.scripts || [], 'scripts').map((x) => x.bundleName);
170 if (isDifferentialLoadingNeeded && options.watch) {
171 moduleFiles = emittedFiles;
172 files = moduleFiles.filter((x) => x.extension === '.css' || (x.name && scriptsEntryPointName.includes(x.name)));
173 if (i18n.shouldInline) {
174 const success = await i18n_inlining_1.i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), scriptsEntryPointName, webpackOutputPath, target <= typescript_1.ScriptTarget.ES5, options.i18nMissingTranslation);
175 if (!success) {
176 return { success: false };
177 }
178 }
179 }
180 else if (isDifferentialLoadingNeeded) {
181 moduleFiles = [];
182 noModuleFiles = [];
183 // Common options for all bundle process actions
184 const sourceMapOptions = utils_1.normalizeSourceMaps(options.sourceMap || false);
185 const actionOptions = {
186 optimize: normalizedOptimization.scripts,
187 sourceMaps: sourceMapOptions.scripts,
188 hiddenSourceMaps: sourceMapOptions.hidden,
189 vendorSourceMaps: sourceMapOptions.vendor,
190 integrityAlgorithm: options.subresourceIntegrity ? 'sha384' : undefined,
191 };
192 let mainChunkId;
193 const actions = [];
194 let workerReplacements;
195 const seen = new Set();
196 for (const file of emittedFiles) {
197 // Assets are not processed nor injected into the index
198 if (file.asset) {
199 // WorkerPlugin adds worker files to assets
200 if (file.file.endsWith('.worker.js')) {
201 if (!workerReplacements) {
202 workerReplacements = [];
203 }
204 workerReplacements.push([
205 file.file,
206 file.file.replace(/\-(es20\d{2}|esnext)/, '-es5'),
207 ]);
208 }
209 else {
210 continue;
211 }
212 }
213 // Scripts and non-javascript files are not processed
214 if (file.extension !== '.js' ||
215 (file.name && scriptsEntryPointName.includes(file.name))) {
216 if (files === undefined) {
217 files = [];
218 }
219 files.push(file);
220 continue;
221 }
222 // Ignore already processed files; emittedFiles can contain duplicates
223 if (seen.has(file.file)) {
224 continue;
225 }
226 seen.add(file.file);
227 if (file.name === 'vendor' || (!mainChunkId && file.name === 'main')) {
228 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
229 mainChunkId = file.id.toString();
230 }
231 // All files at this point except ES5 polyfills are module scripts
232 const es5Polyfills = file.file.startsWith('polyfills-es5');
233 if (!es5Polyfills) {
234 moduleFiles.push(file);
235 }
236 // Retrieve the content/map for the file
237 // NOTE: Additional future optimizations will read directly from memory
238 let filename = path.join(webpackOutputPath, file.file);
239 const code = fs.readFileSync(filename, 'utf8');
240 let map;
241 if (actionOptions.sourceMaps) {
242 try {
243 map = fs.readFileSync(filename + '.map', 'utf8');
244 if (es5Polyfills) {
245 fs.unlinkSync(filename + '.map');
246 }
247 }
248 catch { }
249 }
250 if (es5Polyfills) {
251 fs.unlinkSync(filename);
252 filename = filename.replace(/\-es20\d{2}/, '');
253 }
254 const es2015Polyfills = file.file.startsWith('polyfills-es20');
255 // Record the bundle processing action
256 // The runtime chunk gets special processing for lazy loaded files
257 actions.push({
258 ...actionOptions,
259 filename,
260 code,
261 map,
262 // id is always present for non-assets
263 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
264 name: file.id,
265 runtime: file.file.startsWith('runtime'),
266 ignoreOriginal: es5Polyfills,
267 optimizeOnly: es2015Polyfills,
268 });
269 // ES2015 polyfills are only optimized; optimization check was performed above
270 if (es2015Polyfills) {
271 continue;
272 }
273 // Add the newly created ES5 bundles to the index as nomodule scripts
274 const newFilename = es5Polyfills
275 ? file.file.replace(/\-es20\d{2}/, '')
276 : file.file.replace(/\-(es20\d{2}|esnext)/, '-es5');
277 noModuleFiles.push({ ...file, file: newFilename });
278 }
279 const processActions = [];
280 let processRuntimeAction;
281 for (const action of actions) {
282 // If SRI is enabled always process the runtime bundle
283 // Lazy route integrity values are stored in the runtime bundle
284 if (action.integrityAlgorithm && action.runtime) {
285 processRuntimeAction = action;
286 }
287 else {
288 processActions.push({ replacements: workerReplacements, ...action });
289 }
290 }
291 const executor = new action_executor_1.BundleActionExecutor({ cachePath: cacheDownlevelPath, i18n }, options.subresourceIntegrity ? 'sha384' : undefined);
292 // Execute the bundle processing actions
293 try {
294 spinner.start('Generating ES5 bundles for differential loading...');
295 for await (const result of executor.processAll(processActions)) {
296 processResults.push(result);
297 }
298 // Runtime must be processed after all other files
299 if (processRuntimeAction) {
300 const runtimeOptions = {
301 ...processRuntimeAction,
302 runtimeData: processResults,
303 supportedBrowsers: buildBrowserFeatures.supportedBrowsers,
304 };
305 processResults.push(await Promise.resolve().then(() => __importStar(require('../utils/process-bundle'))).then((m) => m.process(runtimeOptions)));
306 }
307 spinner.succeed('ES5 bundle generation complete.');
308 if (i18n.shouldInline) {
309 spinner.start('Generating localized bundles...');
310 const inlineActions = [];
311 const processedFiles = new Set();
312 for (const result of processResults) {
313 if (result.original) {
314 inlineActions.push({
315 filename: path.basename(result.original.filename),
316 code: fs.readFileSync(result.original.filename, 'utf8'),
317 map: result.original.map &&
318 fs.readFileSync(result.original.map.filename, 'utf8'),
319 outputPath: baseOutputPath,
320 es5: false,
321 missingTranslation: options.i18nMissingTranslation,
322 setLocale: result.name === mainChunkId,
323 });
324 processedFiles.add(result.original.filename);
325 if (result.original.map) {
326 processedFiles.add(result.original.map.filename);
327 }
328 }
329 if (result.downlevel) {
330 inlineActions.push({
331 filename: path.basename(result.downlevel.filename),
332 code: fs.readFileSync(result.downlevel.filename, 'utf8'),
333 map: result.downlevel.map &&
334 fs.readFileSync(result.downlevel.map.filename, 'utf8'),
335 outputPath: baseOutputPath,
336 es5: true,
337 missingTranslation: options.i18nMissingTranslation,
338 setLocale: result.name === mainChunkId,
339 });
340 processedFiles.add(result.downlevel.filename);
341 if (result.downlevel.map) {
342 processedFiles.add(result.downlevel.map.filename);
343 }
344 }
345 }
346 let hasErrors = false;
347 try {
348 for await (const result of executor.inlineAll(inlineActions)) {
349 if (options.verbose) {
350 context.logger.info(`Localized "${result.file}" [${result.count} translation(s)].`);
351 }
352 for (const diagnostic of result.diagnostics) {
353 spinner.stop();
354 if (diagnostic.type === 'error') {
355 hasErrors = true;
356 context.logger.error(diagnostic.message);
357 }
358 else {
359 context.logger.warn(diagnostic.message);
360 }
361 spinner.start();
362 }
363 }
364 // Copy any non-processed files into the output locations
365 await copy_assets_1.copyAssets([
366 {
367 glob: '**/*',
368 input: webpackOutputPath,
369 output: '',
370 ignore: [...processedFiles].map((f) => path.relative(webpackOutputPath, f)),
371 },
372 ], Array.from(outputPaths.values()), '');
373 }
374 catch (err) {
375 spinner.fail('Localized bundle generation failed.');
376 return { success: false, error: mapErrorToMessage(err) };
377 }
378 if (hasErrors) {
379 spinner.fail('Localized bundle generation failed.');
380 }
381 else {
382 spinner.succeed('Localized bundle generation complete.');
383 }
384 if (hasErrors) {
385 return { success: false };
386 }
387 }
388 }
389 finally {
390 executor.stop();
391 }
392 for (const result of processResults) {
393 const chunk = (_a = webpackStats.chunks) === null || _a === void 0 ? void 0 : _a.find((chunk) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; });
394 if (result.original) {
395 bundleInfoStats.push(generateBundleInfoStats(result.original, chunk, 'modern'));
396 }
397 if (result.downlevel) {
398 bundleInfoStats.push(generateBundleInfoStats(result.downlevel, chunk, 'legacy'));
399 }
400 }
401 const unprocessedChunks = ((_b = webpackStats.chunks) === null || _b === void 0 ? void 0 : _b.filter((chunk) => !processResults.find((result) => { var _a; return ((_a = chunk.id) === null || _a === void 0 ? void 0 : _a.toString()) === result.name; }))) || [];
402 for (const chunk of unprocessedChunks) {
403 const asset = (_c = webpackStats.assets) === null || _c === void 0 ? void 0 : _c.find((a) => { var _a; return a.name === ((_a = chunk.files) === null || _a === void 0 ? void 0 : _a[0]); });
404 bundleInfoStats.push(stats_1.generateBundleStats({ ...chunk, size: asset === null || asset === void 0 ? void 0 : asset.size }));
405 }
406 }
407 else {
408 files = emittedFiles.filter((x) => x.name !== 'polyfills-es5');
409 noModuleFiles = emittedFiles.filter((x) => x.name === 'polyfills-es5');
410 if (i18n.shouldInline) {
411 const success = await i18n_inlining_1.i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), scriptsEntryPointName, webpackOutputPath, target <= typescript_1.ScriptTarget.ES5, options.i18nMissingTranslation);
412 if (!success) {
413 return { success: false };
414 }
415 }
416 }
417 // Check for budget errors and display them to the user.
418 const budgets = options.budgets;
419 if (budgets === null || budgets === void 0 ? void 0 : budgets.length) {
420 const budgetFailures = bundle_calculator_1.checkBudgets(budgets, webpackStats, processResults);
421 for (const { severity, message } of budgetFailures) {
422 switch (severity) {
423 case bundle_calculator_1.ThresholdSeverity.Warning:
424 (_d = webpackStats.warnings) === null || _d === void 0 ? void 0 : _d.push({ message });
425 break;
426 case bundle_calculator_1.ThresholdSeverity.Error:
427 (_e = webpackStats.errors) === null || _e === void 0 ? void 0 : _e.push({ message });
428 break;
429 default:
430 assertNever(severity);
431 }
432 }
433 }
434 const buildSuccess = success && !stats_1.statsHasErrors(webpackStats);
435 if (buildSuccess) {
436 // Copy assets
437 if (!options.watch && ((_f = options.assets) === null || _f === void 0 ? void 0 : _f.length)) {
438 spinner.start('Copying assets...');
439 try {
440 await copy_assets_1.copyAssets(utils_1.normalizeAssetPatterns(options.assets, root, core_1.normalize(projectRoot), projectSourceRoot === undefined ? undefined : core_1.normalize(projectSourceRoot)), Array.from(outputPaths.values()), context.workspaceRoot);
441 spinner.succeed('Copying assets complete.');
442 }
443 catch (err) {
444 spinner.fail(color_1.colors.redBright('Copying of assets failed.'));
445 return { success: false, error: 'Unable to copy assets: ' + err.message };
446 }
447 }
448 if (options.index) {
449 spinner.start('Generating index html...');
450 const WOFFSupportNeeded = !buildBrowserFeatures.isFeatureSupported('woff2');
451 const entrypoints = package_chunk_sort_1.generateEntryPoints({
452 scripts: (_g = options.scripts) !== null && _g !== void 0 ? _g : [],
453 styles: (_h = options.styles) !== null && _h !== void 0 ? _h : [],
454 });
455 const indexHtmlGenerator = new index_html_generator_1.IndexHtmlGenerator({
456 indexPath: path.join(context.workspaceRoot, webpack_browser_config_1.getIndexInputFile(options.index)),
457 entrypoints,
458 deployUrl: options.deployUrl,
459 sri: options.subresourceIntegrity,
460 WOFFSupportNeeded,
461 optimization: normalizedOptimization,
462 crossOrigin: options.crossOrigin,
463 postTransform: transforms.indexHtml,
464 });
465 let hasErrors = false;
466 for (const [locale, outputPath] of outputPaths.entries()) {
467 try {
468 const { content, warnings, errors } = await indexHtmlGenerator.process({
469 baseHref: getLocaleBaseHref(i18n, locale) || options.baseHref,
470 // i18nLocale is used when Ivy is disabled
471 lang: locale || undefined,
472 outputPath,
473 files: mapEmittedFilesToFileInfo(files),
474 noModuleFiles: mapEmittedFilesToFileInfo(noModuleFiles),
475 moduleFiles: mapEmittedFilesToFileInfo(moduleFiles),
476 });
477 if (warnings.length || errors.length) {
478 spinner.stop();
479 warnings.forEach((m) => context.logger.warn(m));
480 errors.forEach((m) => {
481 context.logger.error(m);
482 hasErrors = true;
483 });
484 spinner.start();
485 }
486 const indexOutput = path.join(outputPath, webpack_browser_config_1.getIndexOutputFile(options.index));
487 await fs.promises.mkdir(path.dirname(indexOutput), { recursive: true });
488 await fs.promises.writeFile(indexOutput, content);
489 }
490 catch (error) {
491 spinner.fail('Index html generation failed.');
492 return { success: false, error: mapErrorToMessage(error) };
493 }
494 }
495 if (hasErrors) {
496 spinner.fail('Index html generation failed.');
497 return { success: false };
498 }
499 else {
500 spinner.succeed('Index html generation complete.');
501 }
502 }
503 if (options.serviceWorker) {
504 spinner.start('Generating service worker...');
505 for (const [locale, outputPath] of outputPaths.entries()) {
506 try {
507 await service_worker_1.augmentAppWithServiceWorker(root, core_1.normalize(projectRoot), core_1.normalize(outputPath), getLocaleBaseHref(i18n, locale) || options.baseHref || '/', options.ngswConfigPath);
508 }
509 catch (error) {
510 spinner.fail('Service worker generation failed.');
511 return { success: false, error: mapErrorToMessage(error) };
512 }
513 }
514 spinner.succeed('Service worker generation complete.');
515 }
516 }
517 stats_1.webpackStatsLogger(context.logger, webpackStats, config, bundleInfoStats);
518 return { success: buildSuccess };
519 }
520 }), operators_1.map((event) => ({
521 ...event,
522 baseOutputPath,
523 outputPath: baseOutputPath,
524 outputPaths: (outputPaths && Array.from(outputPaths.values())) || [baseOutputPath],
525 })));
526 }));
527 function getLocaleBaseHref(i18n, locale) {
528 var _a, _b;
529 if (i18n.locales[locale] && ((_a = i18n.locales[locale]) === null || _a === void 0 ? void 0 : _a.baseHref) !== '') {
530 return utils_1.urlJoin(options.baseHref || '', (_b = i18n.locales[locale].baseHref) !== null && _b !== void 0 ? _b : `/${locale}/`);
531 }
532 return undefined;
533 }
534}
535exports.buildWebpackBrowser = buildWebpackBrowser;
536function mapErrorToMessage(error) {
537 if (error instanceof Error) {
538 return error.message;
539 }
540 if (typeof error === 'string') {
541 return error;
542 }
543 return undefined;
544}
545function assertNever(input) {
546 throw new Error(`Unexpected call to assertNever() with input: ${JSON.stringify(input, null /* replacer */, 4 /* tabSize */)}`);
547}
548function generateBundleInfoStats(bundle, chunk, chunkType) {
549 return stats_1.generateBundleStats({
550 size: bundle.size,
551 files: bundle.map ? [bundle.filename, bundle.map.filename] : [bundle.filename],
552 names: chunk === null || chunk === void 0 ? void 0 : chunk.names,
553 initial: !!(chunk === null || chunk === void 0 ? void 0 : chunk.initial),
554 rendered: true,
555 chunkType,
556 });
557}
558function mapEmittedFilesToFileInfo(files = []) {
559 const filteredFiles = [];
560 for (const { file, name, extension, initial } of files) {
561 if (name && initial) {
562 filteredFiles.push({ file, extension, name });
563 }
564 }
565 return filteredFiles;
566}
567function checkInternetExplorerSupport(supportedBrowsers, logger) {
568 const hasIE9 = supportedBrowsers.includes('ie 9');
569 const hasIE10 = supportedBrowsers.includes('ie 10');
570 const hasIE11 = supportedBrowsers.includes('ie 11');
571 if (hasIE9 || hasIE10) {
572 const browsers = (hasIE9 ? 'IE 9' + (hasIE10 ? ' & ' : '') : '') + (hasIE10 ? 'IE 10' : '');
573 logger.warn(`Warning: Support was requested for ${browsers} in the project's browserslist configuration. ` +
574 (hasIE9 && hasIE10 ? 'These browsers are' : 'This browser is') +
575 ' no longer officially supported with Angular v11 and higher.' +
576 '\nFor more information, see https://v10.angular.io/guide/deprecations#ie-9-10-and-mobile');
577 }
578 if (hasIE11) {
579 logger.warn(`Warning: Support was requested for IE 11 in the project's browserslist configuration. ` +
580 'IE 11 support is deprecated since Angular v12.' +
581 '\nFor more information, see https://angular.io/guide/browser-support');
582 }
583}
584exports.default = architect_1.createBuilder(buildWebpackBrowser);