@angular-devkit/build-angular 18.0.0-next.2 → 18.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builders.json +1 -5
- package/package.json +21 -20
- package/src/builders/app-shell/index.js +3 -5
- package/src/builders/browser/index.d.ts +1 -1
- package/src/builders/browser/index.js +9 -13
- package/src/builders/browser-esbuild/index.d.ts +2 -2
- package/src/builders/browser-esbuild/index.js +6 -9
- package/src/builders/dev-server/builder.d.ts +2 -2
- package/src/builders/dev-server/builder.js +11 -6
- package/src/builders/dev-server/index.d.ts +1 -1
- package/src/builders/dev-server/webpack-server.d.ts +1 -1
- package/src/builders/dev-server/webpack-server.js +5 -6
- package/src/builders/extract-i18n/application-extraction.js +2 -2
- package/src/builders/extract-i18n/builder.js +3 -4
- package/src/builders/extract-i18n/options.d.ts +1 -1
- package/src/builders/extract-i18n/options.js +2 -2
- package/src/builders/jest/index.js +2 -2
- package/src/builders/karma/index.js +3 -4
- package/src/builders/ng-packagr/index.js +8 -7
- package/src/builders/ng-packagr/schema.d.ts +4 -0
- package/src/builders/ng-packagr/schema.json +4 -0
- package/src/builders/prerender/index.js +2 -2
- package/src/builders/prerender/render-worker.js +1 -1
- package/src/builders/server/index.js +3 -4
- package/src/builders/server/platform-server-exports-loader.js +2 -1
- package/src/builders/ssr-dev-server/index.js +34 -34
- package/src/builders/web-test-runner/index.js +2 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -2
- package/src/tools/babel/presets/application.js +1 -1
- package/src/tools/webpack/configs/styles.js +2 -2
- package/src/tools/webpack/plugins/any-component-style-budget-checker.d.ts +2 -2
- package/src/tools/webpack/plugins/any-component-style-budget-checker.js +14 -17
- package/src/tools/webpack/plugins/css-optimizer-plugin.js +2 -2
- package/src/tools/webpack/plugins/index-html-webpack-plugin.d.ts +1 -1
- package/src/tools/webpack/plugins/index-html-webpack-plugin.js +3 -3
- package/src/tools/webpack/plugins/javascript-optimizer-plugin.js +2 -2
- package/src/tools/webpack/plugins/service-worker-plugin.js +2 -2
- package/src/tools/webpack/utils/stats.d.ts +1 -14
- package/src/tools/webpack/utils/stats.js +3 -207
- package/src/utils/action-executor.d.ts +1 -1
- package/src/utils/i18n-inlining.d.ts +1 -1
- package/src/utils/i18n-webpack.d.ts +16 -0
- package/src/utils/i18n-webpack.js +107 -0
- package/src/utils/index.d.ts +1 -2
- package/src/utils/index.js +4 -2
- package/src/utils/normalize-builder-schema.js +2 -2
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/normalize-optimization.d.ts +1 -1
- package/src/utils/normalize-optimization.js +0 -2
- package/src/utils/output-paths.d.ts +1 -1
- package/src/utils/webpack-browser-config.d.ts +1 -1
- package/src/utils/webpack-browser-config.js +2 -2
- package/src/builders/application/build-action.d.ts +0 -33
- package/src/builders/application/build-action.js +0 -183
- package/src/builders/application/execute-build.d.ts +0 -11
- package/src/builders/application/execute-build.js +0 -127
- package/src/builders/application/execute-post-bundle.d.ts +0 -25
- package/src/builders/application/execute-post-bundle.js +0 -96
- package/src/builders/application/i18n.d.ts +0 -29
- package/src/builders/application/i18n.js +0 -128
- package/src/builders/application/index.d.ts +0 -57
- package/src/builders/application/index.js +0 -121
- package/src/builders/application/options.d.ts +0 -149
- package/src/builders/application/options.js +0 -352
- package/src/builders/application/schema.d.ts +0 -512
- package/src/builders/application/schema.js +0 -58
- package/src/builders/application/schema.json +0 -635
- package/src/builders/application/setup-bundling.d.ts +0 -19
- package/src/builders/application/setup-bundling.js +0 -71
- package/src/builders/dev-server/vite-server.d.ts +0 -30
- package/src/builders/dev-server/vite-server.js +0 -502
- package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -27
- package/src/tools/babel/plugins/adjust-static-class-members.js +0 -351
- package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -23
- package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
- package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
- package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
- package/src/tools/babel/plugins/index.d.ts +0 -11
- package/src/tools/babel/plugins/index.js +0 -21
- package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -16
- package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -90
- package/src/tools/esbuild/angular/angular-host.d.ts +0 -26
- package/src/tools/esbuild/angular/angular-host.js +0 -72
- package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +0 -42
- package/src/tools/esbuild/angular/compilation/angular-compilation.js +0 -94
- package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +0 -21
- package/src/tools/esbuild/angular/compilation/aot-compilation.js +0 -228
- package/src/tools/esbuild/angular/compilation/factory.d.ts +0 -16
- package/src/tools/esbuild/angular/compilation/factory.js +0 -56
- package/src/tools/esbuild/angular/compilation/index.d.ts +0 -10
- package/src/tools/esbuild/angular/compilation/index.js +0 -17
- package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +0 -21
- package/src/tools/esbuild/angular/compilation/jit-compilation.js +0 -106
- package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +0 -20
- package/src/tools/esbuild/angular/compilation/noop-compilation.js +0 -26
- package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +0 -42
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +0 -123
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -33
- package/src/tools/esbuild/angular/compilation/parallel-worker.js +0 -90
- package/src/tools/esbuild/angular/compilation-state.d.ts +0 -15
- package/src/tools/esbuild/angular/compilation-state.js +0 -44
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +0 -27
- package/src/tools/esbuild/angular/compiler-plugin.js +0 -433
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +0 -44
- package/src/tools/esbuild/angular/component-stylesheets.js +0 -150
- package/src/tools/esbuild/angular/diagnostics.d.ts +0 -15
- package/src/tools/esbuild/angular/diagnostics.js +0 -69
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +0 -17
- package/src/tools/esbuild/angular/file-reference-tracker.js +0 -57
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +0 -23
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +0 -117
- package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +0 -17
- package/src/tools/esbuild/angular/jit-resource-transformer.js +0 -186
- package/src/tools/esbuild/angular/source-file-cache.d.ts +0 -18
- package/src/tools/esbuild/angular/source-file-cache.js +0 -65
- package/src/tools/esbuild/angular/uri.d.ts +0 -54
- package/src/tools/esbuild/angular/uri.js +0 -74
- package/src/tools/esbuild/angular/web-worker-transformer.d.ts +0 -17
- package/src/tools/esbuild/angular/web-worker-transformer.js +0 -94
- package/src/tools/esbuild/application-code-bundle.d.ts +0 -20
- package/src/tools/esbuild/application-code-bundle.js +0 -368
- package/src/tools/esbuild/budget-stats.d.ts +0 -19
- package/src/tools/esbuild/budget-stats.js +0 -59
- package/src/tools/esbuild/bundler-context.d.ts +0 -75
- package/src/tools/esbuild/bundler-context.js +0 -366
- package/src/tools/esbuild/bundler-execution-result.d.ts +0 -71
- package/src/tools/esbuild/bundler-execution-result.js +0 -131
- package/src/tools/esbuild/cache.d.ts +0 -88
- package/src/tools/esbuild/cache.js +0 -92
- package/src/tools/esbuild/commonjs-checker.d.ts +0 -28
- package/src/tools/esbuild/commonjs-checker.js +0 -151
- package/src/tools/esbuild/compiler-plugin-options.d.ts +0 -16
- package/src/tools/esbuild/compiler-plugin-options.js +0 -49
- package/src/tools/esbuild/external-packages-plugin.d.ts +0 -18
- package/src/tools/esbuild/external-packages-plugin.js +0 -70
- package/src/tools/esbuild/global-scripts.d.ts +0 -16
- package/src/tools/esbuild/global-scripts.js +0 -142
- package/src/tools/esbuild/global-styles.d.ts +0 -10
- package/src/tools/esbuild/global-styles.js +0 -74
- package/src/tools/esbuild/i18n-inliner-worker.d.ts +0 -42
- package/src/tools/esbuild/i18n-inliner-worker.js +0 -136
- package/src/tools/esbuild/i18n-inliner.d.ts +0 -44
- package/src/tools/esbuild/i18n-inliner.js +0 -150
- package/src/tools/esbuild/i18n-locale-plugin.d.ts +0 -22
- package/src/tools/esbuild/i18n-locale-plugin.js +0 -120
- package/src/tools/esbuild/index-html-generator.d.ts +0 -15
- package/src/tools/esbuild/index-html-generator.js +0 -129
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +0 -19
- package/src/tools/esbuild/javascript-transformer-worker.js +0 -154
- package/src/tools/esbuild/javascript-transformer.d.ts +0 -54
- package/src/tools/esbuild/javascript-transformer.js +0 -143
- package/src/tools/esbuild/license-extractor.d.ts +0 -25
- package/src/tools/esbuild/license-extractor.js +0 -158
- package/src/tools/esbuild/load-result-cache.d.ts +0 -21
- package/src/tools/esbuild/load-result-cache.js +0 -75
- package/src/tools/esbuild/profiling.d.ts +0 -11
- package/src/tools/esbuild/profiling.js +0 -78
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +0 -18
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +0 -44
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +0 -17
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +0 -73
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +0 -35
- package/src/tools/esbuild/stylesheets/bundle-options.js +0 -64
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +0 -25
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +0 -57
- package/src/tools/esbuild/stylesheets/css-language.d.ts +0 -9
- package/src/tools/esbuild/stylesheets/css-language.js +0 -15
- package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +0 -18
- package/src/tools/esbuild/stylesheets/css-resource-plugin.js +0 -107
- package/src/tools/esbuild/stylesheets/less-language.d.ts +0 -9
- package/src/tools/esbuild/stylesheets/less-language.js +0 -155
- package/src/tools/esbuild/stylesheets/sass-language.d.ts +0 -10
- package/src/tools/esbuild/stylesheets/sass-language.js +0 -185
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +0 -58
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +0 -282
- package/src/tools/esbuild/utils.d.ts +0 -41
- package/src/tools/esbuild/utils.js +0 -378
- package/src/tools/esbuild/virtual-module-plugin.d.ts +0 -33
- package/src/tools/esbuild/virtual-module-plugin.js +0 -43
- package/src/tools/esbuild/watcher.d.ts +0 -25
- package/src/tools/esbuild/watcher.js +0 -118
- package/src/tools/sass/lexer.d.ts +0 -18
- package/src/tools/sass/lexer.js +0 -161
- package/src/tools/sass/rebasing-importer.d.ts +0 -101
- package/src/tools/sass/rebasing-importer.js +0 -337
- package/src/tools/sass/sass-service.d.ts +0 -49
- package/src/tools/sass/sass-service.js +0 -213
- package/src/tools/sass/worker.d.ts +0 -8
- package/src/tools/sass/worker.js +0 -164
- package/src/tools/vite/angular-memory-plugin.d.ts +0 -24
- package/src/tools/vite/angular-memory-plugin.js +0 -268
- package/src/tools/vite/i18n-locale-plugin.d.ts +0 -18
- package/src/tools/vite/i18n-locale-plugin.js +0 -55
- package/src/typings.d.ts +0 -21
- package/src/utils/bundle-calculator.d.ts +0 -44
- package/src/utils/bundle-calculator.js +0 -302
- package/src/utils/check-port.d.ts +0 -8
- package/src/utils/check-port.js +0 -58
- package/src/utils/delete-output-dir.d.ts +0 -11
- package/src/utils/delete-output-dir.js +0 -46
- package/src/utils/i18n-options.d.ts +0 -40
- package/src/utils/i18n-options.js +0 -254
- package/src/utils/index-file/augment-index-html.d.ts +0 -40
- package/src/utils/index-file/augment-index-html.js +0 -238
- package/src/utils/index-file/html-rewriting-stream.d.ts +0 -11
- package/src/utils/index-file/html-rewriting-stream.js +0 -28
- package/src/utils/index-file/index-html-generator.d.ts +0 -47
- package/src/utils/index-file/index-html-generator.js +0 -119
- package/src/utils/index-file/inline-critical-css.d.ts +0 -24
- package/src/utils/index-file/inline-critical-css.js +0 -179
- package/src/utils/index-file/inline-fonts.d.ts +0 -23
- package/src/utils/index-file/inline-fonts.js +0 -267
- package/src/utils/index-file/style-nonce.d.ts +0 -12
- package/src/utils/index-file/style-nonce.js +0 -53
- package/src/utils/load-proxy-config.d.ts +0 -8
- package/src/utils/load-proxy-config.js +0 -192
- package/src/utils/load-translations.d.ts +0 -16
- package/src/utils/load-translations.js +0 -84
- package/src/utils/postcss-configuration.d.ts +0 -17
- package/src/utils/postcss-configuration.js +0 -86
- package/src/utils/purge-cache.d.ts +0 -10
- package/src/utils/purge-cache.js +0 -40
- package/src/utils/routes-extractor/extractor.d.ts +0 -15
- package/src/utils/routes-extractor/extractor.js +0 -97
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -18
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -129
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +0 -8
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +0 -13
- package/src/utils/server-rendering/fetch-patch.d.ts +0 -8
- package/src/utils/server-rendering/fetch-patch.js +0 -66
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +0 -10
- package/src/utils/server-rendering/load-esm-from-memory.js +0 -26
- package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
- package/src/utils/server-rendering/main-bundle-exports.js +0 -9
- package/src/utils/server-rendering/prerender.d.ts +0 -23
- package/src/utils/server-rendering/prerender.js +0 -192
- package/src/utils/server-rendering/render-page.d.ts +0 -26
- package/src/utils/server-rendering/render-page.js +0 -110
- package/src/utils/server-rendering/render-worker.d.ts +0 -22
- package/src/utils/server-rendering/render-worker.js +0 -30
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +0 -21
- package/src/utils/server-rendering/routes-extractor-worker.js +0 -53
- package/src/utils/service-worker.d.ts +0 -25
- package/src/utils/service-worker.js +0 -211
- package/src/utils/supported-browsers.d.ts +0 -10
- package/src/utils/supported-browsers.js +0 -42
- package/src/utils/version.d.ts +0 -8
- package/src/utils/version.js +0 -59
|
@@ -1,183 +0,0 @@
|
|
|
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
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.runEsBuildBuildAction = void 0;
|
|
37
|
-
const node_fs_1 = require("node:fs");
|
|
38
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
39
|
-
const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
|
|
40
|
-
const utils_1 = require("../../tools/esbuild/utils");
|
|
41
|
-
const delete_output_dir_1 = require("../../utils/delete-output-dir");
|
|
42
|
-
const environment_options_1 = require("../../utils/environment-options");
|
|
43
|
-
// Watch workspace for package manager changes
|
|
44
|
-
const packageWatchFiles = [
|
|
45
|
-
// manifest can affect module resolution
|
|
46
|
-
'package.json',
|
|
47
|
-
// npm lock file
|
|
48
|
-
'package-lock.json',
|
|
49
|
-
// pnpm lock file
|
|
50
|
-
'pnpm-lock.yaml',
|
|
51
|
-
// yarn lock file including Yarn PnP manifest files (https://yarnpkg.com/advanced/pnp-spec/)
|
|
52
|
-
'yarn.lock',
|
|
53
|
-
'.pnp.cjs',
|
|
54
|
-
'.pnp.data.json',
|
|
55
|
-
];
|
|
56
|
-
async function* runEsBuildBuildAction(action, options) {
|
|
57
|
-
const { writeToFileSystemFilter, writeToFileSystem, watch, poll, clearScreen, logger, deleteOutputPath, cacheOptions, outputOptions, verbose, projectRoot, workspaceRoot, progress, preserveSymlinks, colors, jsonLogs, } = options;
|
|
58
|
-
if (deleteOutputPath && writeToFileSystem) {
|
|
59
|
-
await (0, delete_output_dir_1.deleteOutputDir)(workspaceRoot, outputOptions.base, [
|
|
60
|
-
outputOptions.browser,
|
|
61
|
-
outputOptions.server,
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
const withProgress = progress ? utils_1.withSpinner : utils_1.withNoProgress;
|
|
65
|
-
// Initial build
|
|
66
|
-
let result;
|
|
67
|
-
try {
|
|
68
|
-
// Perform the build action
|
|
69
|
-
result = await withProgress('Building...', () => action());
|
|
70
|
-
// Log all diagnostic (error/warning/logs) messages
|
|
71
|
-
await (0, utils_1.logMessages)(logger, result, colors, jsonLogs);
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
// Ensure Sass workers are shutdown if not watching
|
|
75
|
-
if (!watch) {
|
|
76
|
-
(0, sass_language_1.shutdownSassWorkerPool)();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
// Setup watcher if watch mode enabled
|
|
80
|
-
let watcher;
|
|
81
|
-
if (watch) {
|
|
82
|
-
if (progress) {
|
|
83
|
-
logger.info('Watch mode enabled. Watching for file changes...');
|
|
84
|
-
}
|
|
85
|
-
const ignored = [
|
|
86
|
-
// Ignore the output and cache paths to avoid infinite rebuild cycles
|
|
87
|
-
outputOptions.base,
|
|
88
|
-
cacheOptions.basePath,
|
|
89
|
-
`${workspaceRoot.replace(/\\/g, '/')}/**/.*/**`,
|
|
90
|
-
];
|
|
91
|
-
if (!preserveSymlinks) {
|
|
92
|
-
// Ignore all node modules directories to avoid excessive file watchers.
|
|
93
|
-
// Package changes are handled below by watching manifest and lock files.
|
|
94
|
-
// NOTE: this is not enable when preserveSymlinks is true as this would break `npm link` usages.
|
|
95
|
-
ignored.push('**/node_modules/**');
|
|
96
|
-
}
|
|
97
|
-
// Setup a watcher
|
|
98
|
-
const { createWatcher } = await Promise.resolve().then(() => __importStar(require('../../tools/esbuild/watcher')));
|
|
99
|
-
watcher = createWatcher({
|
|
100
|
-
polling: typeof poll === 'number',
|
|
101
|
-
interval: poll,
|
|
102
|
-
followSymlinks: preserveSymlinks,
|
|
103
|
-
ignored,
|
|
104
|
-
});
|
|
105
|
-
// Setup abort support
|
|
106
|
-
options.signal?.addEventListener('abort', () => void watcher?.close());
|
|
107
|
-
// Watch the entire project root if 'NG_BUILD_WATCH_ROOT' environment variable is set
|
|
108
|
-
if (environment_options_1.shouldWatchRoot) {
|
|
109
|
-
watcher.add(projectRoot);
|
|
110
|
-
}
|
|
111
|
-
watcher.add(packageWatchFiles
|
|
112
|
-
.map((file) => node_path_1.default.join(workspaceRoot, file))
|
|
113
|
-
.filter((file) => (0, node_fs_1.existsSync)(file)));
|
|
114
|
-
// Watch locations provided by the initial build result
|
|
115
|
-
watcher.add(result.watchFiles);
|
|
116
|
-
}
|
|
117
|
-
// Output the first build results after setting up the watcher to ensure that any code executed
|
|
118
|
-
// higher in the iterator call stack will trigger the watcher. This is particularly relevant for
|
|
119
|
-
// unit tests which execute the builder and modify the file system programmatically.
|
|
120
|
-
yield await writeAndEmitOutput(writeToFileSystem, result, outputOptions, writeToFileSystemFilter);
|
|
121
|
-
// Finish if watch mode is not enabled
|
|
122
|
-
if (!watcher) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
// Wait for changes and rebuild as needed
|
|
126
|
-
const currentWatchFiles = new Set(result.watchFiles);
|
|
127
|
-
try {
|
|
128
|
-
for await (const changes of watcher) {
|
|
129
|
-
if (options.signal?.aborted) {
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
if (clearScreen) {
|
|
133
|
-
// eslint-disable-next-line no-console
|
|
134
|
-
console.clear();
|
|
135
|
-
}
|
|
136
|
-
if (verbose) {
|
|
137
|
-
logger.info(changes.toDebugString());
|
|
138
|
-
}
|
|
139
|
-
result = await withProgress('Changes detected. Rebuilding...', () => action(result.createRebuildState(changes)));
|
|
140
|
-
// Log all diagnostic (error/warning/logs) messages
|
|
141
|
-
await (0, utils_1.logMessages)(logger, result, colors, jsonLogs);
|
|
142
|
-
// Update watched locations provided by the new build result.
|
|
143
|
-
// Keep watching all previous files if there are any errors; otherwise consider all
|
|
144
|
-
// files stale until confirmed present in the new result's watch files.
|
|
145
|
-
const staleWatchFiles = result.errors.length > 0 ? undefined : new Set(currentWatchFiles);
|
|
146
|
-
for (const watchFile of result.watchFiles) {
|
|
147
|
-
if (!currentWatchFiles.has(watchFile)) {
|
|
148
|
-
// Add new watch location
|
|
149
|
-
watcher.add(watchFile);
|
|
150
|
-
currentWatchFiles.add(watchFile);
|
|
151
|
-
}
|
|
152
|
-
// Present so remove from stale locations
|
|
153
|
-
staleWatchFiles?.delete(watchFile);
|
|
154
|
-
}
|
|
155
|
-
// Remove any stale locations if the build was successful
|
|
156
|
-
if (staleWatchFiles?.size) {
|
|
157
|
-
watcher.remove([...staleWatchFiles]);
|
|
158
|
-
}
|
|
159
|
-
yield await writeAndEmitOutput(writeToFileSystem, result, outputOptions, writeToFileSystemFilter);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
finally {
|
|
163
|
-
// Stop the watcher and cleanup incremental rebuild state
|
|
164
|
-
await Promise.allSettled([watcher.close(), result.dispose()]);
|
|
165
|
-
(0, sass_language_1.shutdownSassWorkerPool)();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.runEsBuildBuildAction = runEsBuildBuildAction;
|
|
169
|
-
async function writeAndEmitOutput(writeToFileSystem, { outputFiles, output, outputWithFiles, assetFiles }, outputOptions, writeToFileSystemFilter) {
|
|
170
|
-
if (writeToFileSystem) {
|
|
171
|
-
// Write output files
|
|
172
|
-
const outputFilesToWrite = writeToFileSystemFilter
|
|
173
|
-
? outputFiles.filter(writeToFileSystemFilter)
|
|
174
|
-
: outputFiles;
|
|
175
|
-
await (0, utils_1.writeResultFiles)(outputFilesToWrite, assetFiles, outputOptions);
|
|
176
|
-
return output;
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
// Requires casting due to unneeded `JsonObject` requirement. Remove once fixed.
|
|
180
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
|
-
return outputWithFiles;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
-
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
|
10
|
-
import { NormalizedApplicationBuildOptions } from './options';
|
|
11
|
-
export declare function executeBuild(options: NormalizedApplicationBuildOptions, context: BuilderContext, rebuildState?: RebuildState): Promise<ExecutionResult>;
|
|
@@ -1,127 +0,0 @@
|
|
|
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
|
-
exports.executeBuild = void 0;
|
|
11
|
-
const source_file_cache_1 = require("../../tools/esbuild/angular/source-file-cache");
|
|
12
|
-
const budget_stats_1 = require("../../tools/esbuild/budget-stats");
|
|
13
|
-
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
14
|
-
const bundler_execution_result_1 = require("../../tools/esbuild/bundler-execution-result");
|
|
15
|
-
const commonjs_checker_1 = require("../../tools/esbuild/commonjs-checker");
|
|
16
|
-
const license_extractor_1 = require("../../tools/esbuild/license-extractor");
|
|
17
|
-
const utils_1 = require("../../tools/esbuild/utils");
|
|
18
|
-
const bundle_calculator_1 = require("../../utils/bundle-calculator");
|
|
19
|
-
const copy_assets_1 = require("../../utils/copy-assets");
|
|
20
|
-
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
21
|
-
const execute_post_bundle_1 = require("./execute-post-bundle");
|
|
22
|
-
const i18n_1 = require("./i18n");
|
|
23
|
-
const setup_bundling_1 = require("./setup-bundling");
|
|
24
|
-
async function executeBuild(options, context, rebuildState) {
|
|
25
|
-
const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets, cacheOptions, prerenderOptions, ssrOptions, verbose, colors, jsonLogs, } = options;
|
|
26
|
-
// TODO: Consider integrating into watch mode. Would require full rebuild on target changes.
|
|
27
|
-
const browsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, context.logger);
|
|
28
|
-
// Load active translations if inlining
|
|
29
|
-
// TODO: Integrate into watch mode and only load changed translations
|
|
30
|
-
if (i18nOptions.shouldInline) {
|
|
31
|
-
await (0, i18n_1.loadActiveTranslations)(context, i18nOptions);
|
|
32
|
-
}
|
|
33
|
-
// Reuse rebuild state or create new bundle contexts for code and global stylesheets
|
|
34
|
-
let bundlerContexts = rebuildState?.rebuildContexts;
|
|
35
|
-
const codeBundleCache = rebuildState?.codeBundleCache ??
|
|
36
|
-
new source_file_cache_1.SourceFileCache(cacheOptions.enabled ? cacheOptions.path : undefined);
|
|
37
|
-
if (bundlerContexts === undefined) {
|
|
38
|
-
bundlerContexts = (0, setup_bundling_1.setupBundlerContexts)(options, browsers, codeBundleCache);
|
|
39
|
-
}
|
|
40
|
-
const bundlingResult = await bundler_context_1.BundlerContext.bundleAll(bundlerContexts, rebuildState?.fileChanges.all);
|
|
41
|
-
const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, codeBundleCache);
|
|
42
|
-
executionResult.addWarnings(bundlingResult.warnings);
|
|
43
|
-
// Return if the bundling has errors
|
|
44
|
-
if (bundlingResult.errors) {
|
|
45
|
-
executionResult.addErrors(bundlingResult.errors);
|
|
46
|
-
return executionResult;
|
|
47
|
-
}
|
|
48
|
-
// Analyze external imports if external options are enabled
|
|
49
|
-
if (options.externalPackages || bundlingResult.externalConfiguration) {
|
|
50
|
-
const { externalConfiguration, externalImports: { browser, server }, } = bundlingResult;
|
|
51
|
-
const implicitBrowser = browser ? [...browser] : [];
|
|
52
|
-
const implicitServer = server ? [...server] : [];
|
|
53
|
-
// TODO: Implement wildcard externalConfiguration filtering
|
|
54
|
-
executionResult.setExternalMetadata(externalConfiguration
|
|
55
|
-
? implicitBrowser.filter((value) => !externalConfiguration.includes(value))
|
|
56
|
-
: implicitBrowser, externalConfiguration
|
|
57
|
-
? implicitServer.filter((value) => !externalConfiguration.includes(value))
|
|
58
|
-
: implicitServer, externalConfiguration);
|
|
59
|
-
}
|
|
60
|
-
const { metafile, initialFiles, outputFiles } = bundlingResult;
|
|
61
|
-
executionResult.outputFiles.push(...outputFiles);
|
|
62
|
-
const changedFiles = rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputHashes);
|
|
63
|
-
// Analyze files for bundle budget failures if present
|
|
64
|
-
let budgetFailures;
|
|
65
|
-
if (options.budgets) {
|
|
66
|
-
const compatStats = (0, budget_stats_1.generateBudgetStats)(metafile, initialFiles);
|
|
67
|
-
budgetFailures = [...(0, bundle_calculator_1.checkBudgets)(options.budgets, compatStats, true)];
|
|
68
|
-
for (const { message, severity } of budgetFailures) {
|
|
69
|
-
if (severity === 'error') {
|
|
70
|
-
executionResult.addError(message);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
executionResult.addWarning(message);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Calculate estimated transfer size if scripts are optimized
|
|
78
|
-
let estimatedTransferSizes;
|
|
79
|
-
if (optimizationOptions.scripts || optimizationOptions.styles.minify) {
|
|
80
|
-
estimatedTransferSizes = await (0, utils_1.calculateEstimatedTransferSizes)(executionResult.outputFiles);
|
|
81
|
-
}
|
|
82
|
-
// Check metafile for CommonJS module usage if optimizing scripts
|
|
83
|
-
if (optimizationOptions.scripts) {
|
|
84
|
-
const messages = (0, commonjs_checker_1.checkCommonJSModules)(metafile, options.allowedCommonJsDependencies);
|
|
85
|
-
executionResult.addWarnings(messages);
|
|
86
|
-
}
|
|
87
|
-
// Copy assets
|
|
88
|
-
if (assets) {
|
|
89
|
-
// The webpack copy assets helper is used with no base paths defined. This prevents the helper
|
|
90
|
-
// from directly writing to disk. This should eventually be replaced with a more optimized helper.
|
|
91
|
-
executionResult.addAssets(await (0, copy_assets_1.copyAssets)(assets, [], workspaceRoot));
|
|
92
|
-
}
|
|
93
|
-
// Extract and write licenses for used packages
|
|
94
|
-
if (options.extractLicenses) {
|
|
95
|
-
executionResult.addOutputFile('3rdpartylicenses.txt', await (0, license_extractor_1.extractLicenses)(metafile, workspaceRoot), bundler_context_1.BuildOutputFileType.Root);
|
|
96
|
-
}
|
|
97
|
-
// Perform i18n translation inlining if enabled
|
|
98
|
-
if (i18nOptions.shouldInline) {
|
|
99
|
-
const result = await (0, i18n_1.inlineI18n)(options, executionResult, initialFiles);
|
|
100
|
-
executionResult.addErrors(result.errors);
|
|
101
|
-
executionResult.addWarnings(result.warnings);
|
|
102
|
-
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
|
|
106
|
-
// Set lang attribute to the defined source locale if present
|
|
107
|
-
i18nOptions.hasDefinedSourceLocale ? i18nOptions.sourceLocale : undefined);
|
|
108
|
-
executionResult.addErrors(result.errors);
|
|
109
|
-
executionResult.addWarnings(result.warnings);
|
|
110
|
-
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
|
111
|
-
executionResult.outputFiles.push(...result.additionalOutputFiles);
|
|
112
|
-
executionResult.assetFiles.push(...result.additionalAssets);
|
|
113
|
-
}
|
|
114
|
-
if (prerenderOptions) {
|
|
115
|
-
const prerenderedRoutes = executionResult.prerenderedRoutes;
|
|
116
|
-
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: prerenderedRoutes }, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
117
|
-
}
|
|
118
|
-
// Write metafile if stats option is enabled
|
|
119
|
-
if (options.stats) {
|
|
120
|
-
executionResult.addOutputFile('stats.json', JSON.stringify(metafile, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
121
|
-
}
|
|
122
|
-
if (!jsonLogs) {
|
|
123
|
-
executionResult.addLog((0, utils_1.logBuildStats)(metafile, initialFiles, budgetFailures, colors, changedFiles, estimatedTransferSizes, !!ssrOptions, verbose));
|
|
124
|
-
}
|
|
125
|
-
return executionResult;
|
|
126
|
-
}
|
|
127
|
-
exports.executeBuild = executeBuild;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { BuildOutputFile, InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
|
9
|
-
import { BuildOutputAsset } from '../../tools/esbuild/bundler-execution-result';
|
|
10
|
-
import { NormalizedApplicationBuildOptions } from './options';
|
|
11
|
-
/**
|
|
12
|
-
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
|
13
|
-
* @param options The normalized application builder options used to create the build.
|
|
14
|
-
* @param outputFiles The output files of an executed build.
|
|
15
|
-
* @param assetFiles The assets of an executed build.
|
|
16
|
-
* @param initialFiles A map containing initial file information for the executed build.
|
|
17
|
-
* @param locale A language locale to insert in the index.html.
|
|
18
|
-
*/
|
|
19
|
-
export declare function executePostBundleSteps(options: NormalizedApplicationBuildOptions, outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[], initialFiles: Map<string, InitialFileRecord>, locale: string | undefined): Promise<{
|
|
20
|
-
errors: string[];
|
|
21
|
-
warnings: string[];
|
|
22
|
-
additionalOutputFiles: BuildOutputFile[];
|
|
23
|
-
additionalAssets: BuildOutputAsset[];
|
|
24
|
-
prerenderedRoutes: string[];
|
|
25
|
-
}>;
|
|
@@ -1,96 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.executePostBundleSteps = void 0;
|
|
14
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
|
-
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
16
|
-
const index_html_generator_1 = require("../../tools/esbuild/index-html-generator");
|
|
17
|
-
const utils_1 = require("../../tools/esbuild/utils");
|
|
18
|
-
const environment_options_1 = require("../../utils/environment-options");
|
|
19
|
-
const prerender_1 = require("../../utils/server-rendering/prerender");
|
|
20
|
-
const service_worker_1 = require("../../utils/service-worker");
|
|
21
|
-
/**
|
|
22
|
-
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
|
23
|
-
* @param options The normalized application builder options used to create the build.
|
|
24
|
-
* @param outputFiles The output files of an executed build.
|
|
25
|
-
* @param assetFiles The assets of an executed build.
|
|
26
|
-
* @param initialFiles A map containing initial file information for the executed build.
|
|
27
|
-
* @param locale A language locale to insert in the index.html.
|
|
28
|
-
*/
|
|
29
|
-
async function executePostBundleSteps(options, outputFiles, assetFiles, initialFiles, locale) {
|
|
30
|
-
const additionalAssets = [];
|
|
31
|
-
const additionalOutputFiles = [];
|
|
32
|
-
const allErrors = [];
|
|
33
|
-
const allWarnings = [];
|
|
34
|
-
const prerenderedRoutes = [];
|
|
35
|
-
const { serviceWorker, indexHtmlOptions, optimizationOptions, sourcemapOptions, ssrOptions, prerenderOptions, appShellOptions, workspaceRoot, verbose, } = options;
|
|
36
|
-
/**
|
|
37
|
-
* Index HTML content without CSS inlining to be used for server rendering (AppShell, SSG and SSR).
|
|
38
|
-
*
|
|
39
|
-
* NOTE: we don't perform critical CSS inlining as this will be done during server rendering.
|
|
40
|
-
*/
|
|
41
|
-
let indexContentOutputNoCssInlining;
|
|
42
|
-
// When using prerender/app-shell the index HTML file can be regenerated.
|
|
43
|
-
// Thus, we use a Map so that we do not generate 2 files with the same filename.
|
|
44
|
-
const additionalHtmlOutputFiles = new Map();
|
|
45
|
-
// Generate index HTML file
|
|
46
|
-
// If localization is enabled, index generation is handled in the inlining process.
|
|
47
|
-
if (indexHtmlOptions) {
|
|
48
|
-
const { content, contentWithoutCriticalCssInlined, errors, warnings } = await (0, index_html_generator_1.generateIndexHtml)(initialFiles, outputFiles, {
|
|
49
|
-
...options,
|
|
50
|
-
optimizationOptions,
|
|
51
|
-
}, locale);
|
|
52
|
-
indexContentOutputNoCssInlining = contentWithoutCriticalCssInlined;
|
|
53
|
-
allErrors.push(...errors);
|
|
54
|
-
allWarnings.push(...warnings);
|
|
55
|
-
additionalHtmlOutputFiles.set(indexHtmlOptions.output, (0, utils_1.createOutputFileFromText)(indexHtmlOptions.output, content, bundler_context_1.BuildOutputFileType.Browser));
|
|
56
|
-
if (ssrOptions) {
|
|
57
|
-
const serverIndexHtmlFilename = 'index.server.html';
|
|
58
|
-
additionalHtmlOutputFiles.set(serverIndexHtmlFilename, (0, utils_1.createOutputFileFromText)(serverIndexHtmlFilename, contentWithoutCriticalCssInlined, bundler_context_1.BuildOutputFileType.Server));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Pre-render (SSG) and App-shell
|
|
62
|
-
// If localization is enabled, prerendering is handled in the inlining process.
|
|
63
|
-
if (prerenderOptions || appShellOptions) {
|
|
64
|
-
(0, node_assert_1.default)(indexContentOutputNoCssInlining, 'The "index" option is required when using the "ssg" or "appShell" options.');
|
|
65
|
-
const { output, warnings, errors, prerenderedRoutes: generatedRoutes, } = await (0, prerender_1.prerenderPages)(workspaceRoot, appShellOptions, prerenderOptions, outputFiles, assetFiles, indexContentOutputNoCssInlining, sourcemapOptions.scripts, optimizationOptions.styles.inlineCritical, environment_options_1.maxWorkers, verbose);
|
|
66
|
-
allErrors.push(...errors);
|
|
67
|
-
allWarnings.push(...warnings);
|
|
68
|
-
prerenderedRoutes.push(...Array.from(generatedRoutes));
|
|
69
|
-
for (const [path, content] of Object.entries(output)) {
|
|
70
|
-
additionalHtmlOutputFiles.set(path, (0, utils_1.createOutputFileFromText)(path, content, bundler_context_1.BuildOutputFileType.Browser));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
additionalOutputFiles.push(...additionalHtmlOutputFiles.values());
|
|
74
|
-
// Augment the application with service worker support
|
|
75
|
-
// If localization is enabled, service worker is handled in the inlining process.
|
|
76
|
-
if (serviceWorker) {
|
|
77
|
-
try {
|
|
78
|
-
const serviceWorkerResult = await (0, service_worker_1.augmentAppWithServiceWorkerEsbuild)(workspaceRoot, serviceWorker, options.baseHref || '/', options.indexHtmlOptions?.output,
|
|
79
|
-
// Ensure additional files recently added are used
|
|
80
|
-
[...outputFiles, ...additionalOutputFiles], assetFiles);
|
|
81
|
-
additionalOutputFiles.push((0, utils_1.createOutputFileFromText)('ngsw.json', serviceWorkerResult.manifest, bundler_context_1.BuildOutputFileType.Browser));
|
|
82
|
-
additionalAssets.push(...serviceWorkerResult.assetFiles);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
allErrors.push(error instanceof Error ? error.message : `${error}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
errors: allErrors,
|
|
90
|
-
warnings: allWarnings,
|
|
91
|
-
additionalAssets,
|
|
92
|
-
prerenderedRoutes,
|
|
93
|
-
additionalOutputFiles,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
exports.executePostBundleSteps = executePostBundleSteps;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
-
import { InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
|
10
|
-
import { ExecutionResult } from '../../tools/esbuild/bundler-execution-result';
|
|
11
|
-
import { NormalizedApplicationBuildOptions } from './options';
|
|
12
|
-
/**
|
|
13
|
-
* Inlines all active locales as specified by the application build options into all
|
|
14
|
-
* application JavaScript files created during the build.
|
|
15
|
-
* @param options The normalized application builder options used to create the build.
|
|
16
|
-
* @param executionResult The result of an executed build.
|
|
17
|
-
* @param initialFiles A map containing initial file information for the executed build.
|
|
18
|
-
*/
|
|
19
|
-
export declare function inlineI18n(options: NormalizedApplicationBuildOptions, executionResult: ExecutionResult, initialFiles: Map<string, InitialFileRecord>): Promise<{
|
|
20
|
-
errors: string[];
|
|
21
|
-
warnings: string[];
|
|
22
|
-
prerenderedRoutes: string[];
|
|
23
|
-
}>;
|
|
24
|
-
/**
|
|
25
|
-
* Loads all active translations using the translation loaders from the `@angular/localize` package.
|
|
26
|
-
* @param context The architect builder context for the current build.
|
|
27
|
-
* @param i18n The normalized i18n options to use.
|
|
28
|
-
*/
|
|
29
|
-
export declare function loadActiveTranslations(context: BuilderContext, i18n: NormalizedApplicationBuildOptions['i18nOptions']): Promise<void>;
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
exports.loadActiveTranslations = exports.inlineI18n = void 0;
|
|
11
|
-
const node_path_1 = require("node:path");
|
|
12
|
-
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
13
|
-
const i18n_inliner_1 = require("../../tools/esbuild/i18n-inliner");
|
|
14
|
-
const environment_options_1 = require("../../utils/environment-options");
|
|
15
|
-
const i18n_options_1 = require("../../utils/i18n-options");
|
|
16
|
-
const load_translations_1 = require("../../utils/load-translations");
|
|
17
|
-
const url_1 = require("../../utils/url");
|
|
18
|
-
const execute_post_bundle_1 = require("./execute-post-bundle");
|
|
19
|
-
/**
|
|
20
|
-
* Inlines all active locales as specified by the application build options into all
|
|
21
|
-
* application JavaScript files created during the build.
|
|
22
|
-
* @param options The normalized application builder options used to create the build.
|
|
23
|
-
* @param executionResult The result of an executed build.
|
|
24
|
-
* @param initialFiles A map containing initial file information for the executed build.
|
|
25
|
-
*/
|
|
26
|
-
async function inlineI18n(options, executionResult, initialFiles) {
|
|
27
|
-
// Create the multi-threaded inliner with common options and the files generated from the build.
|
|
28
|
-
const inliner = new i18n_inliner_1.I18nInliner({
|
|
29
|
-
missingTranslation: options.i18nOptions.missingTranslationBehavior ?? 'warning',
|
|
30
|
-
outputFiles: executionResult.outputFiles,
|
|
31
|
-
shouldOptimize: options.optimizationOptions.scripts,
|
|
32
|
-
}, environment_options_1.maxWorkers);
|
|
33
|
-
const inlineResult = {
|
|
34
|
-
errors: [],
|
|
35
|
-
warnings: [],
|
|
36
|
-
prerenderedRoutes: [],
|
|
37
|
-
};
|
|
38
|
-
// For each active locale, use the inliner to process the output files of the build.
|
|
39
|
-
const updatedOutputFiles = [];
|
|
40
|
-
const updatedAssetFiles = [];
|
|
41
|
-
try {
|
|
42
|
-
for (const locale of options.i18nOptions.inlineLocales) {
|
|
43
|
-
// A locale specific set of files is returned from the inliner.
|
|
44
|
-
const localeInlineResult = await inliner.inlineForLocale(locale, options.i18nOptions.locales[locale].translation);
|
|
45
|
-
const localeOutputFiles = localeInlineResult.outputFiles;
|
|
46
|
-
inlineResult.errors.push(...localeInlineResult.errors);
|
|
47
|
-
inlineResult.warnings.push(...localeInlineResult.warnings);
|
|
48
|
-
const baseHref = getLocaleBaseHref(options.baseHref, options.i18nOptions, locale) ?? options.baseHref;
|
|
49
|
-
const { errors, warnings, additionalAssets, additionalOutputFiles, prerenderedRoutes: generatedRoutes, } = await (0, execute_post_bundle_1.executePostBundleSteps)({
|
|
50
|
-
...options,
|
|
51
|
-
baseHref,
|
|
52
|
-
}, localeOutputFiles, executionResult.assetFiles, initialFiles, locale);
|
|
53
|
-
localeOutputFiles.push(...additionalOutputFiles);
|
|
54
|
-
inlineResult.errors.push(...errors);
|
|
55
|
-
inlineResult.warnings.push(...warnings);
|
|
56
|
-
// Update directory with locale base
|
|
57
|
-
if (options.i18nOptions.flatOutput !== true) {
|
|
58
|
-
localeOutputFiles.forEach((file) => {
|
|
59
|
-
file.path = (0, node_path_1.join)(locale, file.path);
|
|
60
|
-
});
|
|
61
|
-
for (const assetFile of [...executionResult.assetFiles, ...additionalAssets]) {
|
|
62
|
-
updatedAssetFiles.push({
|
|
63
|
-
source: assetFile.source,
|
|
64
|
-
destination: (0, node_path_1.join)(locale, assetFile.destination),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
inlineResult.prerenderedRoutes.push(...generatedRoutes.map((route) => node_path_1.posix.join('/', locale, route)));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
inlineResult.prerenderedRoutes.push(...generatedRoutes);
|
|
71
|
-
executionResult.assetFiles.push(...additionalAssets);
|
|
72
|
-
}
|
|
73
|
-
updatedOutputFiles.push(...localeOutputFiles);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
await inliner.close();
|
|
78
|
-
}
|
|
79
|
-
// Update the result with all localized files.
|
|
80
|
-
executionResult.outputFiles = [
|
|
81
|
-
// Root files are not modified.
|
|
82
|
-
...executionResult.outputFiles.filter(({ type }) => type === bundler_context_1.BuildOutputFileType.Root),
|
|
83
|
-
// Updated files for each locale.
|
|
84
|
-
...updatedOutputFiles,
|
|
85
|
-
];
|
|
86
|
-
// Assets are only changed if not using the flat output option
|
|
87
|
-
if (options.i18nOptions.flatOutput !== true) {
|
|
88
|
-
executionResult.assetFiles = updatedAssetFiles;
|
|
89
|
-
}
|
|
90
|
-
return inlineResult;
|
|
91
|
-
}
|
|
92
|
-
exports.inlineI18n = inlineI18n;
|
|
93
|
-
function getLocaleBaseHref(baseHref, i18n, locale) {
|
|
94
|
-
if (i18n.flatOutput) {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
if (i18n.locales[locale] && i18n.locales[locale].baseHref !== '') {
|
|
98
|
-
return (0, url_1.urlJoin)(baseHref || '', i18n.locales[locale].baseHref ?? `/${locale}/`);
|
|
99
|
-
}
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Loads all active translations using the translation loaders from the `@angular/localize` package.
|
|
104
|
-
* @param context The architect builder context for the current build.
|
|
105
|
-
* @param i18n The normalized i18n options to use.
|
|
106
|
-
*/
|
|
107
|
-
async function loadActiveTranslations(context, i18n) {
|
|
108
|
-
// Load locale data and translations (if present)
|
|
109
|
-
let loader;
|
|
110
|
-
for (const [locale, desc] of Object.entries(i18n.locales)) {
|
|
111
|
-
if (!i18n.inlineLocales.has(locale) && locale !== i18n.sourceLocale) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (!desc.files.length) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
loader ??= await (0, load_translations_1.createTranslationLoader)();
|
|
118
|
-
(0, i18n_options_1.loadTranslations)(locale, desc, context.workspaceRoot, loader, {
|
|
119
|
-
warn(message) {
|
|
120
|
-
context.logger.warn(message);
|
|
121
|
-
},
|
|
122
|
-
error(message) {
|
|
123
|
-
throw new Error(message);
|
|
124
|
-
},
|
|
125
|
-
}, undefined, i18n.duplicateTranslationBehavior);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.loadActiveTranslations = loadActiveTranslations;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
9
|
-
import type { Plugin } from 'esbuild';
|
|
10
|
-
import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
|
|
11
|
-
import { ApplicationBuilderExtensions, ApplicationBuilderInternalOptions } from './options';
|
|
12
|
-
import { Schema as ApplicationBuilderOptions } from './schema';
|
|
13
|
-
export { ApplicationBuilderOptions };
|
|
14
|
-
export declare function buildApplicationInternal(options: ApplicationBuilderInternalOptions, context: BuilderContext & {
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
}, infrastructureSettings?: {
|
|
17
|
-
write?: boolean;
|
|
18
|
-
}, extensions?: ApplicationBuilderExtensions): AsyncIterable<ApplicationBuilderOutput>;
|
|
19
|
-
export interface ApplicationBuilderOutput extends BuilderOutput {
|
|
20
|
-
outputFiles?: BuildOutputFile[];
|
|
21
|
-
assetFiles?: {
|
|
22
|
-
source: string;
|
|
23
|
-
destination: string;
|
|
24
|
-
}[];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Builds an application using the `application` builder with the provided
|
|
28
|
-
* options.
|
|
29
|
-
*
|
|
30
|
-
* Usage of the `plugins` parameter is NOT supported and may cause unexpected
|
|
31
|
-
* build output or build failures.
|
|
32
|
-
*
|
|
33
|
-
* @experimental Direct usage of this function is considered experimental.
|
|
34
|
-
*
|
|
35
|
-
* @param options The options defined by the builder's schema to use.
|
|
36
|
-
* @param context An Architect builder context instance.
|
|
37
|
-
* @param plugins An array of plugins to apply to the main code bundling.
|
|
38
|
-
* @returns The build output results of the build.
|
|
39
|
-
*/
|
|
40
|
-
export declare function buildApplication(options: ApplicationBuilderOptions, context: BuilderContext, plugins?: Plugin[]): AsyncIterable<ApplicationBuilderOutput>;
|
|
41
|
-
/**
|
|
42
|
-
* Builds an application using the `application` builder with the provided
|
|
43
|
-
* options.
|
|
44
|
-
*
|
|
45
|
-
* Usage of the `extensions` parameter is NOT supported and may cause unexpected
|
|
46
|
-
* build output or build failures.
|
|
47
|
-
*
|
|
48
|
-
* @experimental Direct usage of this function is considered experimental.
|
|
49
|
-
*
|
|
50
|
-
* @param options The options defined by the builder's schema to use.
|
|
51
|
-
* @param context An Architect builder context instance.
|
|
52
|
-
* @param extensions An object contain extension points for the build.
|
|
53
|
-
* @returns The build output results of the build.
|
|
54
|
-
*/
|
|
55
|
-
export declare function buildApplication(options: ApplicationBuilderOptions, context: BuilderContext, extensions?: ApplicationBuilderExtensions): AsyncIterable<ApplicationBuilderOutput>;
|
|
56
|
-
declare const _default: import("../../../../architect/src/internal").Builder<ApplicationBuilderOptions & import("../../../../core/src").JsonObject>;
|
|
57
|
-
export default _default;
|