@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,369 @@
|
|
|
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.normalizeOptions = void 0;
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
|
+
const promises_1 = require("node:fs/promises");
|
|
16
|
+
const node_module_1 = require("node:module");
|
|
17
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
+
const utils_1 = require("../../utils");
|
|
19
|
+
const color_1 = require("../../utils/color");
|
|
20
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
21
|
+
const i18n_options_1 = require("../../utils/i18n-options");
|
|
22
|
+
const normalize_cache_1 = require("../../utils/normalize-cache");
|
|
23
|
+
const postcss_configuration_1 = require("../../utils/postcss-configuration");
|
|
24
|
+
const schema_1 = require("./schema");
|
|
25
|
+
/**
|
|
26
|
+
* Normalize the user provided options by creating full paths for all path based options
|
|
27
|
+
* and converting multi-form options into a single form that can be directly used
|
|
28
|
+
* by the build process.
|
|
29
|
+
*
|
|
30
|
+
* @param context The context for current builder execution.
|
|
31
|
+
* @param projectName The name of the project for the current execution.
|
|
32
|
+
* @param options An object containing the options to use for the build.
|
|
33
|
+
* @param plugins An optional array of programmatically supplied build plugins.
|
|
34
|
+
* @returns An object containing normalized options required to perform the build.
|
|
35
|
+
*/
|
|
36
|
+
// eslint-disable-next-line max-lines-per-function
|
|
37
|
+
async function normalizeOptions(context, projectName, options, extensions) {
|
|
38
|
+
// If not explicitly set, default to the Node.js process argument
|
|
39
|
+
const preserveSymlinks = options.preserveSymlinks ?? process.execArgv.includes('--preserve-symlinks');
|
|
40
|
+
// Setup base paths based on workspace root and project information
|
|
41
|
+
const workspaceRoot = preserveSymlinks
|
|
42
|
+
? context.workspaceRoot
|
|
43
|
+
: // NOTE: promises.realpath should not be used here since it uses realpath.native which
|
|
44
|
+
// can cause case conversion and other undesirable behavior on Windows systems.
|
|
45
|
+
// ref: https://github.com/nodejs/node/issues/7726
|
|
46
|
+
(0, node_fs_1.realpathSync)(context.workspaceRoot);
|
|
47
|
+
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
48
|
+
const projectRoot = normalizeDirectoryPath(node_path_1.default.join(workspaceRoot, projectMetadata.root ?? ''));
|
|
49
|
+
const projectSourceRoot = normalizeDirectoryPath(node_path_1.default.join(workspaceRoot, projectMetadata.sourceRoot ?? 'src'));
|
|
50
|
+
// Gather persistent caching option and provide a project specific cache location
|
|
51
|
+
const cacheOptions = (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, workspaceRoot);
|
|
52
|
+
cacheOptions.path = node_path_1.default.join(cacheOptions.path, projectName);
|
|
53
|
+
const i18nOptions = (0, i18n_options_1.createI18nOptions)(projectMetadata, options.localize);
|
|
54
|
+
i18nOptions.duplicateTranslationBehavior = options.i18nDuplicateTranslation;
|
|
55
|
+
i18nOptions.missingTranslationBehavior = options.i18nMissingTranslation;
|
|
56
|
+
if (options.forceI18nFlatOutput) {
|
|
57
|
+
i18nOptions.flatOutput = true;
|
|
58
|
+
}
|
|
59
|
+
const entryPoints = normalizeEntryPoints(workspaceRoot, options.browser, options.entryPoints);
|
|
60
|
+
const tsconfig = node_path_1.default.join(workspaceRoot, options.tsConfig);
|
|
61
|
+
const optimizationOptions = (0, utils_1.normalizeOptimization)(options.optimization);
|
|
62
|
+
const sourcemapOptions = (0, utils_1.normalizeSourceMaps)(options.sourceMap ?? false);
|
|
63
|
+
const assets = options.assets?.length
|
|
64
|
+
? (0, utils_1.normalizeAssetPatterns)(options.assets, workspaceRoot, projectRoot, projectSourceRoot)
|
|
65
|
+
: undefined;
|
|
66
|
+
const outputPath = options.outputPath;
|
|
67
|
+
const outputOptions = {
|
|
68
|
+
browser: 'browser',
|
|
69
|
+
server: 'server',
|
|
70
|
+
media: 'media',
|
|
71
|
+
...(typeof outputPath === 'string' ? undefined : outputPath),
|
|
72
|
+
base: normalizeDirectoryPath(node_path_1.default.resolve(workspaceRoot, typeof outputPath === 'string' ? outputPath : outputPath.base)),
|
|
73
|
+
};
|
|
74
|
+
const outputNames = {
|
|
75
|
+
bundles: options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Bundles
|
|
76
|
+
? '[name]-[hash]'
|
|
77
|
+
: '[name]',
|
|
78
|
+
media: outputOptions.media +
|
|
79
|
+
(options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Media
|
|
80
|
+
? '/[name]-[hash]'
|
|
81
|
+
: '/[name]'),
|
|
82
|
+
};
|
|
83
|
+
let fileReplacements;
|
|
84
|
+
if (options.fileReplacements) {
|
|
85
|
+
for (const replacement of options.fileReplacements) {
|
|
86
|
+
const fileReplaceWith = node_path_1.default.join(workspaceRoot, replacement.with);
|
|
87
|
+
try {
|
|
88
|
+
await (0, promises_1.access)(fileReplaceWith, promises_1.constants.F_OK);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
throw new Error(`The ${fileReplaceWith} path in file replacements does not exist.`);
|
|
92
|
+
}
|
|
93
|
+
fileReplacements ??= {};
|
|
94
|
+
fileReplacements[node_path_1.default.join(workspaceRoot, replacement.replace)] = fileReplaceWith;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let loaderExtensions;
|
|
98
|
+
if (options.loader) {
|
|
99
|
+
for (const [extension, value] of Object.entries(options.loader)) {
|
|
100
|
+
if (extension[0] !== '.' || /\.[cm]?[jt]sx?$/.test(extension)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (value !== 'text' && value !== 'binary' && value !== 'file' && value !== 'empty') {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
loaderExtensions ??= {};
|
|
107
|
+
loaderExtensions[extension] = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// A configuration file can exist in the project or workspace root
|
|
111
|
+
const searchDirectories = await (0, postcss_configuration_1.generateSearchDirectories)([projectRoot, workspaceRoot]);
|
|
112
|
+
const postcssConfiguration = await (0, postcss_configuration_1.loadPostcssConfiguration)(searchDirectories);
|
|
113
|
+
// Skip tailwind configuration if postcss is customized
|
|
114
|
+
const tailwindConfiguration = postcssConfiguration
|
|
115
|
+
? undefined
|
|
116
|
+
: await getTailwindConfig(searchDirectories, workspaceRoot, context);
|
|
117
|
+
let serverEntryPoint;
|
|
118
|
+
if (options.server) {
|
|
119
|
+
serverEntryPoint = node_path_1.default.join(workspaceRoot, options.server);
|
|
120
|
+
}
|
|
121
|
+
else if (options.server === '') {
|
|
122
|
+
throw new Error('The "server" option cannot be an empty string.');
|
|
123
|
+
}
|
|
124
|
+
let prerenderOptions;
|
|
125
|
+
if (options.prerender) {
|
|
126
|
+
const { discoverRoutes = true, routesFile = undefined } = options.prerender === true ? {} : options.prerender;
|
|
127
|
+
prerenderOptions = {
|
|
128
|
+
discoverRoutes,
|
|
129
|
+
routesFile: routesFile && node_path_1.default.join(workspaceRoot, routesFile),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
let ssrOptions;
|
|
133
|
+
if (options.ssr === true) {
|
|
134
|
+
ssrOptions = {};
|
|
135
|
+
}
|
|
136
|
+
else if (typeof options.ssr === 'object') {
|
|
137
|
+
const { entry } = options.ssr;
|
|
138
|
+
ssrOptions = {
|
|
139
|
+
entry: entry && node_path_1.default.join(workspaceRoot, entry),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
let appShellOptions;
|
|
143
|
+
if (options.appShell) {
|
|
144
|
+
appShellOptions = {
|
|
145
|
+
route: 'shell',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const globalStyles = normalizeGlobalEntries(options.styles, 'styles');
|
|
149
|
+
const globalScripts = normalizeGlobalEntries(options.scripts, 'scripts');
|
|
150
|
+
let indexHtmlOptions;
|
|
151
|
+
// index can never have a value of `true` but in the schema it's of type `boolean`.
|
|
152
|
+
if (typeof options.index !== 'boolean') {
|
|
153
|
+
let indexOutput;
|
|
154
|
+
// The output file will be created within the configured output path
|
|
155
|
+
if (typeof options.index === 'string') {
|
|
156
|
+
/**
|
|
157
|
+
* If SSR is activated, create a distinct entry file for the `index.html`.
|
|
158
|
+
* This is necessary because numerous server/cloud providers automatically serve the `index.html` as a static file
|
|
159
|
+
* if it exists (handling SSG).
|
|
160
|
+
* For instance, accessing `foo.com/` would lead to `foo.com/index.html` being served instead of hitting the server.
|
|
161
|
+
*/
|
|
162
|
+
const indexBaseName = node_path_1.default.basename(options.index);
|
|
163
|
+
indexOutput = ssrOptions && indexBaseName === 'index.html' ? 'index.csr.html' : indexBaseName;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
indexOutput = options.index.output || 'index.html';
|
|
167
|
+
}
|
|
168
|
+
indexHtmlOptions = {
|
|
169
|
+
input: node_path_1.default.join(workspaceRoot, typeof options.index === 'string' ? options.index : options.index.input),
|
|
170
|
+
output: indexOutput,
|
|
171
|
+
insertionOrder: [
|
|
172
|
+
['polyfills', true],
|
|
173
|
+
...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
174
|
+
...globalScripts.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
175
|
+
['main', true],
|
|
176
|
+
// [name, esm]
|
|
177
|
+
],
|
|
178
|
+
transformer: extensions?.indexHtmlTransformer,
|
|
179
|
+
// Preload initial defaults to true
|
|
180
|
+
preloadInitial: typeof options.index !== 'object' || (options.index.preloadInitial ?? true),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (appShellOptions || ssrOptions || prerenderOptions) {
|
|
184
|
+
if (!serverEntryPoint) {
|
|
185
|
+
throw new Error('The "server" option is required when enabling "ssr", "prerender" or "app-shell".');
|
|
186
|
+
}
|
|
187
|
+
if (!indexHtmlOptions) {
|
|
188
|
+
throw new Error('The "index" option cannot be set to false when enabling "ssr", "prerender" or "app-shell".');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Initial options to keep
|
|
192
|
+
const { allowedCommonJsDependencies, aot, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, deleteOutputPath, namedChunks, budgets, deployUrl, clearScreen, define, } = options;
|
|
193
|
+
// Return all the normalized options
|
|
194
|
+
return {
|
|
195
|
+
advancedOptimizations: !!aot && optimizationOptions.scripts,
|
|
196
|
+
allowedCommonJsDependencies,
|
|
197
|
+
baseHref,
|
|
198
|
+
cacheOptions,
|
|
199
|
+
crossOrigin,
|
|
200
|
+
deleteOutputPath,
|
|
201
|
+
externalDependencies,
|
|
202
|
+
extractLicenses,
|
|
203
|
+
inlineStyleLanguage,
|
|
204
|
+
jit: !aot,
|
|
205
|
+
stats: !!statsJson,
|
|
206
|
+
polyfills: polyfills === undefined || Array.isArray(polyfills) ? polyfills : [polyfills],
|
|
207
|
+
poll,
|
|
208
|
+
progress,
|
|
209
|
+
externalPackages,
|
|
210
|
+
preserveSymlinks,
|
|
211
|
+
stylePreprocessorOptions,
|
|
212
|
+
subresourceIntegrity,
|
|
213
|
+
serverEntryPoint,
|
|
214
|
+
prerenderOptions,
|
|
215
|
+
appShellOptions,
|
|
216
|
+
ssrOptions,
|
|
217
|
+
verbose,
|
|
218
|
+
watch,
|
|
219
|
+
workspaceRoot,
|
|
220
|
+
entryPoints,
|
|
221
|
+
optimizationOptions,
|
|
222
|
+
outputOptions,
|
|
223
|
+
outExtension,
|
|
224
|
+
sourcemapOptions,
|
|
225
|
+
tsconfig,
|
|
226
|
+
projectRoot,
|
|
227
|
+
assets,
|
|
228
|
+
outputNames,
|
|
229
|
+
fileReplacements,
|
|
230
|
+
globalStyles,
|
|
231
|
+
globalScripts,
|
|
232
|
+
serviceWorker: serviceWorker
|
|
233
|
+
? node_path_1.default.join(workspaceRoot, typeof serviceWorker === 'string' ? serviceWorker : 'src/ngsw-config.json')
|
|
234
|
+
: undefined,
|
|
235
|
+
indexHtmlOptions,
|
|
236
|
+
tailwindConfiguration,
|
|
237
|
+
postcssConfiguration,
|
|
238
|
+
i18nOptions,
|
|
239
|
+
namedChunks,
|
|
240
|
+
budgets: budgets?.length ? budgets : undefined,
|
|
241
|
+
publicPath: deployUrl,
|
|
242
|
+
plugins: extensions?.codePlugins?.length ? extensions?.codePlugins : undefined,
|
|
243
|
+
loaderExtensions,
|
|
244
|
+
jsonLogs: environment_options_1.useJSONBuildLogs,
|
|
245
|
+
colors: color_1.colors.enabled,
|
|
246
|
+
clearScreen,
|
|
247
|
+
define,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
exports.normalizeOptions = normalizeOptions;
|
|
251
|
+
async function getTailwindConfig(searchDirectories, workspaceRoot, context) {
|
|
252
|
+
const tailwindConfigurationPath = (0, postcss_configuration_1.findTailwindConfiguration)(searchDirectories);
|
|
253
|
+
if (!tailwindConfigurationPath) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
// Create a node resolver from the configuration file
|
|
257
|
+
const resolver = (0, node_module_1.createRequire)(tailwindConfigurationPath);
|
|
258
|
+
try {
|
|
259
|
+
return {
|
|
260
|
+
file: tailwindConfigurationPath,
|
|
261
|
+
package: resolver.resolve('tailwindcss'),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
const relativeTailwindConfigPath = node_path_1.default.relative(workspaceRoot, tailwindConfigurationPath);
|
|
266
|
+
context.logger.warn(`Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +
|
|
267
|
+
` but the 'tailwindcss' package is not installed.` +
|
|
268
|
+
` To enable Tailwind CSS, please install the 'tailwindcss' package.`);
|
|
269
|
+
}
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Normalize entry point options. To maintain compatibility with the legacy browser builder, we need a single `browser`
|
|
274
|
+
* option which defines a single entry point. However, we also want to support multiple entry points as an internal option.
|
|
275
|
+
* The two options are mutually exclusive and if `browser` is provided it will be used as the sole entry point.
|
|
276
|
+
* If `entryPoints` are provided, they will be used as the set of entry points.
|
|
277
|
+
*
|
|
278
|
+
* @param workspaceRoot Path to the root of the Angular workspace.
|
|
279
|
+
* @param browser The `browser` option pointing at the application entry point. While required per the schema file, it may be omitted by
|
|
280
|
+
* programmatic usages of `browser-esbuild`.
|
|
281
|
+
* @param entryPoints Set of entry points to use if provided.
|
|
282
|
+
* @returns An object mapping entry point names to their file paths.
|
|
283
|
+
*/
|
|
284
|
+
function normalizeEntryPoints(workspaceRoot, browser, entryPoints = new Set()) {
|
|
285
|
+
if (browser === '') {
|
|
286
|
+
throw new Error('`browser` option cannot be an empty string.');
|
|
287
|
+
}
|
|
288
|
+
// `browser` and `entryPoints` are mutually exclusive.
|
|
289
|
+
if (browser && entryPoints.size > 0) {
|
|
290
|
+
throw new Error('Only one of `browser` or `entryPoints` may be provided.');
|
|
291
|
+
}
|
|
292
|
+
if (!browser && entryPoints.size === 0) {
|
|
293
|
+
// Schema should normally reject this case, but programmatic usages of the builder might make this mistake.
|
|
294
|
+
throw new Error('Either `browser` or at least one `entryPoints` value must be provided.');
|
|
295
|
+
}
|
|
296
|
+
// Schema types force `browser` to always be provided, but it may be omitted when the builder is invoked programmatically.
|
|
297
|
+
if (browser) {
|
|
298
|
+
// Use `browser` alone.
|
|
299
|
+
return { 'main': node_path_1.default.join(workspaceRoot, browser) };
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
// Use `entryPoints` alone.
|
|
303
|
+
const entryPointPaths = {};
|
|
304
|
+
for (const entryPoint of entryPoints) {
|
|
305
|
+
const parsedEntryPoint = node_path_1.default.parse(entryPoint);
|
|
306
|
+
// Use the input file path without an extension as the "name" of the entry point dictating its output location.
|
|
307
|
+
// Relative entry points are generated at the same relative path in the output directory.
|
|
308
|
+
// Absolute entry points are always generated with the same file name in the root of the output directory. This includes absolute
|
|
309
|
+
// paths pointing at files actually within the workspace root.
|
|
310
|
+
const entryPointName = node_path_1.default.isAbsolute(entryPoint)
|
|
311
|
+
? parsedEntryPoint.name
|
|
312
|
+
: node_path_1.default.join(parsedEntryPoint.dir, parsedEntryPoint.name);
|
|
313
|
+
// Get the full file path to a relative entry point input. Leave bare specifiers alone so they are resolved as modules.
|
|
314
|
+
const isRelativePath = entryPoint.startsWith('.');
|
|
315
|
+
const entryPointPath = isRelativePath ? node_path_1.default.join(workspaceRoot, entryPoint) : entryPoint;
|
|
316
|
+
// Check for conflicts with previous entry points.
|
|
317
|
+
const existingEntryPointPath = entryPointPaths[entryPointName];
|
|
318
|
+
if (existingEntryPointPath) {
|
|
319
|
+
throw new Error(`\`${existingEntryPointPath}\` and \`${entryPointPath}\` both output to the same location \`${entryPointName}\`.` +
|
|
320
|
+
' Rename or move one of the files to fix the conflict.');
|
|
321
|
+
}
|
|
322
|
+
entryPointPaths[entryPointName] = entryPointPath;
|
|
323
|
+
}
|
|
324
|
+
return entryPointPaths;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Normalize a directory path string.
|
|
329
|
+
* Currently only removes a trailing slash if present.
|
|
330
|
+
* @param path A path string.
|
|
331
|
+
* @returns A normalized path string.
|
|
332
|
+
*/
|
|
333
|
+
function normalizeDirectoryPath(path) {
|
|
334
|
+
const last = path[path.length - 1];
|
|
335
|
+
if (last === '/' || last === '\\') {
|
|
336
|
+
return path.slice(0, -1);
|
|
337
|
+
}
|
|
338
|
+
return path;
|
|
339
|
+
}
|
|
340
|
+
function normalizeGlobalEntries(rawEntries, defaultName) {
|
|
341
|
+
if (!rawEntries?.length) {
|
|
342
|
+
return [];
|
|
343
|
+
}
|
|
344
|
+
const bundles = new Map();
|
|
345
|
+
for (const rawEntry of rawEntries) {
|
|
346
|
+
let entry;
|
|
347
|
+
if (typeof rawEntry === 'string') {
|
|
348
|
+
// string entries use default bundle name and inject values
|
|
349
|
+
entry = { input: rawEntry };
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
entry = rawEntry;
|
|
353
|
+
}
|
|
354
|
+
const { bundleName, input, inject = true } = entry;
|
|
355
|
+
// Non-injected entries default to the file name
|
|
356
|
+
const name = bundleName || (inject ? defaultName : node_path_1.default.basename(input, node_path_1.default.extname(input)));
|
|
357
|
+
const existing = bundles.get(name);
|
|
358
|
+
if (!existing) {
|
|
359
|
+
bundles.set(name, { name, files: [input], initial: inject });
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (existing.initial !== inject) {
|
|
363
|
+
throw new Error(`The "${name}" bundle is mixing injected and non-injected entries. ` +
|
|
364
|
+
'Verify that the project options are correct.');
|
|
365
|
+
}
|
|
366
|
+
existing.files.push(input);
|
|
367
|
+
}
|
|
368
|
+
return [...bundles.values()];
|
|
369
|
+
}
|