@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,189 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.loadProxyConfiguration = void 0;
|
|
34
|
+
const fast_glob_1 = require("fast-glob");
|
|
35
|
+
const node_fs_1 = require("node:fs");
|
|
36
|
+
const promises_1 = require("node:fs/promises");
|
|
37
|
+
const node_path_1 = require("node:path");
|
|
38
|
+
const node_url_1 = require("node:url");
|
|
39
|
+
const picomatch_1 = require("picomatch");
|
|
40
|
+
const error_1 = require("./error");
|
|
41
|
+
const load_esm_1 = require("./load-esm");
|
|
42
|
+
async function loadProxyConfiguration(root, proxyConfig) {
|
|
43
|
+
if (!proxyConfig) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const proxyPath = (0, node_path_1.resolve)(root, proxyConfig);
|
|
47
|
+
if (!(0, node_fs_1.existsSync)(proxyPath)) {
|
|
48
|
+
throw new Error(`Proxy configuration file ${proxyPath} does not exist.`);
|
|
49
|
+
}
|
|
50
|
+
let proxyConfiguration;
|
|
51
|
+
switch ((0, node_path_1.extname)(proxyPath)) {
|
|
52
|
+
case '.json': {
|
|
53
|
+
const content = await (0, promises_1.readFile)(proxyPath, 'utf-8');
|
|
54
|
+
const { parse, printParseErrorCode } = await Promise.resolve().then(() => __importStar(require('jsonc-parser')));
|
|
55
|
+
const parseErrors = [];
|
|
56
|
+
proxyConfiguration = parse(content, parseErrors, { allowTrailingComma: true });
|
|
57
|
+
if (parseErrors.length > 0) {
|
|
58
|
+
let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;
|
|
59
|
+
for (const parseError of parseErrors) {
|
|
60
|
+
const { line, column } = getJsonErrorLineColumn(parseError.offset, content);
|
|
61
|
+
errorMessage += `\n[${line}, ${column}] ${printParseErrorCode(parseError.error)}`;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(errorMessage);
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case '.mjs':
|
|
68
|
+
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
69
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
70
|
+
// changed to a direct dynamic import.
|
|
71
|
+
proxyConfiguration = (await (0, load_esm_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath)))
|
|
72
|
+
.default;
|
|
73
|
+
break;
|
|
74
|
+
case '.cjs':
|
|
75
|
+
proxyConfiguration = require(proxyPath);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
// The file could be either CommonJS or ESM.
|
|
79
|
+
// CommonJS is tried first then ESM if loading fails.
|
|
80
|
+
try {
|
|
81
|
+
proxyConfiguration = require(proxyPath);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
(0, error_1.assertIsError)(e);
|
|
86
|
+
if (e.code === 'ERR_REQUIRE_ESM') {
|
|
87
|
+
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
88
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
89
|
+
// changed to a direct dynamic import.
|
|
90
|
+
proxyConfiguration = (await (0, load_esm_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath)))
|
|
91
|
+
.default;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return normalizeProxyConfiguration(proxyConfiguration);
|
|
98
|
+
}
|
|
99
|
+
exports.loadProxyConfiguration = loadProxyConfiguration;
|
|
100
|
+
/**
|
|
101
|
+
* Converts glob patterns to regular expressions to support Vite's proxy option.
|
|
102
|
+
* Also converts the Webpack supported array form to an object form supported by both.
|
|
103
|
+
*
|
|
104
|
+
* @param proxy A proxy configuration object.
|
|
105
|
+
*/
|
|
106
|
+
function normalizeProxyConfiguration(proxy) {
|
|
107
|
+
let normalizedProxy;
|
|
108
|
+
if (Array.isArray(proxy)) {
|
|
109
|
+
// Construct an object-form proxy configuration from the array
|
|
110
|
+
normalizedProxy = {};
|
|
111
|
+
for (const proxyEntry of proxy) {
|
|
112
|
+
if (!('context' in proxyEntry)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (!Array.isArray(proxyEntry.context)) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
// Array-form entries contain a context string array with the path(s)
|
|
119
|
+
// to use for the configuration entry.
|
|
120
|
+
const context = proxyEntry.context;
|
|
121
|
+
delete proxyEntry.context;
|
|
122
|
+
for (const contextEntry of context) {
|
|
123
|
+
if (typeof contextEntry !== 'string') {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
normalizedProxy[contextEntry] = proxyEntry;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
normalizedProxy = proxy;
|
|
132
|
+
}
|
|
133
|
+
// TODO: Consider upstreaming glob support
|
|
134
|
+
for (const key of Object.keys(normalizedProxy)) {
|
|
135
|
+
if (key[0] !== '^' && (0, fast_glob_1.isDynamicPattern)(key)) {
|
|
136
|
+
const pattern = (0, picomatch_1.makeRe)(key).source;
|
|
137
|
+
normalizedProxy[pattern] = normalizedProxy[key];
|
|
138
|
+
delete normalizedProxy[key];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Replace `pathRewrite` field with a `rewrite` function
|
|
142
|
+
for (const proxyEntry of Object.values(normalizedProxy)) {
|
|
143
|
+
if (typeof proxyEntry === 'object' &&
|
|
144
|
+
'pathRewrite' in proxyEntry &&
|
|
145
|
+
proxyEntry.pathRewrite &&
|
|
146
|
+
typeof proxyEntry.pathRewrite === 'object') {
|
|
147
|
+
// Preprocess path rewrite entries
|
|
148
|
+
const pathRewriteEntries = [];
|
|
149
|
+
for (const [pattern, value] of Object.entries(proxyEntry.pathRewrite)) {
|
|
150
|
+
pathRewriteEntries.push([new RegExp(pattern), value]);
|
|
151
|
+
}
|
|
152
|
+
proxyEntry.rewrite = pathRewriter.bind(undefined, pathRewriteEntries);
|
|
153
|
+
delete proxyEntry.pathRewrite;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return normalizedProxy;
|
|
157
|
+
}
|
|
158
|
+
function pathRewriter(pathRewriteEntries, path) {
|
|
159
|
+
for (const [pattern, value] of pathRewriteEntries) {
|
|
160
|
+
const updated = path.replace(pattern, value);
|
|
161
|
+
if (path !== updated) {
|
|
162
|
+
return updated;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return path;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Calculates the line and column for an error offset in the content of a JSON file.
|
|
169
|
+
* @param location The offset error location from the beginning of the content.
|
|
170
|
+
* @param content The full content of the file containing the error.
|
|
171
|
+
* @returns An object containing the line and column
|
|
172
|
+
*/
|
|
173
|
+
function getJsonErrorLineColumn(offset, content) {
|
|
174
|
+
if (offset === 0) {
|
|
175
|
+
return { line: 1, column: 1 };
|
|
176
|
+
}
|
|
177
|
+
let line = 0;
|
|
178
|
+
let position = 0;
|
|
179
|
+
// eslint-disable-next-line no-constant-condition
|
|
180
|
+
while (true) {
|
|
181
|
+
++line;
|
|
182
|
+
const nextNewline = content.indexOf('\n', position);
|
|
183
|
+
if (nextNewline === -1 || nextNewline > offset) {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
position = nextNewline + 1;
|
|
187
|
+
}
|
|
188
|
+
return { line, column: offset - position + 1 };
|
|
189
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { Diagnostics } from '@angular/localize/tools';
|
|
9
|
+
export type TranslationLoader = (path: string) => {
|
|
10
|
+
translations: Record<string, import('@angular/localize').ɵParsedTranslation>;
|
|
11
|
+
format: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
diagnostics: Diagnostics;
|
|
14
|
+
integrity: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function createTranslationLoader(): Promise<TranslationLoader>;
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.createTranslationLoader = void 0;
|
|
34
|
+
const crypto_1 = require("crypto");
|
|
35
|
+
const fs = __importStar(require("fs"));
|
|
36
|
+
const load_esm_1 = require("./load-esm");
|
|
37
|
+
async function createTranslationLoader() {
|
|
38
|
+
const { parsers, diagnostics } = await importParsers();
|
|
39
|
+
return (path) => {
|
|
40
|
+
const content = fs.readFileSync(path, 'utf8');
|
|
41
|
+
const unusedParsers = new Map();
|
|
42
|
+
for (const [format, parser] of Object.entries(parsers)) {
|
|
43
|
+
const analysis = parser.analyze(path, content);
|
|
44
|
+
if (analysis.canParse) {
|
|
45
|
+
// Types don't overlap here so we need to use any.
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
const { locale, translations } = parser.parse(path, content, analysis.hint);
|
|
48
|
+
const integrity = 'sha256-' + (0, crypto_1.createHash)('sha256').update(content).digest('base64');
|
|
49
|
+
return { format, locale, translations, diagnostics, integrity };
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
unusedParsers.set(parser, analysis);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const messages = [];
|
|
56
|
+
for (const [parser, analysis] of unusedParsers.entries()) {
|
|
57
|
+
messages.push(analysis.diagnostics.formatDiagnostics(`*** ${parser.constructor.name} ***`));
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`Unsupported translation file format in ${path}. The following parsers were tried:\n` +
|
|
60
|
+
messages.join('\n'));
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.createTranslationLoader = createTranslationLoader;
|
|
64
|
+
async function importParsers() {
|
|
65
|
+
try {
|
|
66
|
+
// Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
|
|
67
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
68
|
+
// changed to a direct dynamic import.
|
|
69
|
+
const { Diagnostics, ArbTranslationParser, SimpleJsonTranslationParser, Xliff1TranslationParser, Xliff2TranslationParser, XtbTranslationParser, } = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
|
70
|
+
const diagnostics = new Diagnostics();
|
|
71
|
+
const parsers = {
|
|
72
|
+
arb: new ArbTranslationParser(),
|
|
73
|
+
json: new SimpleJsonTranslationParser(),
|
|
74
|
+
xlf: new Xliff1TranslationParser(),
|
|
75
|
+
xlf2: new Xliff2TranslationParser(),
|
|
76
|
+
// The name ('xmb') needs to match the AOT compiler option
|
|
77
|
+
xmb: new XtbTranslationParser(),
|
|
78
|
+
};
|
|
79
|
+
return { parsers, diagnostics };
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
throw new Error(`Unable to load translation file parsers. Please ensure '@angular/localize' is installed.`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { AssetPattern, AssetPatternClass } from '../builders/application/schema';
|
|
9
|
+
export declare class MissingAssetSourceRootException extends Error {
|
|
10
|
+
constructor(path: string);
|
|
11
|
+
}
|
|
12
|
+
export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined): (AssetPatternClass & {
|
|
13
|
+
output: string;
|
|
14
|
+
})[];
|
|
@@ -0,0 +1,96 @@
|
|
|
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.normalizeAssetPatterns = exports.MissingAssetSourceRootException = void 0;
|
|
37
|
+
const fs_1 = require("fs");
|
|
38
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
class MissingAssetSourceRootException extends Error {
|
|
41
|
+
constructor(path) {
|
|
42
|
+
super(`The ${path} asset path must start with the project source root.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.MissingAssetSourceRootException = MissingAssetSourceRootException;
|
|
46
|
+
function normalizeAssetPatterns(assetPatterns, workspaceRoot, projectRoot, projectSourceRoot) {
|
|
47
|
+
if (assetPatterns.length === 0) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
// When sourceRoot is not available, we default to ${projectRoot}/src.
|
|
51
|
+
const sourceRoot = projectSourceRoot || path.join(projectRoot, 'src');
|
|
52
|
+
const resolvedSourceRoot = path.resolve(workspaceRoot, sourceRoot);
|
|
53
|
+
return assetPatterns.map((assetPattern) => {
|
|
54
|
+
// Normalize string asset patterns to objects.
|
|
55
|
+
if (typeof assetPattern === 'string') {
|
|
56
|
+
const assetPath = path.normalize(assetPattern);
|
|
57
|
+
const resolvedAssetPath = path.resolve(workspaceRoot, assetPath);
|
|
58
|
+
// Check if the string asset is within sourceRoot.
|
|
59
|
+
if (!resolvedAssetPath.startsWith(resolvedSourceRoot)) {
|
|
60
|
+
throw new MissingAssetSourceRootException(assetPattern);
|
|
61
|
+
}
|
|
62
|
+
let glob, input;
|
|
63
|
+
let isDirectory = false;
|
|
64
|
+
try {
|
|
65
|
+
isDirectory = (0, fs_1.statSync)(resolvedAssetPath).isDirectory();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
isDirectory = true;
|
|
69
|
+
}
|
|
70
|
+
if (isDirectory) {
|
|
71
|
+
// Folders get a recursive star glob.
|
|
72
|
+
glob = '**/*';
|
|
73
|
+
// Input directory is their original path.
|
|
74
|
+
input = assetPath;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Files are their own glob.
|
|
78
|
+
glob = path.basename(assetPath);
|
|
79
|
+
// Input directory is their original dirname.
|
|
80
|
+
input = path.dirname(assetPath);
|
|
81
|
+
}
|
|
82
|
+
// Output directory for both is the relative path from source root to input.
|
|
83
|
+
const output = path.relative(resolvedSourceRoot, path.resolve(workspaceRoot, input));
|
|
84
|
+
assetPattern = { glob, input, output };
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
assetPattern.output = path.join('.', assetPattern.output ?? '');
|
|
88
|
+
}
|
|
89
|
+
(0, node_assert_1.default)(assetPattern.output !== undefined);
|
|
90
|
+
if (assetPattern.output.startsWith('..')) {
|
|
91
|
+
throw new Error('An asset cannot be written to a location outside of the output path.');
|
|
92
|
+
}
|
|
93
|
+
return assetPattern;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.normalizeAssetPatterns = normalizeAssetPatterns;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export interface NormalizedCachedOptions {
|
|
9
|
+
/** Whether disk cache is enabled. */
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
/** Disk cache path. Example: `/.angular/cache/v12.0.0`. */
|
|
12
|
+
path: string;
|
|
13
|
+
/** Disk cache base path. Example: `/.angular/cache`. */
|
|
14
|
+
basePath: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function normalizeCacheOptions(projectMetadata: unknown, worspaceRoot: string): NormalizedCachedOptions;
|
|
@@ -0,0 +1,44 @@
|
|
|
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.normalizeCacheOptions = void 0;
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
/** Version placeholder is replaced during the build process with actual package version */
|
|
13
|
+
const VERSION = '18.0.0-next.3';
|
|
14
|
+
function hasCacheMetadata(value) {
|
|
15
|
+
return (!!value &&
|
|
16
|
+
typeof value === 'object' &&
|
|
17
|
+
'cli' in value &&
|
|
18
|
+
!!value['cli'] &&
|
|
19
|
+
typeof value['cli'] === 'object' &&
|
|
20
|
+
'cache' in value['cli']);
|
|
21
|
+
}
|
|
22
|
+
function normalizeCacheOptions(projectMetadata, worspaceRoot) {
|
|
23
|
+
const cacheMetadata = hasCacheMetadata(projectMetadata) ? projectMetadata.cli.cache : {};
|
|
24
|
+
const { enabled = true, environment = 'local', path = '.angular/cache' } = cacheMetadata;
|
|
25
|
+
const isCI = process.env['CI'] === '1' || process.env['CI']?.toLowerCase() === 'true';
|
|
26
|
+
let cacheEnabled = enabled;
|
|
27
|
+
if (cacheEnabled) {
|
|
28
|
+
switch (environment) {
|
|
29
|
+
case 'ci':
|
|
30
|
+
cacheEnabled = isCI;
|
|
31
|
+
break;
|
|
32
|
+
case 'local':
|
|
33
|
+
cacheEnabled = !isCI;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const cacheBasePath = (0, node_path_1.resolve)(worspaceRoot, path);
|
|
38
|
+
return {
|
|
39
|
+
enabled: cacheEnabled,
|
|
40
|
+
basePath: cacheBasePath,
|
|
41
|
+
path: (0, node_path_1.join)(cacheBasePath, VERSION),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.normalizeCacheOptions = normalizeCacheOptions;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { FontsClass, OptimizationClass, OptimizationUnion, StylesClass } from '../builders/application/schema';
|
|
9
|
+
export type NormalizedOptimizationOptions = Required<Omit<OptimizationClass, 'fonts' | 'styles'>> & {
|
|
10
|
+
fonts: FontsClass;
|
|
11
|
+
styles: StylesClass;
|
|
12
|
+
};
|
|
13
|
+
export declare function normalizeOptimization(optimization?: OptimizationUnion): NormalizedOptimizationOptions;
|
|
@@ -0,0 +1,42 @@
|
|
|
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.normalizeOptimization = void 0;
|
|
11
|
+
function normalizeOptimization(optimization = true) {
|
|
12
|
+
if (typeof optimization === 'object') {
|
|
13
|
+
const styleOptimization = !!optimization.styles;
|
|
14
|
+
return {
|
|
15
|
+
scripts: !!optimization.scripts,
|
|
16
|
+
styles: typeof optimization.styles === 'object'
|
|
17
|
+
? optimization.styles
|
|
18
|
+
: {
|
|
19
|
+
minify: styleOptimization,
|
|
20
|
+
removeSpecialComments: styleOptimization,
|
|
21
|
+
inlineCritical: styleOptimization,
|
|
22
|
+
},
|
|
23
|
+
fonts: typeof optimization.fonts === 'object'
|
|
24
|
+
? optimization.fonts
|
|
25
|
+
: {
|
|
26
|
+
inline: !!optimization.fonts,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
scripts: optimization,
|
|
32
|
+
styles: {
|
|
33
|
+
minify: optimization,
|
|
34
|
+
inlineCritical: optimization,
|
|
35
|
+
removeSpecialComments: optimization,
|
|
36
|
+
},
|
|
37
|
+
fonts: {
|
|
38
|
+
inline: optimization,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.normalizeOptimization = normalizeOptimization;
|
|
@@ -0,0 +1,9 @@
|
|
|
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 { SourceMapClass, SourceMapUnion } from '../builders/application/schema';
|
|
9
|
+
export declare function normalizeSourceMaps(sourceMap: SourceMapUnion): SourceMapClass;
|
|
@@ -0,0 +1,23 @@
|
|
|
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.normalizeSourceMaps = void 0;
|
|
11
|
+
function normalizeSourceMaps(sourceMap) {
|
|
12
|
+
const scripts = typeof sourceMap === 'object' ? sourceMap.scripts : sourceMap;
|
|
13
|
+
const styles = typeof sourceMap === 'object' ? sourceMap.styles : sourceMap;
|
|
14
|
+
const hidden = (typeof sourceMap === 'object' && sourceMap.hidden) || false;
|
|
15
|
+
const vendor = (typeof sourceMap === 'object' && sourceMap.vendor) || false;
|
|
16
|
+
return {
|
|
17
|
+
vendor,
|
|
18
|
+
hidden,
|
|
19
|
+
scripts,
|
|
20
|
+
styles,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.normalizeSourceMaps = normalizeSourceMaps;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export interface PostcssConfiguration {
|
|
9
|
+
plugins: [name: string, options?: object | string][];
|
|
10
|
+
}
|
|
11
|
+
export interface SearchDirectory {
|
|
12
|
+
root: string;
|
|
13
|
+
files: Set<string>;
|
|
14
|
+
}
|
|
15
|
+
export declare function generateSearchDirectories(roots: string[]): Promise<SearchDirectory[]>;
|
|
16
|
+
export declare function findTailwindConfiguration(searchDirectories: SearchDirectory[]): string | undefined;
|
|
17
|
+
export declare function loadPostcssConfiguration(searchDirectories: SearchDirectory[]): Promise<PostcssConfiguration | undefined>;
|
|
@@ -0,0 +1,86 @@
|
|
|
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.loadPostcssConfiguration = exports.findTailwindConfiguration = exports.generateSearchDirectories = void 0;
|
|
11
|
+
const promises_1 = require("node:fs/promises");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
const postcssConfigurationFiles = ['postcss.config.json', '.postcssrc.json'];
|
|
14
|
+
const tailwindConfigFiles = [
|
|
15
|
+
'tailwind.config.js',
|
|
16
|
+
'tailwind.config.cjs',
|
|
17
|
+
'tailwind.config.mjs',
|
|
18
|
+
'tailwind.config.ts',
|
|
19
|
+
];
|
|
20
|
+
async function generateSearchDirectories(roots) {
|
|
21
|
+
return await Promise.all(roots.map((root) => (0, promises_1.readdir)(root, { withFileTypes: true }).then((entries) => ({
|
|
22
|
+
root,
|
|
23
|
+
files: new Set(entries.filter((entry) => entry.isFile()).map((entry) => entry.name)),
|
|
24
|
+
}))));
|
|
25
|
+
}
|
|
26
|
+
exports.generateSearchDirectories = generateSearchDirectories;
|
|
27
|
+
function findFile(searchDirectories, potentialFiles) {
|
|
28
|
+
for (const { root, files } of searchDirectories) {
|
|
29
|
+
for (const potential of potentialFiles) {
|
|
30
|
+
if (files.has(potential)) {
|
|
31
|
+
return (0, node_path_1.join)(root, potential);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
function findTailwindConfiguration(searchDirectories) {
|
|
38
|
+
return findFile(searchDirectories, tailwindConfigFiles);
|
|
39
|
+
}
|
|
40
|
+
exports.findTailwindConfiguration = findTailwindConfiguration;
|
|
41
|
+
async function readPostcssConfiguration(configurationFile) {
|
|
42
|
+
const data = await (0, promises_1.readFile)(configurationFile, 'utf-8');
|
|
43
|
+
const config = JSON.parse(data);
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
async function loadPostcssConfiguration(searchDirectories) {
|
|
47
|
+
const configPath = findFile(searchDirectories, postcssConfigurationFiles);
|
|
48
|
+
if (!configPath) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const raw = await readPostcssConfiguration(configPath);
|
|
52
|
+
// If no plugins are defined, consider it equivalent to no configuration
|
|
53
|
+
if (!raw.plugins || typeof raw.plugins !== 'object') {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
// Normalize plugin array form
|
|
57
|
+
if (Array.isArray(raw.plugins)) {
|
|
58
|
+
if (raw.plugins.length < 1) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const config = { plugins: [] };
|
|
62
|
+
for (const element of raw.plugins) {
|
|
63
|
+
if (typeof element === 'string') {
|
|
64
|
+
config.plugins.push([element]);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
config.plugins.push(element);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
// Normalize plugin object map form
|
|
73
|
+
const entries = Object.entries(raw.plugins);
|
|
74
|
+
if (entries.length < 1) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
const config = { plugins: [] };
|
|
78
|
+
for (const [name, options] of entries) {
|
|
79
|
+
if (!options || (typeof options !== 'object' && typeof options !== 'string')) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
config.plugins.push([name, options]);
|
|
83
|
+
}
|
|
84
|
+
return config;
|
|
85
|
+
}
|
|
86
|
+
exports.loadPostcssConfiguration = loadPostcssConfiguration;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
/** Delete stale cache directories used by previous versions of build-angular. */
|
|
10
|
+
export declare function purgeStaleBuildCache(context: BuilderContext): Promise<void>;
|