@angular/build 18.0.0-next.3
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/LICENSE +21 -0
- package/README.md +5 -0
- package/builders.json +14 -0
- package/package.json +87 -0
- package/src/builders/application/build-action.d.ts +33 -0
- package/src/builders/application/build-action.js +183 -0
- package/src/builders/application/execute-build.d.ts +11 -0
- package/src/builders/application/execute-build.js +125 -0
- package/src/builders/application/execute-post-bundle.d.ts +25 -0
- package/src/builders/application/execute-post-bundle.js +93 -0
- package/src/builders/application/i18n.d.ts +29 -0
- package/src/builders/application/i18n.js +128 -0
- package/src/builders/application/index.d.ts +57 -0
- package/src/builders/application/index.js +121 -0
- package/src/builders/application/options.d.ts +149 -0
- package/src/builders/application/options.js +369 -0
- package/src/builders/application/schema.d.ts +512 -0
- package/src/builders/application/schema.js +58 -0
- package/src/builders/application/schema.json +635 -0
- package/src/builders/application/setup-bundling.d.ts +19 -0
- package/src/builders/application/setup-bundling.js +71 -0
- package/src/builders/dev-server/builder.d.ts +32 -0
- package/src/builders/dev-server/builder.js +70 -0
- package/src/builders/dev-server/index.d.ts +14 -0
- package/src/builders/dev-server/index.js +15 -0
- package/src/builders/dev-server/internal.d.ts +19 -0
- package/src/builders/dev-server/internal.js +29 -0
- package/src/builders/dev-server/options.d.ts +47 -0
- package/src/builders/dev-server/options.js +65 -0
- package/src/builders/dev-server/output.d.ts +16 -0
- package/src/builders/dev-server/output.js +9 -0
- package/src/builders/dev-server/schema.d.ts +118 -0
- package/src/builders/dev-server/schema.js +4 -0
- package/src/builders/dev-server/schema.json +131 -0
- package/src/builders/dev-server/vite-server.d.ts +31 -0
- package/src/builders/dev-server/vite-server.js +504 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +16 -0
- package/src/private.d.ts +35 -0
- package/src/private.js +70 -0
- package/src/tools/babel/plugins/adjust-static-class-members.d.ts +26 -0
- package/src/tools/babel/plugins/adjust-static-class-members.js +351 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +22 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.js +113 -0
- package/src/tools/babel/plugins/elide-angular-metadata.d.ts +22 -0
- package/src/tools/babel/plugins/elide-angular-metadata.js +110 -0
- package/src/tools/babel/plugins/index.d.ts +11 -0
- package/src/tools/babel/plugins/index.js +21 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +15 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.js +90 -0
- package/src/tools/babel/typings.d.ts +21 -0
- package/src/tools/esbuild/angular/angular-host.d.ts +26 -0
- package/src/tools/esbuild/angular/angular-host.js +134 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.js +94 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.js +224 -0
- package/src/tools/esbuild/angular/compilation/factory.d.ts +16 -0
- package/src/tools/esbuild/angular/compilation/factory.js +56 -0
- package/src/tools/esbuild/angular/compilation/index.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/index.js +17 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +182 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.js +106 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +20 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.js +26 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +123 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +33 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.js +90 -0
- package/src/tools/esbuild/angular/compilation-state.d.ts +15 -0
- package/src/tools/esbuild/angular/compilation-state.js +44 -0
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +27 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +441 -0
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +44 -0
- package/src/tools/esbuild/angular/component-stylesheets.js +150 -0
- package/src/tools/esbuild/angular/diagnostics.d.ts +15 -0
- package/src/tools/esbuild/angular/diagnostics.js +69 -0
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +17 -0
- package/src/tools/esbuild/angular/file-reference-tracker.js +57 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +23 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +117 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.js +186 -0
- package/src/tools/esbuild/angular/source-file-cache.d.ts +18 -0
- package/src/tools/esbuild/angular/source-file-cache.js +65 -0
- package/src/tools/esbuild/angular/uri.d.ts +54 -0
- package/src/tools/esbuild/angular/uri.js +74 -0
- package/src/tools/esbuild/angular/web-worker-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/web-worker-transformer.js +94 -0
- package/src/tools/esbuild/application-code-bundle.d.ts +20 -0
- package/src/tools/esbuild/application-code-bundle.js +368 -0
- package/src/tools/esbuild/budget-stats.d.ts +19 -0
- package/src/tools/esbuild/budget-stats.js +59 -0
- package/src/tools/esbuild/bundler-context.d.ts +75 -0
- package/src/tools/esbuild/bundler-context.js +366 -0
- package/src/tools/esbuild/bundler-execution-result.d.ts +71 -0
- package/src/tools/esbuild/bundler-execution-result.js +131 -0
- package/src/tools/esbuild/cache.d.ts +88 -0
- package/src/tools/esbuild/cache.js +92 -0
- package/src/tools/esbuild/commonjs-checker.d.ts +28 -0
- package/src/tools/esbuild/commonjs-checker.js +151 -0
- package/src/tools/esbuild/compiler-plugin-options.d.ts +16 -0
- package/src/tools/esbuild/compiler-plugin-options.js +49 -0
- package/src/tools/esbuild/external-packages-plugin.d.ts +18 -0
- package/src/tools/esbuild/external-packages-plugin.js +70 -0
- package/src/tools/esbuild/global-scripts.d.ts +16 -0
- package/src/tools/esbuild/global-scripts.js +142 -0
- package/src/tools/esbuild/global-styles.d.ts +10 -0
- package/src/tools/esbuild/global-styles.js +74 -0
- package/src/tools/esbuild/i18n-inliner-worker.d.ts +42 -0
- package/src/tools/esbuild/i18n-inliner-worker.js +136 -0
- package/src/tools/esbuild/i18n-inliner.d.ts +44 -0
- package/src/tools/esbuild/i18n-inliner.js +150 -0
- package/src/tools/esbuild/i18n-locale-plugin.d.ts +22 -0
- package/src/tools/esbuild/i18n-locale-plugin.js +120 -0
- package/src/tools/esbuild/index-html-generator.d.ts +15 -0
- package/src/tools/esbuild/index-html-generator.js +81 -0
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +19 -0
- package/src/tools/esbuild/javascript-transformer-worker.js +154 -0
- package/src/tools/esbuild/javascript-transformer.d.ts +54 -0
- package/src/tools/esbuild/javascript-transformer.js +147 -0
- package/src/tools/esbuild/license-extractor.d.ts +25 -0
- package/src/tools/esbuild/license-extractor.js +158 -0
- package/src/tools/esbuild/load-result-cache.d.ts +21 -0
- package/src/tools/esbuild/load-result-cache.js +75 -0
- package/src/tools/esbuild/profiling.d.ts +11 -0
- package/src/tools/esbuild/profiling.js +78 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +18 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +44 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +17 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +73 -0
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +35 -0
- package/src/tools/esbuild/stylesheets/bundle-options.js +64 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
- package/src/tools/esbuild/stylesheets/css-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/css-language.js +15 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +18 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.js +114 -0
- package/src/tools/esbuild/stylesheets/less-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/less-language.js +155 -0
- package/src/tools/esbuild/stylesheets/sass-language.d.ts +10 -0
- package/src/tools/esbuild/stylesheets/sass-language.js +185 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +58 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +282 -0
- package/src/tools/esbuild/utils.d.ts +49 -0
- package/src/tools/esbuild/utils.js +392 -0
- package/src/tools/esbuild/virtual-module-plugin.d.ts +33 -0
- package/src/tools/esbuild/virtual-module-plugin.js +43 -0
- package/src/tools/esbuild/watcher.d.ts +25 -0
- package/src/tools/esbuild/watcher.js +118 -0
- package/src/tools/sass/lexer.d.ts +18 -0
- package/src/tools/sass/lexer.js +161 -0
- package/src/tools/sass/rebasing-importer.d.ts +101 -0
- package/src/tools/sass/rebasing-importer.js +334 -0
- package/src/tools/sass/sass-service.d.ts +72 -0
- package/src/tools/sass/sass-service.js +213 -0
- package/src/tools/sass/worker.d.ts +8 -0
- package/src/tools/sass/worker.js +192 -0
- package/src/tools/vite/angular-memory-plugin.d.ts +24 -0
- package/src/tools/vite/angular-memory-plugin.js +268 -0
- package/src/tools/vite/i18n-locale-plugin.d.ts +18 -0
- package/src/tools/vite/i18n-locale-plugin.js +55 -0
- package/src/utils/bundle-calculator.d.ts +44 -0
- package/src/utils/bundle-calculator.js +303 -0
- package/src/utils/check-port.d.ts +8 -0
- package/src/utils/check-port.js +58 -0
- package/src/utils/color.d.ts +10 -0
- package/src/utils/color.js +63 -0
- package/src/utils/delete-output-dir.d.ts +11 -0
- package/src/utils/delete-output-dir.js +46 -0
- package/src/utils/environment-options.d.ts +16 -0
- package/src/utils/environment-options.js +79 -0
- package/src/utils/error.d.ts +10 -0
- package/src/utils/error.js +21 -0
- package/src/utils/format-bytes.d.ts +8 -0
- package/src/utils/format-bytes.js +22 -0
- package/src/utils/i18n-options.d.ts +33 -0
- package/src/utils/i18n-options.js +161 -0
- package/src/utils/index-file/add-event-dispatch-contract.d.ts +8 -0
- package/src/utils/index-file/add-event-dispatch-contract.js +28 -0
- package/src/utils/index-file/augment-index-html.d.ts +40 -0
- package/src/utils/index-file/augment-index-html.js +239 -0
- package/src/utils/index-file/html-rewriting-stream.d.ts +11 -0
- package/src/utils/index-file/html-rewriting-stream.js +28 -0
- package/src/utils/index-file/index-html-generator.d.ts +57 -0
- package/src/utils/index-file/index-html-generator.js +135 -0
- package/src/utils/index-file/inline-critical-css.d.ts +24 -0
- package/src/utils/index-file/inline-critical-css.js +179 -0
- package/src/utils/index-file/inline-fonts.d.ts +23 -0
- package/src/utils/index-file/inline-fonts.js +267 -0
- package/src/utils/index-file/nonce.d.ts +12 -0
- package/src/utils/index-file/nonce.js +55 -0
- package/src/utils/index-file/style-nonce.d.ts +12 -0
- package/src/utils/index-file/style-nonce.js +55 -0
- package/src/utils/index.d.ts +11 -0
- package/src/utils/index.js +27 -0
- package/src/utils/load-esm.d.ts +20 -0
- package/src/utils/load-esm.js +31 -0
- package/src/utils/load-proxy-config.d.ts +8 -0
- package/src/utils/load-proxy-config.js +189 -0
- package/src/utils/load-translations.d.ts +16 -0
- package/src/utils/load-translations.js +84 -0
- package/src/utils/normalize-asset-patterns.d.ts +14 -0
- package/src/utils/normalize-asset-patterns.js +96 -0
- package/src/utils/normalize-cache.d.ts +16 -0
- package/src/utils/normalize-cache.js +44 -0
- package/src/utils/normalize-optimization.d.ts +13 -0
- package/src/utils/normalize-optimization.js +42 -0
- package/src/utils/normalize-source-maps.d.ts +9 -0
- package/src/utils/normalize-source-maps.js +23 -0
- package/src/utils/postcss-configuration.d.ts +17 -0
- package/src/utils/postcss-configuration.js +86 -0
- package/src/utils/purge-cache.d.ts +10 -0
- package/src/utils/purge-cache.js +40 -0
- package/src/utils/resolve-assets.d.ts +18 -0
- package/src/utils/resolve-assets.js +35 -0
- package/src/utils/routes-extractor/extractor.d.ts +15 -0
- package/src/utils/routes-extractor/extractor.js +97 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +18 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +129 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +8 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +13 -0
- package/src/utils/server-rendering/fetch-patch.d.ts +8 -0
- package/src/utils/server-rendering/fetch-patch.js +66 -0
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +10 -0
- package/src/utils/server-rendering/load-esm-from-memory.js +26 -0
- package/src/utils/server-rendering/main-bundle-exports.d.ts +27 -0
- package/src/utils/server-rendering/main-bundle-exports.js +9 -0
- package/src/utils/server-rendering/prerender.d.ts +23 -0
- package/src/utils/server-rendering/prerender.js +192 -0
- package/src/utils/server-rendering/render-page.d.ts +26 -0
- package/src/utils/server-rendering/render-page.js +110 -0
- package/src/utils/server-rendering/render-worker.d.ts +22 -0
- package/src/utils/server-rendering/render-worker.js +30 -0
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +21 -0
- package/src/utils/server-rendering/routes-extractor-worker.js +53 -0
- package/src/utils/service-worker.d.ts +25 -0
- package/src/utils/service-worker.js +211 -0
- package/src/utils/spinner.d.ts +20 -0
- package/src/utils/spinner.js +55 -0
- package/src/utils/stats-table.d.ts +20 -0
- package/src/utils/stats-table.js +205 -0
- package/src/utils/supported-browsers.d.ts +10 -0
- package/src/utils/supported-browsers.js +42 -0
- package/src/utils/tty.d.ts +8 -0
- package/src/utils/tty.js +23 -0
- package/src/utils/url.d.ts +8 -0
- package/src/utils/url.js +18 -0
- package/src/utils/version.d.ts +8 -0
- package/src/utils/version.js +59 -0
|
@@ -0,0 +1,128 @@
|
|
|
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;
|
|
@@ -0,0 +1,57 @@
|
|
|
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("../../../../../angular_devkit/architect/src/internal").Builder<ApplicationBuilderOptions & import("../../../../../angular_devkit/core/src").JsonObject>;
|
|
57
|
+
export default _default;
|
|
@@ -0,0 +1,121 @@
|
|
|
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.buildApplication = exports.buildApplicationInternal = void 0;
|
|
11
|
+
const architect_1 = require("@angular-devkit/architect");
|
|
12
|
+
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
|
13
|
+
const utils_1 = require("../../tools/esbuild/utils");
|
|
14
|
+
const color_1 = require("../../utils/color");
|
|
15
|
+
const purge_cache_1 = require("../../utils/purge-cache");
|
|
16
|
+
const version_1 = require("../../utils/version");
|
|
17
|
+
const build_action_1 = require("./build-action");
|
|
18
|
+
const execute_build_1 = require("./execute-build");
|
|
19
|
+
const options_1 = require("./options");
|
|
20
|
+
async function* buildApplicationInternal(options,
|
|
21
|
+
// TODO: Integrate abort signal support into builder system
|
|
22
|
+
context, infrastructureSettings, extensions) {
|
|
23
|
+
const { workspaceRoot, logger, target } = context;
|
|
24
|
+
// Check Angular version.
|
|
25
|
+
(0, version_1.assertCompatibleAngularVersion)(workspaceRoot);
|
|
26
|
+
// Purge old build disk cache.
|
|
27
|
+
await (0, purge_cache_1.purgeStaleBuildCache)(context);
|
|
28
|
+
// Determine project name from builder context target
|
|
29
|
+
const projectName = target?.project;
|
|
30
|
+
if (!projectName) {
|
|
31
|
+
yield { success: false, error: `The 'application' builder requires a target to be specified.` };
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const normalizedOptions = await (0, options_1.normalizeOptions)(context, projectName, options, extensions);
|
|
35
|
+
const writeToFileSystem = infrastructureSettings?.write ?? true;
|
|
36
|
+
const writeServerBundles = writeToFileSystem && !!(normalizedOptions.ssrOptions && normalizedOptions.serverEntryPoint);
|
|
37
|
+
if (writeServerBundles) {
|
|
38
|
+
const { browser, server } = normalizedOptions.outputOptions;
|
|
39
|
+
if (browser === '') {
|
|
40
|
+
yield {
|
|
41
|
+
success: false,
|
|
42
|
+
error: `'outputPath.browser' cannot be configured to an empty string when SSR is enabled.`,
|
|
43
|
+
};
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (browser === server) {
|
|
47
|
+
yield {
|
|
48
|
+
success: false,
|
|
49
|
+
error: `'outputPath.browser' and 'outputPath.server' cannot be configured to the same value.`,
|
|
50
|
+
};
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Setup an abort controller with a builder teardown if no signal is present
|
|
55
|
+
let signal = context.signal;
|
|
56
|
+
if (!signal) {
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
signal = controller.signal;
|
|
59
|
+
context.addTeardown(() => controller.abort('builder-teardown'));
|
|
60
|
+
}
|
|
61
|
+
yield* (0, build_action_1.runEsBuildBuildAction)(async (rebuildState) => {
|
|
62
|
+
const { prerenderOptions, outputOptions, jsonLogs } = normalizedOptions;
|
|
63
|
+
const startTime = process.hrtime.bigint();
|
|
64
|
+
const result = await (0, execute_build_1.executeBuild)(normalizedOptions, context, rebuildState);
|
|
65
|
+
if (jsonLogs) {
|
|
66
|
+
result.addLog(await (0, utils_1.createJsonBuildManifest)(result, normalizedOptions));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (prerenderOptions) {
|
|
70
|
+
const prerenderedRoutesLength = result.prerenderedRoutes.length;
|
|
71
|
+
let prerenderMsg = `Prerendered ${prerenderedRoutesLength} static route`;
|
|
72
|
+
prerenderMsg += prerenderedRoutesLength !== 1 ? 's.' : '.';
|
|
73
|
+
result.addLog(color_1.colors.magenta(prerenderMsg));
|
|
74
|
+
}
|
|
75
|
+
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
|
|
76
|
+
const hasError = result.errors.length > 0;
|
|
77
|
+
if (writeToFileSystem && !hasError) {
|
|
78
|
+
result.addLog(`Output location: ${outputOptions.base}\n`);
|
|
79
|
+
}
|
|
80
|
+
result.addLog(`Application bundle generation ${hasError ? 'failed' : 'complete'}. [${buildTime.toFixed(3)} seconds]\n`);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}, {
|
|
84
|
+
watch: normalizedOptions.watch,
|
|
85
|
+
preserveSymlinks: normalizedOptions.preserveSymlinks,
|
|
86
|
+
poll: normalizedOptions.poll,
|
|
87
|
+
deleteOutputPath: normalizedOptions.deleteOutputPath,
|
|
88
|
+
cacheOptions: normalizedOptions.cacheOptions,
|
|
89
|
+
outputOptions: normalizedOptions.outputOptions,
|
|
90
|
+
verbose: normalizedOptions.verbose,
|
|
91
|
+
projectRoot: normalizedOptions.projectRoot,
|
|
92
|
+
workspaceRoot: normalizedOptions.workspaceRoot,
|
|
93
|
+
progress: normalizedOptions.progress,
|
|
94
|
+
clearScreen: normalizedOptions.clearScreen,
|
|
95
|
+
colors: normalizedOptions.colors,
|
|
96
|
+
jsonLogs: normalizedOptions.jsonLogs,
|
|
97
|
+
writeToFileSystem,
|
|
98
|
+
// For app-shell and SSG server files are not required by users.
|
|
99
|
+
// Omit these when SSR is not enabled.
|
|
100
|
+
writeToFileSystemFilter: writeServerBundles
|
|
101
|
+
? undefined
|
|
102
|
+
: (file) => file.type !== bundler_context_1.BuildOutputFileType.Server,
|
|
103
|
+
logger,
|
|
104
|
+
signal,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.buildApplicationInternal = buildApplicationInternal;
|
|
108
|
+
function buildApplication(options, context, pluginsOrExtensions) {
|
|
109
|
+
let extensions;
|
|
110
|
+
if (pluginsOrExtensions && Array.isArray(pluginsOrExtensions)) {
|
|
111
|
+
extensions = {
|
|
112
|
+
codePlugins: pluginsOrExtensions,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
extensions = pluginsOrExtensions;
|
|
117
|
+
}
|
|
118
|
+
return buildApplicationInternal(options, context, undefined, extensions);
|
|
119
|
+
}
|
|
120
|
+
exports.buildApplication = buildApplication;
|
|
121
|
+
exports.default = (0, architect_1.createBuilder)(buildApplication);
|
|
@@ -0,0 +1,149 @@
|
|
|
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 type { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
+
import type { Plugin } from 'esbuild';
|
|
10
|
+
import { I18nOptions } from '../../utils/i18n-options';
|
|
11
|
+
import { IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
|
|
12
|
+
import { Schema as ApplicationBuilderOptions, I18NTranslation, OutputPathClass } from './schema';
|
|
13
|
+
export type NormalizedOutputOptions = Required<OutputPathClass>;
|
|
14
|
+
export type NormalizedApplicationBuildOptions = Awaited<ReturnType<typeof normalizeOptions>>;
|
|
15
|
+
export interface ApplicationBuilderExtensions {
|
|
16
|
+
codePlugins?: Plugin[];
|
|
17
|
+
indexHtmlTransformer?: IndexHtmlTransform;
|
|
18
|
+
}
|
|
19
|
+
/** Internal options hidden from builder schema but available when invoked programmatically. */
|
|
20
|
+
interface InternalOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Entry points to use for the compilation. Incompatible with `browser`, which must not be provided. May be relative or absolute paths.
|
|
23
|
+
* If given a relative path, it is resolved relative to the current workspace and will generate an output at the same relative location
|
|
24
|
+
* in the output directory. If given an absolute path, the output will be generated in the root of the output directory with the same base
|
|
25
|
+
* name.
|
|
26
|
+
*/
|
|
27
|
+
entryPoints?: Set<string>;
|
|
28
|
+
/** File extension to use for the generated output files. */
|
|
29
|
+
outExtension?: 'js' | 'mjs';
|
|
30
|
+
/**
|
|
31
|
+
* Indicates whether all node packages should be marked as external.
|
|
32
|
+
* Currently used by the dev-server to support prebundling.
|
|
33
|
+
*/
|
|
34
|
+
externalPackages?: boolean | {
|
|
35
|
+
exclude: string[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Forces the output from the localize post-processing to not create nested directories per locale output.
|
|
39
|
+
* This is only used by the development server which currently only supports a single locale per build.
|
|
40
|
+
*/
|
|
41
|
+
forceI18nFlatOutput?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Full set of options for `application` builder. */
|
|
44
|
+
export type ApplicationBuilderInternalOptions = Omit<ApplicationBuilderOptions & InternalOptions, 'browser'> & {
|
|
45
|
+
browser?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Normalize the user provided options by creating full paths for all path based options
|
|
49
|
+
* and converting multi-form options into a single form that can be directly used
|
|
50
|
+
* by the build process.
|
|
51
|
+
*
|
|
52
|
+
* @param context The context for current builder execution.
|
|
53
|
+
* @param projectName The name of the project for the current execution.
|
|
54
|
+
* @param options An object containing the options to use for the build.
|
|
55
|
+
* @param plugins An optional array of programmatically supplied build plugins.
|
|
56
|
+
* @returns An object containing normalized options required to perform the build.
|
|
57
|
+
*/
|
|
58
|
+
export declare function normalizeOptions(context: BuilderContext, projectName: string, options: ApplicationBuilderInternalOptions, extensions?: ApplicationBuilderExtensions): Promise<{
|
|
59
|
+
advancedOptimizations: boolean;
|
|
60
|
+
allowedCommonJsDependencies: string[] | undefined;
|
|
61
|
+
baseHref: string | undefined;
|
|
62
|
+
cacheOptions: import("../../utils/normalize-cache").NormalizedCachedOptions;
|
|
63
|
+
crossOrigin: import("./schema").CrossOrigin | undefined;
|
|
64
|
+
deleteOutputPath: boolean | undefined;
|
|
65
|
+
externalDependencies: string[] | undefined;
|
|
66
|
+
extractLicenses: boolean | undefined;
|
|
67
|
+
inlineStyleLanguage: string;
|
|
68
|
+
jit: boolean;
|
|
69
|
+
stats: boolean;
|
|
70
|
+
polyfills: string[] | undefined;
|
|
71
|
+
poll: number | undefined;
|
|
72
|
+
progress: boolean;
|
|
73
|
+
externalPackages: boolean | {
|
|
74
|
+
exclude: string[];
|
|
75
|
+
} | undefined;
|
|
76
|
+
preserveSymlinks: boolean;
|
|
77
|
+
stylePreprocessorOptions: import("./schema").StylePreprocessorOptions | undefined;
|
|
78
|
+
subresourceIntegrity: boolean | undefined;
|
|
79
|
+
serverEntryPoint: string | undefined;
|
|
80
|
+
prerenderOptions: {
|
|
81
|
+
discoverRoutes: boolean;
|
|
82
|
+
routesFile: string | undefined;
|
|
83
|
+
} | undefined;
|
|
84
|
+
appShellOptions: {
|
|
85
|
+
route: string;
|
|
86
|
+
} | undefined;
|
|
87
|
+
ssrOptions: {
|
|
88
|
+
entry?: undefined;
|
|
89
|
+
} | {
|
|
90
|
+
entry: string | undefined;
|
|
91
|
+
} | undefined;
|
|
92
|
+
verbose: boolean | undefined;
|
|
93
|
+
watch: boolean | undefined;
|
|
94
|
+
workspaceRoot: string;
|
|
95
|
+
entryPoints: Record<string, string>;
|
|
96
|
+
optimizationOptions: import("../../utils").NormalizedOptimizationOptions;
|
|
97
|
+
outputOptions: Required<OutputPathClass>;
|
|
98
|
+
outExtension: "js" | "mjs" | undefined;
|
|
99
|
+
sourcemapOptions: import("./schema").SourceMapClass;
|
|
100
|
+
tsconfig: string;
|
|
101
|
+
projectRoot: string;
|
|
102
|
+
assets: (import("./schema").AssetPatternClass & {
|
|
103
|
+
output: string;
|
|
104
|
+
})[] | undefined;
|
|
105
|
+
outputNames: {
|
|
106
|
+
bundles: string;
|
|
107
|
+
media: string;
|
|
108
|
+
};
|
|
109
|
+
fileReplacements: Record<string, string> | undefined;
|
|
110
|
+
globalStyles: {
|
|
111
|
+
name: string;
|
|
112
|
+
files: string[];
|
|
113
|
+
initial: boolean;
|
|
114
|
+
}[];
|
|
115
|
+
globalScripts: {
|
|
116
|
+
name: string;
|
|
117
|
+
files: string[];
|
|
118
|
+
initial: boolean;
|
|
119
|
+
}[];
|
|
120
|
+
serviceWorker: string | undefined;
|
|
121
|
+
indexHtmlOptions: {
|
|
122
|
+
input: string;
|
|
123
|
+
output: string;
|
|
124
|
+
insertionOrder: [string, boolean][];
|
|
125
|
+
transformer: IndexHtmlTransform | undefined;
|
|
126
|
+
preloadInitial: boolean;
|
|
127
|
+
} | undefined;
|
|
128
|
+
tailwindConfiguration: {
|
|
129
|
+
file: string;
|
|
130
|
+
package: string;
|
|
131
|
+
} | undefined;
|
|
132
|
+
postcssConfiguration: import("../../utils/postcss-configuration").PostcssConfiguration | undefined;
|
|
133
|
+
i18nOptions: I18nOptions & {
|
|
134
|
+
duplicateTranslationBehavior?: I18NTranslation | undefined;
|
|
135
|
+
missingTranslationBehavior?: I18NTranslation | undefined;
|
|
136
|
+
};
|
|
137
|
+
namedChunks: boolean | undefined;
|
|
138
|
+
budgets: import("./schema").Budget[] | undefined;
|
|
139
|
+
publicPath: string | undefined;
|
|
140
|
+
plugins: Plugin[] | undefined;
|
|
141
|
+
loaderExtensions: Record<string, "file" | "binary" | "text"> | undefined;
|
|
142
|
+
jsonLogs: boolean;
|
|
143
|
+
colors: boolean;
|
|
144
|
+
clearScreen: boolean | undefined;
|
|
145
|
+
define: {
|
|
146
|
+
[key: string]: string;
|
|
147
|
+
} | undefined;
|
|
148
|
+
}>;
|
|
149
|
+
export {};
|